1 from zope
.interface
import implements
3 from twisted
.python
import usage
4 from twisted
.internet
import task
5 from twisted
.plugin
import IPlugin
6 from twisted
.application
.service
import IServiceMaker
7 from twisted
.application
import internet
, strports
8 from twisted
.web
import static
, server
10 from qwebirc
.root
import RootSite
12 class Options(usage
.Options
):
13 optParameters
= [["port", "p", "9090","Port to start the server on."],
14 ["ip", "i", "0.0.0.0", "IP address to listen on."],
15 ["logfile", "l", None, "Path to web CLF (Combined Log Format) log file."],
16 ["https", None, None, "Port to listen on for Secure HTTP."],
17 ["certificate", "c", "server.pem", "SSL certificate to use for HTTPS. "],
18 ["privkey", "k", "server.pem", "SSL certificate to use for HTTPS."],
19 ["staticpath", "s", "static", "Path to static content"],
22 optFlags
= [["notracebacks", "n", "Display tracebacks in broken web pages. " +
23 "Displaying tracebacks to users may be security risk!"],
26 zsh_actions
= {"logfile" : "_files -g '*.log'", "certificate" : "_files -g '*.pem'",
27 "privkey" : "_files -g '*.pem'"}
29 def postOptions(self
):
32 from twisted
.internet
.ssl
import DefaultOpenSSLContextFactory
34 raise usage
.UsageError("SSL support not installed")
36 class QWebIRCServiceMaker(object):
37 implements(IServiceMaker
, IPlugin
)
39 description
= "QuakeNet web-based IRC client"
42 def makeService(self
, config
):
44 site
= RootSite(config
['staticpath'], logPath
=config
['logfile'])
46 site
= RootSite(config
['staticpath'])
48 site
.displayTracebacks
= not config
["notracebacks"]
50 from twisted
.internet
.ssl
import DefaultOpenSSLContextFactory
51 i
= internet
.SSLServer(int(config
['https']), site
, DefaultOpenSSLContextFactory(config
['privkey'], config
['certificate']), interface
=config
['ip'])
53 i
= internet
.TCPServer(int(config
['port']), site
, interface
=config
['ip'])
57 serviceMaker
= QWebIRCServiceMaker()