Commit 25de68b
zpr/vent.py
@@ -0,0 +1,27 @@
+import zmq
+import json
+
+context = zmq.Context ()
+socket = context.socket (zmq.DEALER);
+socket.bind ("tcp://*:5555")
+
+a = 1
+b = 1
+c = 1
+d = 1
+while True:
+ address = str(a) + "." + str(b) + "." + str(c) + "." + str(d)
+ socket.send("", zmq.SNDMORE)
+ socket.send(json.dumps({'url':"http://"+address,'timeout':0.05}))
+ if (d == 0) :
+ if (c == 0) :
+ if (b == 0) :
+ if (a == 0) :
+ break;
+ a = (a + 1) % 255
+ b = (b + 1) % 255
+ c = (c + 1) % 255
+ d = (d + 1) % 255
+while True:
+ msg = socket.recv()
+ print msg
zpr/worker.py
@@ -0,0 +1,22 @@
+import requests
+import json
+import zmq
+
+def get_headers (url,timeout):
+ try:
+ r = requests.get (url,timeout=timeout)
+ return json.dumps ([{'url':url},
+ {'code':r.status_code},
+ r.headers ])
+ except (requests.ConnectionError,requests.HTTPError,requests.Timeout) as e:
+ return json.dumps ([{'url':url},{'error':str(e)}])
+
+context = zmq.Context ()
+socket = context.socket (zmq.REP);
+socket.connect ("tcp://localhost:5555")
+
+while True:
+ msg = socket.recv()
+ job = json.loads (msg)
+ print job["url"], job["timeout"]
+ socket.send (get_headers (url=job['url'],timeout=job['timeout']))