[or-cvs] r14782: Backport: Several geoip changes/fixes as requested. (in tor/branches/tor-0_2_0-patches: . src/or)

nickm at seul.org nickm at seul.org
Wed May 28 18:35:40 UTC 2008


Author: nickm
Date: 2008-05-28 14:35:39 -0400 (Wed, 28 May 2008)
New Revision: 14782

Modified:
   tor/branches/tor-0_2_0-patches/ChangeLog
   tor/branches/tor-0_2_0-patches/src/or/directory.c
   tor/branches/tor-0_2_0-patches/src/or/geoip.c
   tor/branches/tor-0_2_0-patches/src/or/router.c
Log:
Backport: Several geoip changes/fixes as requested.

Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog	2008-05-28 18:34:10 UTC (rev 14781)
+++ tor/branches/tor-0_2_0-patches/ChangeLog	2008-05-28 18:35:39 UTC (rev 14782)
@@ -13,6 +13,10 @@
       fails do not leave it unattached and ask the controller to deal.  Fixes
       the second part of bug 681.
 
+  o Minor features:
+    - Allow comments in geoip file.
+    - Make bridge authorities never serve extrainfo docs.
+
   o New files:
     - A new contrib/tor-exit-notice.html file that exit relay operators
       can put on their website to help reduce abuse queries.

Modified: tor/branches/tor-0_2_0-patches/src/or/directory.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/directory.c	2008-05-28 18:34:10 UTC (rev 14781)
+++ tor/branches/tor-0_2_0-patches/src/or/directory.c	2008-05-28 18:35:39 UTC (rev 14782)
@@ -2461,7 +2461,7 @@
   }
 
   if (!strcmpstart(url,"/tor/server/") ||
-      !strcmpstart(url,"/tor/extra/")) {
+      (!options->BridgeAuthoritativeDir && !strcmpstart(url,"/tor/extra/"))) {
     int res;
     const char *msg;
     const char *request_type = NULL;

Modified: tor/branches/tor-0_2_0-patches/src/or/geoip.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/geoip.c	2008-05-28 18:34:10 UTC (rev 14781)
+++ tor/branches/tor-0_2_0-patches/src/or/geoip.c	2008-05-28 18:35:39 UTC (rev 14782)
@@ -76,6 +76,10 @@
     geoip_entries = smartlist_create();
     country_idxplus1_by_lc_code = strmap_new();
   }
+  while (TOR_ISSPACE(*line))
+    ++line;
+  if (*line == '#')
+    return 0;
   if (sscanf(line,"%u,%u,%2s", &low, &high, b) == 3) {
     geoip_add_entry(low, high, b);
     return 0;
@@ -277,12 +281,12 @@
 }
 
 /** Do not mention any country from which fewer than this number of IPs have
- * connected.  This avoids reporting information that could deanonymize
- * users. */
-#define MIN_IPS_TO_NOTE_COUNTRY 8
+ * connected.  This conceivably avoids reporting information that could
+ * deanonymize users, though analysis is lacking. */
+#define MIN_IPS_TO_NOTE_COUNTRY 0
 /** Do not report any geoip data at all if we have fewer than this number of
  * IPs to report about. */
-#define MIN_IPS_TO_NOTE_ANYTHING 16
+#define MIN_IPS_TO_NOTE_ANYTHING 0
 /** When reporting geoip data about countries, round down to the nearest
  * multiple of this value. */
 #define IP_GRANULARITY 8
@@ -344,8 +348,10 @@
       ++total;
     }
     /* Don't record anything if we haven't seen enough IPs. */
+#if MIN_IPS_TO_NOTE_ANYTHING > 0
     if (total < MIN_IPS_TO_NOTE_ANYTHING)
       goto done;
+#endif
     /* Make a list of c_hist_t */
     entries = smartlist_create();
     for (i = 0; i < n_countries; ++i) {
@@ -353,7 +359,11 @@
       const char *countrycode;
       c_hist_t *ent;
       /* Only report a country if it has a minimum number of IPs. */
+#if MIN_IPS_TO_NOTE_COUNTRY > 0
       if (c >= MIN_IPS_TO_NOTE_COUNTRY) {
+#else
+      if (1) {
+#endif
         /* Round up to the next multiple of IP_GRANULARITY */
         c += IP_GRANULARITY-1;
         c -= c % IP_GRANULARITY;
@@ -375,7 +385,9 @@
         smartlist_add(chunks, tor_strdup(buf));
       });
     result = smartlist_join_strings(chunks, ",", 0, NULL);
+#if MIN_IPS_TO_NOTE_ANYTHING > 0
   done:
+#endif
     tor_free(counts);
     if (chunks) {
       SMARTLIST_FOREACH(chunks, char *, c, tor_free(c));

Modified: tor/branches/tor-0_2_0-patches/src/or/router.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/router.c	2008-05-28 18:34:10 UTC (rev 14781)
+++ tor/branches/tor-0_2_0-patches/src/or/router.c	2008-05-28 18:35:39 UTC (rev 14782)
@@ -1822,7 +1822,14 @@
     return -1;
 
   if (options->BridgeRelay && options->BridgeRecordUsageByCountry) {
-    char *geoip_summary = geoip_get_client_history(time(NULL));
+    static time_t last_purged_at = 0;
+    char *geoip_summary;
+    time_t now = time(NULL);
+    if (now > last_purged_at+48*60*60) {
+      geoip_remove_old_clients(now-48*60*60);
+      last_purged_at = now;
+    }
+    geoip_summary = geoip_get_client_history(time(NULL));
     if (geoip_summary) {
       char geoip_start[ISO_TIME_LEN+1];
       format_iso_time(geoip_start, geoip_get_history_start());



More information about the tor-commits mailing list