def postProcessor(self, measurements):
        experiment = control = None
        for status, measurement in measurements:
            net_test_method = measurement.netTestMethod.im_func.func_name

            if net_test_method == "test_get_experiment":
                if isinstance(measurement.result, failure.Failure):
                    self.report['experiment_failure'] = failureToString(
                        measurement.result)
                else:
                    experiment = measurement.result
            elif net_test_method == "test_get_control":
                if isinstance(measurement.result, failure.Failure):
                    self.report['control_failure'] = failureToString(
                        measurement.result)
                else:
                    control = measurement.result

        if experiment and control:
            if hasattr(experiment, 'body') and hasattr(control, 'body') \
                    and experiment.body and control.body:
                self.report['control_cloudflare'] = False
                if 'Attention Required! | CloudFlare' in control.body:
                    log.msg("The control body contains a blockpage from "
                            "cloudflare. This will skew our results.")
                    self.report['control_cloudflare'] = True
                self.compare_body_lengths(len(control.body),
                                          len(experiment.body))
            if hasattr(experiment, 'headers') and hasattr(control, 'headers') \
                    and experiment.headers and control.headers:
                self.compare_headers(control.headers,
                                     experiment.headers)
        return self.report
Beispiel #2
0
    def postProcessor(self, measurements):
        experiment = control = None
        for status, measurement in measurements:
            net_test_method = measurement.netTestMethod.im_func.func_name

            if net_test_method == "test_get_experiment":
                if isinstance(measurement.result, failure.Failure):
                    self.report['experiment_failure'] = failureToString(
                        measurement.result)
                else:
                    experiment = measurement.result
            elif net_test_method == "test_get_control":
                if isinstance(measurement.result, failure.Failure):
                    self.report['control_failure'] = failureToString(
                        measurement.result)
                else:
                    control = measurement.result

        if experiment and control:
            if hasattr(experiment, 'body') and hasattr(control, 'body') \
                    and experiment.body and control.body:
                self.compare_body_lengths(len(control.body),
                                          len(experiment.body))
            if hasattr(experiment, 'headers') and hasattr(control, 'headers') \
                    and experiment.headers and control.headers:
                self.compare_headers(control.headers,
                                     experiment.headers)
        return self.report
Beispiel #3
0
        def callback(res):
            experiment, control = res
            experiment_succeeded, experiment_result = experiment
            control_succeeded, control_result = control

            if control_succeeded and experiment_succeeded:
                self.compare_body_lengths(len(experiment_result.body), len(control_result.body))

                self.compare_headers(control_result.headers, experiment_result.headers)

            if not control_succeeded:
                self.report["control_failure"] = failureToString(control_result)

            if not experiment_succeeded:
                self.report["experiment_failure"] = failureToString(experiment_result)
Beispiel #4
0
    def _test_http_request(self):
        http_blocked = True
        for dc_id, address in TELEGRAM_DCS:
            if http_blocked == False:
                break
            for port in [80, 443]:
                url = 'http://{}:{}'.format(address, port)
                try:
                    response = yield self.doRequest(url, 'POST')
                except Exception as exc:
                    failure_string = failureToString(defer.failure.Failure(exc))
                    log.err("Failed to connect to {}: {}".format(url, failure_string))
                    continue
                log.debug("Got back status code {}".format(response.code))
                log.debug("{}".format(response.body))
                if response.code == 501:
                    http_blocked = False
                    break

        if http_blocked == True:
            self.report['telegram_http_blocking'] = True
            log.msg("Telegram servers are BLOCKED based on HTTP")
        else:
            self.report['telegram_http_blocking'] = False
            log.msg("Telegram servers are not blocked based on HTTP")
    def postProcessor(self, measurements):
        experiment = control = None
        for status, measurement in measurements:
            if "experiment" in str(measurement.netTestMethod):
                if isinstance(measurement.result, failure.Failure):
                    self.report["experiment_failure"] = failureToString(measurement.result)
                else:
                    experiment = measurement.result
            elif "control" in str(measurement.netTestMethod):
                if isinstance(measurement.result, failure.Failure):
                    self.report["control_failure"] = failureToString(measurement.result)
                else:
                    control = measurement.result

        if experiment and control:
            self.compare_body_lengths(len(control.body), len(experiment.body))
            self.compare_headers(control.headers, experiment.headers)
        return self.report
Beispiel #6
0
    def _test_telegram_web(self, url):
        try:
            response = yield self.doRequest(url, 'GET')
        except Exception as exc:
            failure_string = failureToString(defer.failure.Failure(exc))
            log.err("Failed to connect to telegram web %s" % failure_string)
            self.report['telegram_web_failure'] = failure_string
            self.report['telegram_web_status'] = 'blocked'
            defer.returnValue(None)

        title = extractTitle(response.body).strip()
        if title != "Telegram Web":
            self.report['telegram_web_status'] = 'blocked'
Beispiel #7
0
        def callback(res):
            experiment, control = res
            experiment_succeeded, experiment_result = experiment
            control_succeeded, control_result = control

            if control_succeeded and experiment_succeeded:
                self.compare_body_lengths(len(experiment_result.body),
                        len(control_result.body))

                self.compare_headers(control_result.headers,
                        experiment_result.headers)
            else:
                if not control_succeeded:
                    self.report['control_failure'] = failureToString(control_result)
    
                if not experiment_succeeded:
                    self.report['experiment_failure'] = failureToString(experiment_result)
                # Now return some kind of failure so we can retry
                # However, it would be ideal to split this test into two methods
                # and compare the results in the postProcessor
                # Sadly the postProcessor API is currently not implemented
                if control_succeeded:
                    return experiment_result
                return control_result
Beispiel #8
0
    def addToReport(self, query, resolver=None, query_type=None,
                    answers=None, name=None, addrs=None, failure=None):
        log.debug("Adding %s to report)" % query)
        result = {}
        result['resolver'] = resolver
        result['query_type'] = query_type
        result['query'] = repr(query)
        if failure:
            result['failure'] = failureToString(failure)

        if answers:
            result['answers'] = answers
            if name:
                result['name'] = name
            if addrs:
                result['addrs'] = addrs

        self.report['queries'].append(result)
Beispiel #9
0
    def test_registration_server(self):
        self.report['registration_server_failure'] = None
        self.report['registration_server_status'] = None

        url = 'https://v.whatsapp.net/v2/register'
        # Ensure I get back:
        # {"status": "fail", "reason": "missing_param", "param": "code"}

        try:
            yield self.doRequest(url, 'GET')
        except Exception as exc:
            failure_string = failureToString(defer.failure.Failure(exc))
            log.err("Failed to contact the registration server %s" % failure_string)
            self.report['registration_server_failure'] = failure_string
            self.report['registration_server_status'] = 'blocked'
            defer.returnValue(None)

        log.msg("Successfully connected to registration server!")
        self.report['registration_server_status'] = 'ok'
Beispiel #10
0
    def addToReport(self, query, resolver=None, query_type=None,
                    answers=None, failure=None):
        log.debug("Adding %s to report)" % query)
        result = {
            'resolver_hostname': None,
            'resolver_port': None
        }
        if resolver is not None and len(resolver) == 2:
            result['resolver_hostname'] = resolver[0]
            result['resolver_port'] = resolver[1]
        result['query_type'] = query_type
        result['hostname'] = str(query[0].name)
        result['failure'] = None
        if failure:
            result['failure'] = failureToString(failure)

        result['answers'] = []
        if answers:
            result['answers'] = answers

        self.report['queries'].append(result)
Beispiel #11
0
 def errback(failure):
     self.report['failure'] = failureToString(failure)
     d1.errback(failure)
 def errback(failure):
     self.report["failure"] = failureToString(failure)
     d1.errback(failure)
Beispiel #13
0
 def addFailureToReport(failure):
     log.debug("Failed: %s" % failureToString(failure))
     self.report['failure'] = failureToString(failure)
     self.report['success'] = False
Beispiel #14
0
 def errback(failure):
     self.report['failure'] = failureToString(failure)
     d1.errback(failure)
Beispiel #15
0
 def control_err(failure):
     failure_string = failureToString(failure)
     log.err("Failed to perform control lookup: %s" % failure_string)
     self.report['control_failure'] = failure_string
Beispiel #16
0
 def addFailureToReport(failure):
     log.debug("Failed: %s" % failureToString(failure))
     self.report['failure'] = failureToString(failure)
     self.report['success'] = False
Beispiel #17
0
 def http_experiment_err(failure):
     failure_string = failureToString(failure)
     log.err("Failed to perform HTTP request %s" % failure_string)
     self.report["http_experiment_failure"] = failure_string
Beispiel #18
0
 def eb(failure):
     result["status"]["success"] = False
     result["status"]["failure"] = failureToString(failure)
     self.report["tcp_connect"].append(result)
Beispiel #19
0
 def eb(failure):
     result['status']['success'] = False
     result['status']['failure'] = failureToString(failure)
     self.report['tcp_connect'].append(result)
     return failure
 def eb(failure):
     result['status']['success'] = False
     result['status']['failure'] = failureToString(failure)
     self.report['tcp_connect'].append(result)
Beispiel #21
0
 def dns_experiment_err(failure):
     self.report["dns_experiment_failure"] = failureToString(failure)
     return []
Beispiel #22
0
 def dns_experiment_err(failure):
     self.report['dns_experiment_failure'] = failureToString(failure)
     return []
Beispiel #23
0
 def control_err(failure):
     failure_string = failureToString(failure)
     log.err("Failed to perform control lookup: %s" % failure_string)
     self.report["control_failure"] = failure_string
Beispiel #24
0
 def http_experiment_err(failure):
     failure_string = failureToString(failure)
     log.msg("Failed to perform HTTP request %s" % failure_string)
     self.report['http_experiment_failure'] = failure_string