commit ec464979088a4de69611010b68b9c59d9123bb05 Author: Arturo Filastò art@fuffa.org Date: Sat May 18 19:12:47 2013 +0200
Only process the input when we are dealing with URLs --- nettests/blocking/tcpconnect.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/nettests/blocking/tcpconnect.py b/nettests/blocking/tcpconnect.py index 11c5558..5b432e0 100644 --- a/nettests/blocking/tcpconnect.py +++ b/nettests/blocking/tcpconnect.py @@ -48,16 +48,22 @@ class TCPConnectTest(nettest.NetTestCase): This inputProcessor extracts name:port pairs from urls XXX: Does not support unusual port numbers """ + def strip_url(address): + proto, path = x.strip().split('://') + proto = proto.lower() + host = path.split('/')[0] + if proto == 'http': + return "%s:80" % host + if proto == 'https': + return "%s:443" % host + if filename: fp = open(filename) for x in fp.readlines(): - proto, path = x.strip().split('://') - proto = proto.lower() - host = path.split('/')[0] - if proto == 'http': - yield "%s:80" % host - if proto == 'https': - yield "%s:443" % host + if x.startswith("http"): + yield strip_url(x) + else: + yield x.strip() fp.close() else: pass
tor-commits@lists.torproject.org