[tor-commits] [ooni-probe/master] Add meek fronted requests test

art at torproject.org art at torproject.org
Mon Jul 27 13:44:20 UTC 2015


commit 54fe88a3b8151c1a41ecd597ccf6a17db32d9af7
Author: V <auser at 0>
Date:   Sun Apr 5 18:17:55 2015 +0200

    Add meek fronted requests test
---
 ooni/nettests/blocking/meek_fronted_requests.py |   74 +++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/ooni/nettests/blocking/meek_fronted_requests.py b/ooni/nettests/blocking/meek_fronted_requests.py
new file mode 100644
index 0000000..20f42c9
--- /dev/null
+++ b/ooni/nettests/blocking/meek_fronted_requests.py
@@ -0,0 +1,74 @@
+# -*- encoding: utf-8 -*-
+#
+# :licence: see LICENSE
+
+from twisted.python import usage
+from ooni.templates import httpt
+from ooni.utils import log
+
+class UsageOptions(usage.Options):
+    optParameters = [ ['ExpectedBody', 'B',
+                         'I’m just a happy little web server.\n',
+                          'Expected body content from GET response'],
+                      ['DomainName', 'D', None,
+                        'Specify a single fronted DomainName to test.'],
+                      ['HostHeader', 'H', None,
+                        'Specify "inside" Host Header to test.']
+                    ]
+
+class meekTest(httpt.HTTPTest):
+    """
+    Performs a HTTP GET request to a list of fronted domains with the Host
+    Header of the "inside" meek-server. The meek-server handles a GET request
+    and response with: "I’m just a happy little web server.\n".
+    The input file should be formatted as (one per line):
+    "DomainName:HostHeader"
+
+    Some default meek DomainName and HostHeader combinations:
+    www.google.com:meek-reflect.appspot.com
+    ajax.aspnetcdn.com:az668014.vo.msecnd.net
+    a0.awsstatic.com:d2zfqthxsdq309.cloudfront.net
+    """
+    name = "meek fronted requests test"
+    version = "0.0.1"
+
+    usageOptions = UsageOptions
+    inputFile = ['file', 'f', None,
+                  "File containing the DomainName:HostHeader combinations to\
+                  be tested, one per line."]
+
+    requiresRoot = False
+    requiresTor = False
+
+    def setUp(self):
+        """
+        Check for inputs.
+        """
+        if self.input:
+            self.DomainName, self.header = self.input.split(':')
+        elif (self.localOptions['DomainName'] and
+              self.localOptions['HostHeader']):
+               self.DomainName = self.localOptions['DomainName']
+               self.header = self.localOptions['HostHeader']
+        else:
+            raise Exception("No input specified")
+
+        self.ExpectedBody = self.localOptions['ExpectedBody']
+        self.DomainName = 'https://' + self.DomainName
+
+    def test_meek_response(self):
+        """
+        Detects if the fronted request is blocked.
+        """
+        log.msg("Testing fronted domain:%s with Host Header:%s"
+                % (self.DomainName, self.header))
+        def process_body(body):
+            if self.ExpectedBody != body:
+                self.report['censored'] = True
+            else:
+                self.report['censored'] = False
+
+        headers = {}
+        headers['Host'] = [self.header]
+        return self.doRequest(self.DomainName, method="GET", headers=headers,
+                              body_processor=process_body)





More information about the tor-commits mailing list