def _need_to_record(cookie, signatures, ip_addr, key):
        signature_v2 = signatures[1]['signature']

        db = Db()
        db.connect()
        if cookie:
            # okay, we have a cookie; check whether we've seen it with this
            # fingerprint before
            seen = db.count_sightings(cookie, signature_v2)
            write_cookie = cookie
        else:
            seen = 0  # always count cookieless browsers
            # we need to log the HMAC'd IP even if there's no cookie so use a
            # dummy
            write_cookie = 'no cookie'

        # now log the cookie, along with encrypted versions of the IP address
        # and a quarter-erased IP address, like the one Google keeps

        ip, google_style_ip = get_ip_hmacs(ip_addr, key)

        # We're only checking for signature_v1 to know whether we need to
        # record, but if multple whorl vesions are being calculated, we should
        # record all of them so that we can gracefully transition in the future
        for signature_dict in signatures:
            db.record_sighting(
                write_cookie, signature_dict['signature'], ip, google_style_ip)
        return seen == 0
Пример #2
0
    def record_tracking_results(cookie, results, ip_addr, key):
        db = Db()
        db.connect()

        valid_print = {}
        for i in results:
            if i in TrackingHelper.valid_fields.keys():
                valid_print[i] = results[i]

        ip, google_style_ip = get_ip_hmacs(ip_addr, key)

        db.record_tracking_results(cookie, ip, google_style_ip, results['ad'],
                                   results['tracker'], results['dnt'],
                                   results['known_blockers'])
        return True
    def record_tracking_results(cookie, results, ip_addr, key):
        db = Db()
        db.connect()

        valid_print = {}
        for i in results:
            if i in TrackingHelper.valid_fields.keys():
                valid_print[i] = results[i]

        ip, google_style_ip = get_ip_hmacs(ip_addr, key)

        db.record_tracking_results(
            cookie,
            ip,
            google_style_ip,
            results['ad'],
            results['tracker'],
            results['dnt'],
            results['known_blockers'])
        return True
    def _need_to_record(cookie, signature, ip_addr, key):
        db = Db()
        db.connect()
        if cookie:
            # okay, we have a cookie; check whether we've seen it with this
            # fingerprint before
            seen = db.count_sightings(cookie, signature)
            write_cookie = cookie
        else:
            seen = 0  # always count cookieless browsers
            # we need to log the HMAC'd IP even if there's no cookie so use a
            # dummy
            write_cookie = 'no cookie'

        # now log the cookie, along with encrypted versions of the IP address
        # and a quarter-erased IP address, like the one Google keeps

        ip, google_style_ip = get_ip_hmacs(ip_addr, key)

        db.record_sighting(write_cookie, signature, ip, google_style_ip)
        return seen == 0
    def _need_to_record(cookie, signature, ip_addr, key):
        db = Db()
        db.connect()
        if cookie:
            # okay, we have a cookie; check whether we've seen it with this
            # fingerprint before
            seen = db.count_sightings(cookie, signature)
            write_cookie = cookie
        else:
            seen = 0  # always count cookieless browsers
            # we need to log the HMAC'd IP even if there's no cookie so use a
            # dummy
            write_cookie = 'no cookie'

        # now log the cookie, along with encrypted versions of the IP address
        # and a quarter-erased IP address, like the one Google keeps

        ip, google_style_ip = get_ip_hmacs(ip_addr, key)

        db.record_sighting(
            write_cookie, signature, ip, google_style_ip)
        return seen == 0