=================
This document contains instructions on installing punjab
-on your system.
+on your system.
-------------
Obtaining Punjab
-------------
-Punjab can be located at the punjab web site,
+Punjab can be located at the punjab web site,
- http://code.stanziq.com/punjab
+ http://github.com/twonds/punjab
-------------
- Twisted >= 2.5
- - Twisted-names
+ - Twisted-names
- Twisted-words >= 0.6.0
- Twisted-web >= 0.5.0
Recommended
- Twisted-conch >= 0.5.0
- NOTE :
- You can download all of these packages with the Twisted Sumo package.
+ NOTE :
+ You can download all of these packages with the Twisted Sumo package.
http://twistedmatrix.com/
- pyopenssl - if you want tls to work.
Installing Punjab
-------------
-1. Untar the current punjab-X.X.tar.gz file in a directory you would
- like punjab to reside.
+1. Untar the current punjab-X.X.tar.gz file in a directory you would
+ like punjab to reside.
shell>tar vxzf punjab-X.X.tar.gz
shell>python setup.py install
-3. Configure punjab - using a tac file.
+3. Run punjab
-shell>edit punjab.tac
-# punjab tac file
-from twisted.web import server, resource, static
-from twisted.application import service, internet
+shell>twistd punjab
-from punjab.httpb import Httpb, HttpbService
+Run "twistd punjab --help" for options.
-root = static.File("./html") # a static html directory
+4. HAVE FUN!!
-b = resource.IResource(HttpbService(1))
-root.putChild('bosh', b) # url for BOSH
-
-site = server.Site(root)
-
-application = service.Application("punjab")
-internet.TCPServer(5280, site).setServiceParent(application)
-
-
-4. Run punjab
-
-shell>twistd -y punjab.tac
-
-5. HAVE FUN!!
-
-
---------------
-Using a tac file.
---------------------------
Extending Punjab
---------------------------
-You are able to extend punjab in many ways.
+You are able to extend punjab in many ways.
+
+For configuration flexibility you can use a .tac file. See punjab.tac for
+details.
-------------
Support
-------------
- http://code.stanziq.com/punjab
+ http://github.com/twonds/punjab
# punjab tac file
+# tac documentation is at the following URL:
+# http://twistedmatrix.com/documents/current/core/howto/application.html
from twisted.web import server, resource, static
from twisted.application import service, internet
application = service.Application("punjab")
internet.TCPServer(5280, site).setServiceParent(application)
+# To run this simply to twistd -y punjab.tac
Punjab - multiple http interfaces to jabber.
"""
-from twisted.python import log
+from OpenSSL import SSL
+
from twisted.application import service
+from twisted.internet import ssl
+from twisted.python import log
+
import patches
+
+# Override DefaultOpenSSLContextFactory to call ctx.use_certificate_chain_file
+# instead of ctx.use_certificate_file, to allow certificate chains to be loaded.
+class OpenSSLContextFactoryChaining(ssl.DefaultOpenSSLContextFactory):
+ def __init__(self, *args, **kwargs):
+ ssl.DefaultOpenSSLContextFactory.__init__(self, *args, **kwargs)
+
+ def cacheContext(self):
+ ctx = self._contextFactory(self.sslmethod)
+ ctx.set_options(SSL.OP_NO_SSLv2)
+ ctx.use_certificate_chain_file(self.certificateFileName)
+ ctx.use_privatekey_file(self.privateKeyFileName)
+ self._context = ctx
+
+
def uriCheck(elem, uri):
"""
This is a hack for older versions of twisted words, we need to get rid of it.
site = server.Site(r)
-
if config['ssl']:
- from twisted.internet import ssl
- from OpenSSL import SSL
- ssl_context = ssl.DefaultOpenSSLContextFactory(config['ssl_privkey'],
+ ssl_context = OpenSSLContextFactoryChaining(config['ssl_privkey'],
config['ssl_cert'],
SSL.SSLv23_METHOD,)
sm = internet.SSLServer(int(config['port']),
+++ /dev/null
-
-from twisted.python import usage
-import punjab
-
-class Options(usage.Options):
- optParameters = [
- ('host', None, 'localhost'),
- ('port', None, 5280),
- ('httpb', 'b', "http-bind"),
- ('polling', None, '15'),
- ('html_dir', None, "./html"),
- ('ssl', None, None),
- ('ssl_privkey', None, "ssl.key"),
- ('ssl_cert', None, "ssl.crt"),
- ('white_list', None, None,
- 'Comma separated list of domains to allow connections to. \
- Begin an entry with a period to allow connections to subdomains. \
- e.g.: --white_list=.example.com,domain.com'),
- ('black_list', None, None,
- 'Comma separated list of domains to deny connections to. ' \
- 'Begin an entry with a period to deny connections to subdomains. '\
- 'e.g.: --black_list=.example.com,domain.com'),
- ]
-
- optFlags = [
- ('verbose', 'v', 'Show traffic'),
- ]
-
-
-def makeService(config):
- return punjab.makeService(config)
+++ /dev/null
-
-from twisted.scripts.mktap import _tapHelper
-
-Punjab = _tapHelper(
- "Punjab",
- "punjab.tap",
- "A HTTP XMPP client interface",
- "punjab")
--- /dev/null
+from zope.interface import implements
+from twisted.python import usage
+from twisted.plugin import IPlugin
+from twisted.application.service import IServiceMaker
+
+# Due to the directory layout, and the fact that plugin directories aren't
+# modules (no __init__.py), this file is named something other than punjab.py,
+# to ensure that this import pulls in the right module.
+import punjab
+
+class Options(usage.Options):
+ optParameters = [
+ ('host', None, 'localhost'),
+ ('port', None, 5280),
+ ('httpb', 'b', "http-bind"),
+ ('polling', None, '15'),
+ ('html_dir', None, "./html"),
+ ('ssl', None, None),
+ ('ssl_privkey', None, "ssl.key"),
+ ('ssl_cert', None, "ssl.crt"),
+ ('white_list', None, None,
+ 'Comma separated list of domains to allow connections to. \
+ Begin an entry with a period to allow connections to subdomains. \
+ e.g.: --white_list=.example.com,domain.com'),
+ ('black_list', None, None,
+ 'Comma separated list of domains to deny connections to. ' \
+ 'Begin an entry with a period to deny connections to subdomains. '\
+ 'e.g.: --black_list=.example.com,domain.com'),
+ ]
+
+ optFlags = [
+ ('verbose', 'v', 'Show traffic'),
+ ]
+
+class ServiceFactory(object):
+ implements(IServiceMaker, IPlugin)
+ tapname = "punjab"
+ description = "A HTTP XMPP client interface"
+ options = Options
+
+ def makeService(self, options):
+ return punjab.makeService(options)
+
+service = ServiceFactory()
+