[tor-commits] [ooni-probe/master] Query onionoo through Tor

art at torproject.org art at torproject.org
Thu Mar 1 05:17:19 UTC 2012


commit 59e3e0e3ced2ce85f1799ea36ed0bd77abb04401
Author: Sathyanarayanan Gunasekaran <gsathya.ceg at gmail.com>
Date:   Thu Mar 1 10:32:11 2012 +0530

    Query onionoo through Tor
    
    All requests are done through Tor now. Also, Onionoo URL
    is now a global variable.
---
 tests/bridget.py |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/tests/bridget.py b/tests/bridget.py
index 13b72ea..772311c 100644
--- a/tests/bridget.py
+++ b/tests/bridget.py
@@ -37,6 +37,8 @@ try:
 except:
     print "Error TorCtl not installed!"
 
+ONIONOO_URL="http://85.214.195.203/summary/search/"
+
 class SocksiPyConnection(httplib.HTTPConnection):
     def __init__(self, proxytype, proxyaddr, proxyport = None, rdns = True,
                  username = None, password = None, *args, **kwargs):
@@ -198,15 +200,12 @@ ControlPort %s
         print (time_end-time_start)
         return str(256/(time_end-time_start)) + " KB/s"
 
-    def is_public(self, fp):
-        conn = httplib.HTTPConnection("85.214.195.203")
-        conn.request("GET", "/summary/search/"+str(fp))
-        response = conn.getresponse()
-        if response.status == 200:
-            reply = json.loads(response.read())
-            conn.close()
-            if reply['bridges'] or reply['relays']:
-                return True
+    def is_public(self, fp, socksport):
+        opener = urllib2.build_opener(SocksiPyHandler(socks.PROXY_TYPE_SOCKS5,'127.0.0.1',int(socksport)))
+        response = opener.open(str(ONIONOO_URL)+str(fp))
+        reply = json.loads(response.read())
+        if reply['bridges'] or reply['relays']:
+            return True
         return False
             
     def connect(self, bridge, timeout=None):
@@ -256,7 +255,7 @@ ControlPort %s
                     except:
                         self.logger.error("Error in connecting to Tor Control port")
 
-                    public = self.is_public(bridgeinfo['fingerprint'])
+                    public = self.is_public(bridgeinfo['fingerprint'], socksport)
                     self.logger.info("Public: %s" % public)
                     bandwidth = self.download_file(socksport)
                     self.logger.info("Bandwidth: %s" % bandwidth)





More information about the tor-commits mailing list