[or-cvs] [tor/master 1/4] Make "Nowhere" explicitly listable in torrc.

nickm at torproject.org nickm at torproject.org
Mon Aug 2 15:08:13 UTC 2010


Author: Nick Mathewson <nickm at torproject.org>
Date: Tue, 15 Sep 2009 13:41:36 -0400
Subject: Make "Nowhere" explicitly listable in torrc.
Commit: 8fca6fb2aa569cf4f09b6b4aaa887f3b434d759e

We already had the country code ?? indicating an unknown country, so all we
needed to do to make unknown countries excludable was to make the ?? code
discoverable.
---
 changes/nowhereland |    6 ++++++
 src/or/geoip.c      |    1 +
 src/or/routerlist.c |    4 ++++
 3 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 changes/nowhereland

diff --git a/changes/nowhereland b/changes/nowhereland
new file mode 100644
index 0000000..5435e96
--- /dev/null
+++ b/changes/nowhereland
@@ -0,0 +1,6 @@
+  o Minor features:
+    - Add support for the country code "{??}" in torrc options like
+      ExcludeNodes, to indicate all routers of unknown country.  Fixes bug
+      1094.
+
+
diff --git a/src/or/geoip.c b/src/or/geoip.c
index eae9275..6bb76ae 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -200,6 +200,7 @@ geoip_load_file(const char *filename, or_options_t *options)
             sizeof(geoip_unresolved->countrycode));
     smartlist_add(geoip_countries, geoip_unresolved);
     country_idxplus1_by_lc_code = strmap_new();
+    strmap_set_lc(country_idxplus1_by_lc_code, "??", (void*)(1));
   }
   if (geoip_entries) {
     SMARTLIST_FOREACH(geoip_entries, geoip_entry_t *, e, tor_free(e));
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5f98abe..7be98bd 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -5335,6 +5335,10 @@ routerset_contains(const routerset_t *set, const tor_addr_t *addr,
     if (country < 0 && addr)
       country = geoip_get_country_by_ip(tor_addr_to_ipv4h(addr));
 
+    /* XXXX can we safely move this into geoip_get_country_by_ip? */
+    if (country < 0)
+      country = 0;
+
     if (country >= 0 && country < set->n_countries &&
         bitarray_is_set(set->countries, country))
       return 2;
-- 
1.7.1




More information about the tor-commits mailing list