Patch: Adding country codes to *Nodes config options

Robert Hogan robert at
Mon Sep 22 21:48:40 UTC 2008

On Monday 22 September 2008 21:02:41 Nick Mathewson wrote:
> {Please take pity on us old-school purists and wrap email to under 75
> colums, so that it doesn't overflow our terminals when we reply}


> > - Every time Tor parses a new router it checks to see if the
> > router's country is specified in any *Nodes option. If so, it adds
> > the router to the option's
> > routerset. (router_parse_entry_from_string is the only place where a
> > router's routerinfo_t is created/updated right?)
> Hm.  This is a pretty big shift in how the code handles nodes in the
> include/exclude lists.  Previously, there hasn't been any cacheing of
> whether a router is excluded, and from what roles: this info was
> recalculated lots.
> Now, whenever the {Excluded}(Entry/Exit)Nodes list changes, or we get
> a new routerinfo, or whenever we change GeoIPFile or reparse the
> GeoIPFile, we need to recalculate this information, and we need to
> make sure we haven't messed it up.  It looks like we look at the list
> of country codes when we're adding routers, but we look at the set of
> digests when we're excluding routers.  To me, this seems like a bug
> waiting to happen.

Ah OK, so (this includes some of your later points too):

- there should be a routerset->countries bitmap
- it should get set with any valid countries specified in *Nodes
- routerset_get_all_routers returns any routers with a country in 
- routerset_contains should use the same logic for individual routers
- oh and the geoip-to-country call should take place in a helper of the 
above 2 functions rather than storing it in routerinfo_t. (this will cover 
re-parsing the geoip file)

I'll try it out tomorrow so let me know if I've misapprehended anything.

Everything else I'm pretty sure I got first time! ;-)

More information about the tor-dev mailing list