From d6d55e159b1f1590945d6ac9e2ff53de0f9e55b3 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Fri, 31 Aug 2012 11:42:29 -0700 Subject: [PATCH] and my cached-consensus exit geography parser --- .gitmodules | 3 +++ pygeoip | 1 + server-ca/sni_challenge/exit-geography.py | 26 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 160000 pygeoip create mode 100644 server-ca/sni_challenge/exit-geography.py diff --git a/.gitmodules b/.gitmodules index b26143331..0d65cfdaa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "m3crypto"] path = m3crypto url = git@github.com:research/m3crypto.git +[submodule "pygeoip"] + path = pygeoip + url = https://github.com/appliedsec/pygeoip.git diff --git a/pygeoip b/pygeoip new file mode 160000 index 000000000..2bd928e6b --- /dev/null +++ b/pygeoip @@ -0,0 +1 @@ +Subproject commit 2bd928e6b3af32bfd40091cfcdbba2903eadb418 diff --git a/server-ca/sni_challenge/exit-geography.py b/server-ca/sni_challenge/exit-geography.py new file mode 100644 index 000000000..4209a08c1 --- /dev/null +++ b/server-ca/sni_challenge/exit-geography.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +import pygeoip +geoip = pygeoip.GeoIP('GeoIP.dat', pygeoip.MEMORY_CACHE) + +allrouters = [] +exits = [] + +for L in open("/var/lib/tor/cached-consensus"): + if L.startswith("s "): + flags = L.strip().split() + if "Exit" in flags and "BadExit" not in flags and "Running" in flags and "Valid" in flags and "Stable" in flags: + exits.append((router[1], router[6], flags)) + if L.startswith("r "): + router = L.strip().split() + allrouters.append(router[1]) + +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)