aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-02-25 10:04:37 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-25 10:04:37 -0500
commit613b0a3bc5bef687f19771a8e52e57d7bd5edb5b (patch)
treefc4c95fca2129c5ab76fb2d76a3a665dc38260a5 /src
parent23a5921e9aebfa912f16bff541a9bdae5211ee86 (diff)
parent1d2179bc900f1646a5491b65294e78b175e70056 (diff)
downloadtor-613b0a3bc5bef687f19771a8e52e57d7bd5edb5b.tar
tor-613b0a3bc5bef687f19771a8e52e57d7bd5edb5b.tar.gz
Merge remote-tracking branch 'karsten/geoip2regcountry'
Diffstat (limited to 'src')
-rw-r--r--src/config/mmdb-convert.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/config/mmdb-convert.py b/src/config/mmdb-convert.py
index 269a5fe20..cbe9acdc5 100644
--- a/src/config/mmdb-convert.py
+++ b/src/config/mmdb-convert.py
@@ -339,11 +339,24 @@ def parse_mm_file(s):
def format_datum(datum):
"""Given a Datum at a leaf of the tree, return the string that we should
write as its value.
+
+ We first try country->iso_code which is the two-character ISO 3166-1
+ country code of the country where MaxMind believes the end user is
+ located. If there's no such key, we try registered_country->iso_code
+ which is the country in which the ISP has registered the IP address.
+ Without falling back to registered_country, we'd leave out all ranges
+ that MaxMind thinks belong to anonymous proxies, because those ranges
+ don't contain country but only registered_country. In short: let's
+ fill all A1 entries with what ARIN et. al think.
"""
try:
return bytesToStr(datum.map['country'].map['iso_code'].data)
except KeyError:
pass
+ try:
+ return bytesToStr(datum.map['registered_country'].map['iso_code'].data)
+ except KeyError:
+ pass
return None
IPV4_PREFIX = "0"*96