source: ralphm-patches/component_server.patch @ 34:e46c5701df9e

Last change on this file since 34:e46c5701df9e was 34:e46c5701df9e, checked in by Ralph Meijer <ralphm@…>, 11 years ago

Add a bunch of new patches.

File size: 2.6 KB
  • new file twisted/plugins/server.py

    diff -r c9d1bf0b783d twisted/plugins/server.py
    - +  
     1# Copyright (c) 2003-2009 Ralph Meijer
     2# See LICENSE for details.
     3
     4from twisted.application.service import ServiceMaker
     5
     6WokkelXMPPComponentServer = ServiceMaker(
     7    "XMPP Component Server",
     8    "wokkel.componentservertap",
     9    "An XMPP Router server",
     10    "wokkel-component-server")
  • new file wokkel/componentservertap.py

    diff -r c9d1bf0b783d wokkel/componentservertap.py
    - +  
     1from twisted.application import service, strports
     2from twisted.python import usage
     3from twisted.words.protocols.jabber import component
     4from wokkel import server
     5
     6class Options(usage.Options):
     7
     8    optParameters = [
     9            ('component-port', None, 'tcp:5347:interface=127.0.0.1',
     10                'Port components connect to'),
     11            ('component-secret', None, 'secret',
     12                'Secret components use to connect'),
     13            ('server-port', None, '5269',
     14                'Port other servers connect to'),
     15            ('server-secret', None, 'secret',
     16                'Shared secret for dialback verification'),
     17    ]
     18
     19    optFlags = [
     20            ('verbose', 'v', 'Log traffic'),
     21    ]
     22
     23    def __init__(self):
     24        usage.Options.__init__(self)
     25        self['domains'] = []
     26
     27    def opt_domain(self, domain):
     28        self['domains'].append(domain)
     29
     30    def postOptions(self):
     31        if not self['domains']:
     32            raise usage.UsageError('Need at least one domain')
     33
     34
     35
     36def makeService(config):
     37    s = service.MultiService()
     38
     39    router = component.Router()
     40
     41    # Set up the XMPP server service
     42
     43    serverService = server.ServerService(router, secret=config['server-secret'])
     44    serverService.domains = config['domains']
     45    serverService.logTraffic = config['verbose']
     46
     47    # Hook up XMPP server-to-server service
     48    s2sFactory = server.XMPPS2SServerFactory(serverService)
     49    s2sFactory.logTraffic = config['verbose']
     50    s2sService = strports.service(config['server-port'], s2sFactory)
     51    s2sService.setServiceParent(s)
     52
     53    # Hook up XMPP external server-side component service
     54    cFactory = component.XMPPComponentServerFactory(router,
     55                                                    config['component-secret'])
     56
     57    cFactory.logTraffic = config['verbose']
     58    cServer = strports.service(config['component-port'], cFactory)
     59    cServer.setServiceParent(s)
     60
     61    return s
Note: See TracBrowser for help on using the repository browser.