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

Commit

Permalink
Add baseurl as parameter to BwScan so that other URLs can be used.
Browse files Browse the repository at this point in the history
  • Loading branch information
juga0 committed Feb 3, 2018
1 parent 943e003 commit 14d2cb9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bwscanner/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DownloadIncomplete(Exception):


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

self.tasks = []
self.circuits = None
self.baseurl = 'https://bwauth.torproject.org/bwauth.torproject.org'
self.baseurl = baseurl
self.bw_files = {
64*1024: ("64M", "913b3c5df256d62235f955fa936e7a4e2d5e0cb6"),
32*1024: ("32M", "a536076ef51c2cfff607fec2d362671e031d6b48"),
Expand Down
10 changes: 7 additions & 3 deletions bwscanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


BWSCAN_VERSION = '0.0.1'

BASEURL = 'https://bwauth.torproject.org/bwauth.torproject.org'

class ScanInstance(object):
"""
Expand Down Expand Up @@ -65,6 +65,10 @@ def cli(ctx, data_dir, loglevel, logfile, launch_tor, circuit_build_timeout):


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

scan.tor_state.addCallback(BwScan, reactor, scan_data_dir,
scan.tor_state.addCallback(BwScan, reactor, scan_data_dir, baseurl,
request_timeout=timeout,
request_limit=request_limit,
partitions=partitions,
Expand Down
2 changes: 1 addition & 1 deletion test/test_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def render_GET(self, request):
def test_scan_chutney(self):
# check that each run is producing the same input set!
self.tmp = mkdtemp()
scan = BwScan(self.tor_state, reactor, self.tmp)
scan = BwScan(self.tor_state, reactor, self.tmp, None)
scan.baseurl = 'http://127.0.0.1:{}'.format(self.port)

def check_all_routers_measured(measurement_dir):
Expand Down

0 comments on commit 14d2cb9

Please sign in to comment.