Bladeren bron

Make "Nowhere" explicitly listable in torrc.

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.
Nick Mathewson 16 jaren geleden
bovenliggende
commit
8fca6fb2aa
3 gewijzigde bestanden met toevoegingen van 11 en 0 verwijderingen
  1. 6 0
      changes/nowhereland
  2. 1 0
      src/or/geoip.c
  3. 4 0
      src/or/routerlist.c

+ 6 - 0
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.
+
+

+ 1 - 0
src/or/geoip.c

@@ -200,6 +200,7 @@ geoip_load_file(const char *filename, or_options_t *options)
             sizeof(geoip_unresolved->countrycode));
             sizeof(geoip_unresolved->countrycode));
     smartlist_add(geoip_countries, geoip_unresolved);
     smartlist_add(geoip_countries, geoip_unresolved);
     country_idxplus1_by_lc_code = strmap_new();
     country_idxplus1_by_lc_code = strmap_new();
+    strmap_set_lc(country_idxplus1_by_lc_code, "??", (void*)(1));
   }
   }
   if (geoip_entries) {
   if (geoip_entries) {
     SMARTLIST_FOREACH(geoip_entries, geoip_entry_t *, e, tor_free(e));
     SMARTLIST_FOREACH(geoip_entries, geoip_entry_t *, e, tor_free(e));

+ 4 - 0
src/or/routerlist.c

@@ -5335,6 +5335,10 @@ routerset_contains(const routerset_t *set, const tor_addr_t *addr,
     if (country < 0 && addr)
     if (country < 0 && addr)
       country = geoip_get_country_by_ip(tor_addr_to_ipv4h(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 &&
     if (country >= 0 && country < set->n_countries &&
         bitarray_is_set(set->countries, country))
         bitarray_is_set(set->countries, country))
       return 2;
       return 2;