Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

Commit 14d2cb9

Browse files
committed
Add baseurl as parameter to BwScan so that other URLs can be used.
1 parent 943e003 commit 14d2cb9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

bwscanner/measurement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DownloadIncomplete(Exception):
2020

2121

2222
class BwScan(object):
23-
def __init__(self, state, clock, measurement_dir, **kwargs):
23+
def __init__(self, state, clock, measurement_dir, baseurl, **kwargs):
2424
"""
2525
state: the txtorcon state object
2626
clock: this argument is normally the twisted global reactor object but
@@ -44,7 +44,7 @@ def __init__(self, state, clock, measurement_dir, **kwargs):
4444

4545
self.tasks = []
4646
self.circuits = None
47-
self.baseurl = 'https://bwauth.torproject.org/bwauth.torproject.org'
47+
self.baseurl = baseurl
4848
self.bw_files = {
4949
64*1024: ("64M", "913b3c5df256d62235f955fa936e7a4e2d5e0cb6"),
5050
32*1024: ("32M", "a536076ef51c2cfff607fec2d362671e031d6b48"),

bwscanner/scanner.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
BWSCAN_VERSION = '0.0.1'
15-
15+
BASEURL = 'https://bwauth.torproject.org/bwauth.torproject.org'
1616

1717
class ScanInstance(object):
1818
"""
@@ -65,6 +65,10 @@ def cli(ctx, data_dir, loglevel, logfile, launch_tor, circuit_build_timeout):
6565

6666

6767
@cli.command(short_help="Measure the Tor relays.")
68+
# FIXME: when having a configuration file the default will be given by it.
69+
@click.option('--baseurl',
70+
help='URL that provides the files to perform the measurements with',
71+
default=BASEURL)
6872
@click.option('--partitions', '-p', default=1,
6973
help='Divide the set of relays into subsets. 1 by default.')
7074
@click.option('--current-partition', '-c', default=1,
@@ -75,7 +79,7 @@ def cli(ctx, data_dir, loglevel, logfile, launch_tor, circuit_build_timeout):
7579
help='Limit the number of simultaneous bandwidth measurements '
7680
'(default: %d).' % 10)
7781
@pass_scan
78-
def scan(scan, partitions, current_partition, timeout, request_limit):
82+
def scan(scan, baseurl, partitions, current_partition, timeout, request_limit):
7983
"""
8084
Start a scan through each Tor relay to measure it's bandwidth.
8185
"""
@@ -91,7 +95,7 @@ def rename_finished_scan(deferred):
9195
click.echo(deferred)
9296
os.rename(scan_data_dir, os.path.join(scan.measurement_dir, scan_time))
9397

94-
scan.tor_state.addCallback(BwScan, reactor, scan_data_dir,
98+
scan.tor_state.addCallback(BwScan, reactor, scan_data_dir, baseurl,
9599
request_timeout=timeout,
96100
request_limit=request_limit,
97101
partitions=partitions,

test/test_measurement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def render_GET(self, request):
3737
def test_scan_chutney(self):
3838
# check that each run is producing the same input set!
3939
self.tmp = mkdtemp()
40-
scan = BwScan(self.tor_state, reactor, self.tmp)
40+
scan = BwScan(self.tor_state, reactor, self.tmp, None)
4141
scan.baseurl = 'http://127.0.0.1:{}'.format(self.port)
4242

4343
def check_all_routers_measured(measurement_dir):

0 commit comments

Comments
 (0)