[or-cvs] [tor/master 2/4] Move the "nowhereland" logic into geoip.c

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


Author: Nick Mathewson <nickm at torproject.org>
Date: Sat, 31 Jul 2010 15:06:55 -0400
Subject: Move the "nowhereland" logic into geoip.c
Commit: 4dd4d240b76c5c7ae47a1049e5deafc8b13d4f21

---
 src/or/geoip.c      |    9 +++++----
 src/or/routerlist.c |    4 ----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/or/geoip.c b/src/or/geoip.c
index 6bb76ae..adbad8a 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -228,9 +228,10 @@ geoip_load_file(const char *filename, or_options_t *options)
 }
 
 /** Given an IP address in host order, return a number representing the
- * country to which that address belongs, or -1 for unknown.  The return value
- * will always be less than geoip_get_n_countries().  To decode it,
- * call geoip_get_country_name().
+ * country to which that address belongs, -1 for "No geoip information
+ * available", or 0 for the 'unknown country'.  The return value will always
+ * be less than geoip_get_n_countries().  To decode it, call
+ * geoip_get_country_name().
  */
 int
 geoip_get_country_by_ip(uint32_t ipaddr)
@@ -239,7 +240,7 @@ geoip_get_country_by_ip(uint32_t ipaddr)
   if (!geoip_entries)
     return -1;
   ent = smartlist_bsearch(geoip_entries, &ipaddr, _geoip_compare_key_to_entry);
-  return ent ? (int)ent->country : -1;
+  return ent ? (int)ent->country : 0;
 }
 
 /** Return the number of countries recognized by the GeoIP database. */
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 7be98bd..5f98abe 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -5335,10 +5335,6 @@ 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