[Telepathy-commits] [telepathy-gabble/master] bytestream.py: add listen_socks5

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Feb 20 07:30:20 PST 2009


---
 tests/twisted/bytestream.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tests/twisted/bytestream.py b/tests/twisted/bytestream.py
index 9ca9c3f..450ad3c 100644
--- a/tests/twisted/bytestream.py
+++ b/tests/twisted/bytestream.py
@@ -5,6 +5,7 @@ from twisted.internet.protocol import Factory, Protocol
 from twisted.internet import reactor
 from twisted.words.protocols.jabber.client import IQ
 from twisted.words.xish import xpath, domish
+from twisted.internet.error import CannotListenError
 
 from servicetest import Event
 import ns
@@ -149,6 +150,17 @@ def socks5_connect(q, host, port, sid,  initiator, target):
 
     return transport
 
+def listen_socks5(q):
+    for port in range(5000,5100):
+        try:
+            reactor.listenTCP(port, S5BFactory(q.append))
+        except CannotListenError:
+            continue
+        else:
+            return port
+
+    assert False, "Can't find a free port"
+
 def send_socks5_init(stream, from_, to, sid, mode, hosts):
     iq = IQ(stream, 'set')
     iq['to'] = to
-- 
1.5.6.5




More information about the telepathy-commits mailing list