[tor-commits] [ooni-probe/master] Added support for calculating live bandwidth
art at torproject.org
art at torproject.org
Sun Feb 12 16:18:24 UTC 2012
commit 95dff813017a4721c94340d3a23fed2893942c20
Author: Sathyanarayanan Gunasekaran <gsathya.ceg at gmail.com>
Date: Sun Feb 12 00:36:30 2012 +0530
Added support for calculating live bandwidth
---
refactor/TorCtl | 1 +
refactor/tests/bridget.py | 20 +++++++++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/refactor/TorCtl b/refactor/TorCtl
new file mode 160000
index 0000000..3de9176
--- /dev/null
+++ b/refactor/TorCtl
@@ -0,0 +1 @@
+Subproject commit 3de91767e208d1642a8cf89dc1b645f637abaf8e
diff --git a/refactor/tests/bridget.py b/refactor/tests/bridget.py
index 5ad16c0..202181b 100644
--- a/refactor/tests/bridget.py
+++ b/refactor/tests/bridget.py
@@ -44,7 +44,8 @@ class BridgeT(Plugoo):
def writetorrc(self, bridge):
# register Tor to an ephemeral port
- socksport = random.randint(49152, 65535)
+ #socksport = random.randint(49152, 65535)
+ socksport = 9050
controlport = random.randint(49152, 65535)
randomname = "tor_"+str(random.randint(0, 424242424242))
datadir = "/tmp/" + randomname
@@ -64,7 +65,7 @@ bridge %s
DataDirectory %s
usemicrodescriptors 0
""" % (socksport, bridge, datadir)
-
+ print torrc
try:
f = open(randomname, "wb")
f.write(torrc)
@@ -86,16 +87,18 @@ usemicrodescriptors 0
@torify
def download_file(self):
+ time_start=time.time()
f = urllib2.urlopen('http://check.torproject.org')
- print f.readlines()
-
+ data= f.readlines()
+ time_end = time.time()
+ return len(data)/(time_end-time_start)
def connect(self, bridge, timeout=None):
if not timeout:
if self.config.tests.tor_bridges_timeout:
self.timeout = self.config.tests.tor_bridges_timeout
timeout = self.timeout
- self.download_file()
+ #self.download_file()
torrc, tordir, controlport = self.writetorrc(bridge)
cmd = ["tor", "-f", torrc]
@@ -114,6 +117,8 @@ usemicrodescriptors 0
c = TorCtl.connect('127.0.0.1', controlport)
bridgeinfo = self.parsebridgeinfo(c.get_info('dir/server/all')['dir/server/all'])
c.close()
+ bandwidth=self.download_file()
+ print bandwidth
p.stdout.close()
os.unlink(os.path.join(os.getcwd(), torrc))
rmtree(tordir)
@@ -122,13 +127,14 @@ usemicrodescriptors 0
'Time': datetime.now(),
'Bridge': bridge,
'Working': True,
- 'Descriptor': bridgeinfo
+ 'Descriptor': bridgeinfo,
+ 'Calculated bandwidth': bandwidth
}
if re.search("%", o):
# Keep updating the timeout if there is progress
tupdate = time.time()
- print ".",
+ print o
continue
except IOError:
More information about the tor-commits
mailing list