commit 88cfa90a7b76f2c0ff6cc3253459fce4d0790cd2 Author: Arturo Filastò arturo@filasto.net Date: Tue Apr 26 16:33:43 2016 +0200
Add --collector option to oonideckgen
* Remove unused variable in ooniprobe * Add description to requirements.txt
* Remove printing of probe IP --- Vagrantfile | 3 ++- ooni/deckgen/cli.py | 49 +++++++++++++++++++++++++++---------------------- ooni/geoip.py | 5 ++--- ooni/oonicli.py | 1 - requirements.txt | 4 ++++ 5 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/Vagrantfile b/Vagrantfile index 3eeb54c..59b2751 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -65,7 +65,9 @@ Vagrant.configure("2") do |config| backend.vm.synced_folder "../ooni-backend", "/data/ooni-backend" backend.vm.provision :shell, :inline => $setup_oonibackend end + end
+ if File.directory?("../ooni-backend") config.vm.provision "shell", inline: <<-EOF echo "To run oonibackend:" echo "1. vagrant ssh backend" @@ -73,7 +75,6 @@ Vagrant.configure("2") do |config| echo "3. cd /data/ooni-backend" echo "4. sudo ./bin/oonib -c /etc/oonibackend.conf" EOF - end
config.vm.provision "shell", inline: <<-EOF diff --git a/ooni/deckgen/cli.py b/ooni/deckgen/cli.py index 664842e..c2ebfd8 100644 --- a/ooni/deckgen/cli.py +++ b/ooni/deckgen/cli.py @@ -22,15 +22,13 @@ class Options(usage.Options): """ % sys.argv[0]
optParameters = [ - ["country-code", "c", - None, + ["country-code", "c", None, "Specify the two letter country code for which we should " - "generate the deck." - ], - ["output", "o", - None, - "Specify the directory where to write output." - ] + "generate the deck."], + ["collector", None, None, "Specify a custom collector to use when " + "submitting reports"], + ["output", "o", None, + "Specify the directory where to write output."] ]
def opt_version(self): @@ -41,33 +39,40 @@ class Options(usage.Options): class Deck(object): _base_entry = { "options": { + "test_file": None, + "subargs": [], + "annotations": None, + "collector": None, - "help": 0, - "logfile": None, - "no-default-reporter": 0, - "parallelism": None, - "pcapfile": None, + # XXX setting this is currently not supported + "bouncer": None, + "reportfile": None, - "resume": 0, - "testdeck": None + + "no-collector": 0, + "no-geoip": 0, + "no-yamloo": 0, + "verbose": 0 } }
- def __init__(self): - self.deck = [] + def __init__(self, collector=None): + self.deck_entries = [] + self.collector = collector
def add_test(self, test_file, subargs=[]): deck_entry = copy.deepcopy(self._base_entry) + deck_entry['options']['collector'] = self.collector deck_entry['options']['test_file'] = test_file deck_entry['options']['subargs'] = subargs - self.deck.append(deck_entry) + self.deck_entries.append(deck_entry)
def pprint(self): - print yaml.safe_dump(self.deck) + print yaml.safe_dump(self.deck_entries)
def write_to_file(self, filename): with open(filename, "w+") as f: - f.write(yaml.safe_dump(self.deck)) + f.write(yaml.safe_dump(self.deck_entries))
def generate_deck(options): @@ -89,11 +94,11 @@ def generate_deck(options): options['output'] )
- deck = Deck() + deck = Deck(collector=options['collector']) deck.add_test('manipulation/http_invalid_request_line') deck.add_test('manipulation/http_header_field_manipulation')
- if url_list_country is not None: + if url_list_country is not None: deck.add_test('blocking/http_requests', ['-f', url_list_country]) deck.add_test('blocking/http_requests', ['-f', url_list_global])
diff --git a/ooni/geoip.py b/ooni/geoip.py index 417c7d5..dcc799e 100644 --- a/ooni/geoip.py +++ b/ooni/geoip.py @@ -6,7 +6,6 @@ import random from hashlib import sha256
from twisted.web import client, http_headers -from ooni.utils.net import hasRawSocketPermission
client._HTTP11ClientFactory.noisy = False
@@ -183,7 +182,7 @@ class ProbeIP(object): else: try: yield self.askTor() - log.msg("Found your IP via Tor %s" % self.address) + log.msg("Found your IP via Tor") self.resolveGeodata() defer.returnValue(self.address) except errors.TorStateNotFound: @@ -193,7 +192,7 @@ class ProbeIP(object):
try: yield self.askGeoIPService() - log.msg("Found your IP via a GeoIP service: %s" % self.address) + log.msg("Found your IP via a GeoIP service") self.resolveGeodata() defer.returnValue(self.address) except Exception: diff --git a/ooni/oonicli.py b/ooni/oonicli.py index 3be64a9..4da81bc 100644 --- a/ooni/oonicli.py +++ b/ooni/oonicli.py @@ -59,7 +59,6 @@ class Options(usage.Options): tracer = None
def __init__(self): - self['test'] = None usage.Options.__init__(self)
def getUsage(self, width=None): diff --git a/requirements.txt b/requirements.txt index fc6f629..229504b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,8 @@ +# These are dependencies of ooniprobe depedencies that require specific +# versions. pyasn1>=0.1.8 + +# These are direct dependencies of ooniprobe. PyYAML>=3.10 Twisted>=13.2.0 ipaddr>=2.1.10