[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Add URL inputProcessor to tcpconnect
commit 16f41c0f74f9d61b7e8439c719d73641da3e24c8
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Sat May 4 16:49:51 2013 +0800
Add URL inputProcessor to tcpconnect
---
nettests/blocking/tcpconnect.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/nettests/blocking/tcpconnect.py b/nettests/blocking/tcpconnect.py
index 3b22427..11c5558 100644
--- a/nettests/blocking/tcpconnect.py
+++ b/nettests/blocking/tcpconnect.py
@@ -43,3 +43,21 @@ class TCPConnectTest(nettest.NetTestCase):
d.addErrback(connectionFailed)
return d
+ def inputProcessor(self, filename=None):
+ """
+ This inputProcessor extracts name:port pairs from urls
+ XXX: Does not support unusual port numbers
+ """
+ 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
+ fp.close()
+ else:
+ pass
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits