Esempio n. 1
0
    def writeReportHeader(self, options):
        self.firstrun = False
        self._writeln("###########################################")
        self._writeln("# OONI Probe Report for %s test" % options['name'])
        self._writeln("# %s" % otime.prettyDateNow())
        self._writeln("###########################################")

        client_geodata = {}

        if config.privacy.includeip or \
                config.privacy.includeasn or \
                config.privacy.includecountry or \
                config.privacy.includecity:
            log.msg("Running geo IP lookup via check.torproject.org")
            client_ip = yield geodata.myIP()
            client_location = geodata.IPToLocation(client_ip)
        else:
            client_ip = "127.0.0.1"

        if config.privacy.includeip:
            client_geodata['ip'] = client_ip
        else:
            client_geodata['ip'] = "127.0.0.1"

        client_geodata['asn'] = None
        client_geodata['city'] = None
        client_geodata['countrycode'] = None

        if config.privacy.includeasn:
            client_geodata['asn'] = client_location['asn']

        if config.privacy.includecity:
            client_geodata['city'] = client_location['city']

        if config.privacy.includecountry:
            client_geodata['countrycode'] = client_location['countrycode']


        test_details = {'start_time': otime.utcTimeNow(),
                        'probe_asn': client_geodata['asn'],
                        'probe_cc': client_geodata['countrycode'],
                        'probe_ip': client_geodata['ip'],
                        'test_name': options['name'],
                        'test_version': options['version'],
                        }
        self.writeReportEntry(test_details)
Esempio n. 2
0
def getTestDetails(options):
    from ooni import __version__ as software_version

    client_geodata = {}

    if config.privacy.includeip or \
            config.privacy.includeasn or \
            config.privacy.includecountry or \
            config.privacy.includecity:
        log.msg("Running geo IP lookup via check.torproject.org")
        client_ip = yield geodata.myIP()
        client_location = geodata.IPToLocation(client_ip)
    else:
        client_ip = "127.0.0.1"

    if config.privacy.includeip:
        client_geodata['ip'] = client_ip
    else:
        client_geodata['ip'] = "127.0.0.1"

    client_geodata['asn'] = None
    client_geodata['city'] = None
    client_geodata['countrycode'] = None

    if config.privacy.includeasn:
        client_geodata['asn'] = client_location['asn']

    if config.privacy.includecity:
        client_geodata['city'] = client_location['city']

    if config.privacy.includecountry:
        client_geodata['countrycode'] = client_location['countrycode']

    test_details = {
        'start_time': otime.utcTimeNow(),
        'probe_asn': client_geodata['asn'],
        'probe_cc': client_geodata['countrycode'],
        'probe_ip': client_geodata['ip'],
        'test_name': options['name'],
        'test_version': options['version'],
        'software_name': 'ooniprobe',
        'software_version': software_version
    }
    defer.returnValue(test_details)
Esempio n. 3
0
def getTestDetails(options):
    from ooni import __version__ as software_version

    client_geodata = {}

    if config.privacy.includeip or \
            config.privacy.includeasn or \
            config.privacy.includecountry or \
            config.privacy.includecity:
        log.msg("Running geo IP lookup via check.torproject.org")
        client_ip = yield geodata.myIP()
        client_location = geodata.IPToLocation(client_ip)
    else:
        client_ip = "127.0.0.1"

    if config.privacy.includeip:
        client_geodata['ip'] = client_ip
    else:
        client_geodata['ip'] = "127.0.0.1"

    client_geodata['asn'] = None
    client_geodata['city'] = None
    client_geodata['countrycode'] = None

    if config.privacy.includeasn:
        client_geodata['asn'] = client_location['asn']

    if config.privacy.includecity:
        client_geodata['city'] = client_location['city']

    if config.privacy.includecountry:
        client_geodata['countrycode'] = client_location['countrycode']

    test_details = {'start_time': otime.utcTimeNow(),
                    'probe_asn': client_geodata['asn'],
                    'probe_cc': client_geodata['countrycode'],
                    'probe_ip': client_geodata['ip'],
                    'test_name': options['name'],
                    'test_version': options['version'],
                    'software_name': 'ooniprobe',
                    'software_version': software_version
                    }
    defer.returnValue(test_details)
Esempio n. 4
0
    def writeHeader(self):
        self.firstrun = False
        (klass, options) = self.options
        self._writeln("###########################################")
        self._writeln("# OONI Probe Report for %s test" % klass.name)
        self._writeln("# %s" % date.pretty_date())
        self._writeln("###########################################")

        client_geodata = {}
        log.msg("Running geo IP lookup via check.torproject.org")

        client_ip = yield geodata.myIP()
        try:
            import txtorcon
            client_location = txtorcon.util.NetLocation(client_ip)
        except:
            log.err("txtorcon is not installed. Geolocation lookup is not"\
                    "supported")

        client_geodata['ip'] = client_ip
        client_geodata['asn'] = client_location.asn
        client_geodata['city'] = client_location.city
        client_geodata['countrycode'] = client_location.countrycode

        test_details = {'startTime': repr(date.now()),
                        'probeASN': client_geodata['asn'],
                        'probeCC': client_geodata['countrycode'],
                        'probeIP': client_geodata['ip'],
                        'probeLocation': {'city': client_geodata['city'],
                                          'countrycode':
                                          client_geodata['countrycode']},
                        'testName': klass.name,
                        'testVersion': klass.version,
                        }
        self.writeYamlLine(test_details)
        self._writeln('')