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 ["logfile", "l", None, "Path to web CLF (Combined Log Format) log file."],
15 ["https", None, None, "Port to listen on for Secure HTTP."],
16 ["certificate", "c", "server.pem", "SSL certificate to use for HTTPS. "],
17 ["privkey", "k", "server.pem", "SSL certificate to use for HTTPS."],
18 ["staticpath", "s", "static", "Path to static content"],
21 optFlags
= [["notracebacks", "n", "Display tracebacks in broken web pages. " +
22 "Displaying tracebacks to users may be security risk!"],
25 zsh_actions
= {"logfile" : "_files -g '*.log'", "certificate" : "_files -g '*.pem'",
26 "privkey" : "_files -g '*.pem'"}
28 def postOptions(self
):
31 from twisted
.internet
.ssl
import DefaultOpenSSLContextFactory
33 raise usage
.UsageError("SSL support not installed")
35 class QWebIRCServiceMaker(object):
36 implements(IServiceMaker
, IPlugin
)
38 description
= "QuakeNet web-based IRC client"
41 def makeService(self
, config
):
43 site
= RootSite(config
['staticpath'], logPath
=config
['logfile'])
45 site
= RootSite(config
['staticpath'])
47 site
.displayTracebacks
= not config
["notracebacks"]
49 from twisted
.internet
.ssl
import DefaultOpenSSLContextFactory
50 i
= internet
.SSLServer(int(config
['https']), site
, DefaultOpenSSLContextFactory(config
['privkey'], config
['certificate']))
52 i
= internet
.TCPServer(int(config
['port']), site
)
56 serviceMaker
= QWebIRCServiceMaker()