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@…>, 13 years ago

Add a bunch of new patches.

File size: 2.6 KB
RevLine 
[34]1diff -r c9d1bf0b783d twisted/plugins/server.py
2--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
3+++ b/twisted/plugins/server.py Mon Jan 18 08:46:19 2010 +0100
4@@ -0,0 +1,10 @@
5+# Copyright (c) 2003-2009 Ralph Meijer
6+# See LICENSE for details.
7+
8+from twisted.application.service import ServiceMaker
9+
10+WokkelXMPPComponentServer = ServiceMaker(
11+    "XMPP Component Server",
12+    "wokkel.componentservertap",
13+    "An XMPP Router server",
14+    "wokkel-component-server")
15diff -r c9d1bf0b783d wokkel/componentservertap.py
16--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
17+++ b/wokkel/componentservertap.py      Mon Jan 18 08:46:19 2010 +0100
18@@ -0,0 +1,61 @@
19+from twisted.application import service, strports
20+from twisted.python import usage
21+from twisted.words.protocols.jabber import component
22+from wokkel import server
23+
24+class Options(usage.Options):
25+
26+    optParameters = [
27+            ('component-port', None, 'tcp:5347:interface=127.0.0.1',
28+                'Port components connect to'),
29+            ('component-secret', None, 'secret',
30+                'Secret components use to connect'),
31+            ('server-port', None, '5269',
32+                'Port other servers connect to'),
33+            ('server-secret', None, 'secret',
34+                'Shared secret for dialback verification'),
35+    ]
36+
37+    optFlags = [
38+            ('verbose', 'v', 'Log traffic'),
39+    ]
40+
41+    def __init__(self):
42+        usage.Options.__init__(self)
43+        self['domains'] = []
44+
45+    def opt_domain(self, domain):
46+        self['domains'].append(domain)
47+
48+    def postOptions(self):
49+        if not self['domains']:
50+            raise usage.UsageError('Need at least one domain')
51+
52+
53+
54+def makeService(config):
55+    s = service.MultiService()
56+
57+    router = component.Router()
58+
59+    # Set up the XMPP server service
60+
61+    serverService = server.ServerService(router, secret=config['server-secret'])
62+    serverService.domains = config['domains']
63+    serverService.logTraffic = config['verbose']
64+
65+    # Hook up XMPP server-to-server service
66+    s2sFactory = server.XMPPS2SServerFactory(serverService)
67+    s2sFactory.logTraffic = config['verbose']
68+    s2sService = strports.service(config['server-port'], s2sFactory)
69+    s2sService.setServiceParent(s)
70+
71+    # Hook up XMPP external server-side component service
72+    cFactory = component.XMPPComponentServerFactory(router,
73+                                                    config['component-secret'])
74+
75+    cFactory.logTraffic = config['verbose']
76+    cServer = strports.service(config['component-port'], cFactory)
77+    cServer.setServiceParent(s)
78+
79+    return s
Note: See TracBrowser for help on using the repository browser.