Commit 9a9f6603 authored by Cecylia Bocovich's avatar Cecylia Bocovich
Browse files

modified bridge test to take as input bridge_lines.txt file since we're doing...

modified bridge test to take as input bridge_lines.txt file since we're doing probes on private bridges
parent 2b493227
[SITENAME] is an arbitrary identifier for the probe site
that you have to choose.
The bridge_lines.txt file should contain a list of bridges to test. Each line corresponds to a bridge and should be of the form:
<nickname>,<bridge_line>
where <bridge_line> is the line to go in the torrc file and is structured as follows:
obfs4 <IP:Port> <FINGERPRINT> cert=<CERT> iat-mode=0
Add to crontab to run hourly tests:
0 */1 * * * cd ~/kz && ./bridgetest.sh [SITENAME]
......
......@@ -8,6 +8,7 @@ import shutil
import subprocess
import tempfile
import time
import sys
import stem.process
......@@ -102,36 +103,40 @@ time.tzset()
logging.info("starting")
for nickname, bridge_line in BRIDGE_LINES:
datadir = tempfile.mkdtemp(prefix="datadir.", dir=".")
logging.info("created temporary DataDirectory %r", datadir)
tcpdump_proc = None
try:
logging.info("starting tcpdump for bridge %r" % nickname)
addr = get_address_from_bridge_line(bridge_line)
try:
tcpdump_proc = start_tcpdump(nickname, addr)
except OSError as e:
logging.info("failed to start tcpdump: %s", e)
# Carry on regardless.
logging.info("starting tor for bridge %r" % nickname)
logging.info("Bridge %s" % bridge_line)
tor_config = {
"DataDirectory": datadir,
"Log": "notice file %s" % os.path.join(".", "%s.log" % nickname),
"UseBridges": "1",
"Bridge": bridge_line,
}
bridge_lines_file = sys.argv[1]
with open(bridge_lines_file) as f:
for line in f:
nickname, bridge_line = line.split(",", 1)
datadir = tempfile.mkdtemp(prefix="datadir.", dir=".")
logging.info("created temporary DataDirectory %r", datadir)
tcpdump_proc = None
try:
tor_proc, _, _ = start_tor(tor_config)
except OSError as err:
logging.info("failed to start tor: %s" % err)
continue
tor_proc.terminate()
tor_proc.wait()
finally:
logging.info("deleting temporary DataDirectory %r", datadir)
shutil.rmtree(datadir)
if tcpdump_proc is not None:
tcpdump_proc.terminate()
logging.info("starting tcpdump for bridge %r" % nickname)
addr = get_address_from_bridge_line(bridge_line)
try:
tcpdump_proc = start_tcpdump(nickname, addr)
except OSError as e:
logging.info("failed to start tcpdump: %s", e)
# Carry on regardless.
logging.info("starting tor for bridge %r" % nickname)
logging.info("Bridge %s" % bridge_line)
tor_config = {
"DataDirectory": datadir,
"Log": "notice file %s" % os.path.join(".", "%s.log" % nickname),
"UseBridges": "1",
"Bridge": bridge_line,
}
try:
tor_proc, _, _ = start_tor(tor_config)
except OSError as err:
logging.info("failed to start tor: %s" % err)
continue
tor_proc.terminate()
tor_proc.wait()
finally:
logging.info("deleting temporary DataDirectory %r", datadir)
shutil.rmtree(datadir)
if tcpdump_proc is not None:
tcpdump_proc.terminate()
......@@ -7,4 +7,4 @@ SITE="${1:?}"
dirname="$PWD"
logdirname="log/$SITE/$(date -u +%Y%m%d-%H%M)"
mkdir -p "$logdirname"
cd "$logdirname" && "$dirname/bridgetest"
cd "$logdirname" && "$dirname/bridgetest" "$dirname/bridge_lines.txt"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment