Changeset 11:8294ad7253bd in ralphm-patches


Ignore:
Timestamp:
Apr 10, 2009, 3:39:02 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Allow no default domain, generate a secret if not provided.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • s2s.patch

    r10 r11  
    11diff -r 313d45b505a7 wokkel/server.py
    22--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
    3 +++ b/wokkel/server.py  Thu Apr 09 14:47:05 2009 +0200
    4 @@ -0,0 +1,702 @@
     3+++ b/wokkel/server.py  Fri Apr 10 09:38:01 2009 +0200
     4@@ -0,0 +1,709 @@
    55+# -*- test-case-name: wokkel.test.test_server -*-
    66+#
     
    3131+from twisted.internet import defer, reactor
    3232+from twisted.names.srvconnect import SRVConnector
    33 +from twisted.python import log
     33+from twisted.python import log, randbytes
    3434+from twisted.words.protocols.jabber import error, ijabber, jid, xmlstream
    3535+from twisted.words.xish import domish
     
    337337+        # Compatibility fix for pre-8.2 implementations of ListenAuthenticator
    338338+        if not self.xmlstream.sid:
    339 +            from twisted.python import randbytes
    340339+            self.xmlstream.sid = randbytes.secureRandom(8).encode('hex')
    341340+
     
    349348+            self.xmlstream.prefixes = {xmlstream.NS_STREAMS: 'stream',
    350349+                                       NS_DIALBACK: 'db'}
    351 +            self.xmlstream.thisEntity = jid.internJID(domain)
     350+            if domain:
     351+                self.xmlstream.thisEntity = jid.internJID(domain)
    352352+
    353353+        try:
     
    357357+                raise error.StreamError('invalid-namespace')
    358358+
    359 +            if targetDomain not in self.service.domains:
     359+            if not targetDomain or targetDomain not in self.service.domains:
    360360+                raise error.StreamError('host-unknown')
    361361+        except error.StreamError, exc:
     
    569569+    logTraffic = False
    570570+
    571 +    def __init__(self, router, secret, domain):
     571+    def __init__(self, router, domain=None, secret=None):
    572572+        self.router = router
    573 +        self.secret = secret
     573+
    574574+        self.defaultDomain = domain
    575 +        self.domains = set([domain])
     575+        self.domains = set()
     576+        if self.defaultDomain:
     577+            self.domains.add(self.defaultDomain)
     578+
     579+        if secret is not None:
     580+            self.secret = secret
     581+        else:
     582+            self.secret = randbytes.secureRandom(16).encode('hex')
    576583+
    577584+        self._outgoingStreams = {}
     
    707714diff -r 313d45b505a7 wokkel/test/test_server.py
    708715--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
    709 +++ b/wokkel/test/test_server.py        Thu Apr 09 14:47:05 2009 +0200
     716+++ b/wokkel/test/test_server.py        Fri Apr 10 09:38:01 2009 +0200
    710717@@ -0,0 +1,450 @@
    711718+# Copyright (c) 2003-2008 Ralph Meijer
Note: See TracChangeset for help on using the changeset viewer.