commit 022bf7374c0d16704754f441c442169b1ac7ff4a Author: Isis Lovecruft isis@patternsinthevoid.net Date: Fri Mar 16 20:08:37 2012 -0700
changed parsing logic to use new Asset.parse_line method --- assets/top-1m.txt | 21 +++++++++++---------- tests/dnstamper.py | 15 ++++++--------- 2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/assets/top-1m.txt b/assets/top-1m.txt index 9403460..293e661 100644 --- a/assets/top-1m.txt +++ b/assets/top-1m.txt @@ -1,10 +1,11 @@ -google.com -facebook.com -youtube.com -yahoo.com -baidu.com -wikipedia.org -live.com -blogspot.com -twitter.com -qq.com +1,torproject.org +2,google.com +3,facebook.com +4,youtube.com +5,yahoo.com +6,baidu.com +7,wikipedia.org +8,live.com +9,blogspot.com +10,twitter.com +11,qq.com diff --git a/tests/dnstamper.py b/tests/dnstamper.py index 1e59d26..4064831 100644 --- a/tests/dnstamper.py +++ b/tests/dnstamper.py @@ -7,7 +7,6 @@ import os import plugoo from plugoo.assets import Asset from plugoo.tests import Test -from __future__ import with_statement
__plugoo__ = "DNST" __desc__ = "DNS censorship detection test" @@ -16,11 +15,9 @@ class Top1MAsset(Asset): def __init__(self, file=None): self = Asset.__init__(self, file)
- def next_asset(self): - with self.fh as asset: - lines = asset.readlines() - for line in lines: - yield line.split(',')[1] + def parse_line(self, line): + self = Asset.parse_line(self, line) + return line.split(',')[1].replace('\n','')
class DNSTAsset(Asset): def __init__(self, file=None): @@ -53,10 +50,10 @@ class DNST(Test): control = self.lookup(address, config.tests.dns_control_server)
if len(set(exp) & set(control)) > 0: - print "%s : no tampering on %s" % (address, ns) + print "Address %s has not tampered with on DNS server %s\n" % (address, ns) return (address, ns, False) else: - print "%s : possible tampering on %s (%s, %s)" % (address, ns, exp, control) + print "Address %s has possibly been tampered on %s:\nDNS resolution through %s yeilds:\n%s\nAlthough the control group DNS servers resolve to:\n%s\n" % (address, ns, ns, exp, control) return (address, ns, exp, control, True)
def run(ooni): @@ -65,7 +62,7 @@ def run(ooni): config = ooni.config urls = []
- dns_experiment = DNSTAsset(os.path.join(config.main.assetdir, \ + dns_experiment = Top1MAsset(os.path.join(config.main.assetdir, \ config.tests.dns_experiment)) dns_experiment_dns = DNSTAsset(os.path.join(config.main.assetdir, \ config.tests.dns_experiment_dns))
tor-commits@lists.torproject.org