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

Commit 499e875

Browse files
committed
Move hardcoded file server and files to config file
1 parent 75f819a commit 499e875

3 files changed

Lines changed: 11 additions & 15 deletions

File tree

bwscanner/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os.path
44
import click
55

6-
default = {
6+
DEFAULT = {
77
'data_dir': click.get_app_dir('bwscanner'),
88
'measurement_dir': os.path.join(click.get_app_dir('bwscanner'),
99
'measurements'),
@@ -20,7 +20,7 @@
2020
'timeout': 120,
2121
'request_limit': 10
2222
}
23-
bw_files = {
23+
BW_FILES = {
2424
64*1024: ("64M", "6258de4f4d602be75a3458117b29d2c580c4bcb7ba5b9d2c4135c7603109f554"),
2525
32*1024: ("32M", "5a5d66d7865f09498d776f20c9e9791b055a4fff357185f84fb4ecfca7da93f0"),
2626
16*1024: ("(16M", "6258de4f4d602be75a3458117b29d2c580c4bcb7ba5b9d2c4135c7603109f554"),

bwscanner/measurement.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,8 @@ def __init__(self, state, clock, measurement_dir, **kwargs):
4343

4444
self.tasks = []
4545
self.circuits = None
46-
self.baseurl = 'https://bwauth.torproject.org/bwauth.torproject.org'
47-
self.bw_files = {
48-
64*1024: ("64M", "913b3c5df256d62235f955fa936e7a4e2d5e0cb6"),
49-
32*1024: ("32M", "a536076ef51c2cfff607fec2d362671e031d6b48"),
50-
16*1024: ("16M", "e91690ed2abf05e347b61aafaa23abf2a2b3292f"),
51-
8*1024: ("8M", "c690229b300945ec4ba872b80e8c443e2e1750f0"),
52-
4*1024: ("4M", "94f7bc6679a4419b080debd70166c2e43e80533d"),
53-
2*1024: ("2M", "9793cc92932598898d22497acdd5d732037b1a13"),
54-
}
55-
46+
self.baseurl = kwargs.get('baseurl')
47+
self.bw_files = kwargs.get('bw_files')
5648
self.result_sink = ResultSink(self.measurement_dir, chunk_size=10)
5749

5850
def now(self):

bwscanner/scanner.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from bwscanner.logger import setup_logging, log
1010
from bwscanner.measurement import BwScan
1111
from bwscanner.aggregate import write_aggregate_data
12-
from bwscanner.config import TOR_OPTIONS
12+
from bwscanner.config import TOR_OPTIONS, DEFAULT, BW_FILES
1313
from bwscanner import __version__
1414

1515

@@ -75,13 +75,15 @@ def cli(ctx, data_dir, loglevel, logfile, launch_tor, circuit_build_timeout):
7575
@click.option('--request-limit', default=10,
7676
help='Limit the number of simultaneous bandwidth measurements '
7777
'(default: %d).' % 10)
78+
@click.option('--baseurl', default=DEFAULT.get('baseurl'),
79+
help='File server URL')
7880
@pass_scan
79-
def scan(scan, partitions, current_partition, timeout, request_limit):
81+
def scan(scan, partitions, current_partition, timeout, request_limit, baseurl):
8082
"""
8183
Start a scan through each Tor relay to measure it's bandwidth.
8284
"""
8385
log.info("Using {data_dir} as the data directory.", data_dir=scan.data_dir)
84-
86+
assert isinstance(BW_FILES, dict)
8587
# XXX: check that each run is producing the same input set!
8688
scan_time = str(int(time.time()))
8789
scan_data_dir = os.path.join(scan.measurement_dir, '{}.running'.format(scan_time))
@@ -93,6 +95,8 @@ def rename_finished_scan(deferred):
9395
os.rename(scan_data_dir, os.path.join(scan.measurement_dir, scan_time))
9496

9597
scan.tor_state.addCallback(BwScan, reactor, scan_data_dir,
98+
baseurl=baseurl,
99+
bw_files=BW_FILES,
96100
request_timeout=timeout,
97101
request_limit=request_limit,
98102
partitions=partitions,

0 commit comments

Comments
 (0)