1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

organize exit nodes by country

This commit is contained in:
Seth Schoen
2012-08-31 15:43:43 -07:00
parent a9f273ce0b
commit da59639b8b

View File

@@ -1,10 +1,11 @@
#!/usr/bin/env python
import pygeoip
import pygeoip, random
geoip = pygeoip.GeoIP('GeoIP.dat', pygeoip.MEMORY_CACHE)
allrouters = []
exits = []
by_country = {}
for L in open("/var/lib/tor/cached-consensus"):
if L.startswith("s "):
@@ -17,10 +18,7 @@ for L in open("/var/lib/tor/cached-consensus"):
duplicates = set(e[0] for e in exits if allrouters.count(e[0]) != 1)
print "All the good stable exits with unique names:"
print
for exit in exits:
name, ip, flags = exit
if name not in duplicates:
print name, ip, geoip.country_code_by_addr(ip)
by_country.setdefault(geoip.country_code_by_addr(ip), []).append(name)