commit 16f41c0f74f9d61b7e8439c719d73641da3e24c8 Author: aagbsn aagbsn@extc.org Date: Sat May 4 16:49:51 2013 +0800
Add URL inputProcessor to tcpconnect --- nettests/blocking/tcpconnect.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
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