瀏覽代碼

Several geoip changes/fixes as requested.

svn:r14780
Nick Mathewson 16 年之前
父節點
當前提交
bd3b86df3b
共有 6 個文件被更改,包括 31 次插入13 次删除
  1. 2 0
      ChangeLog
  2. 10 7
      doc/TODO
  3. 2 0
      doc/spec/proposals/117-ipv6-exits.txt
  4. 1 1
      src/or/directory.c
  5. 8 4
      src/or/geoip.c
  6. 8 1
      src/or/router.c

+ 2 - 0
ChangeLog

@@ -100,6 +100,8 @@ Changes in version 0.2.1.1-alpha - 2008-??-??
       before too long.
     - Add a "PURPOSE=" argument to "STREAM NEW" events, as suggested by
       Robert Hogan. Fixes the first part of bug 681.
+    - Make bridge authorities never serve extrainfo docs.
+    - Allow comments in geoip file.
 
   o Minor features (security):
     - Reject requests for reverse-dns lookup of names in a private

+ 10 - 7
doc/TODO

@@ -44,7 +44,7 @@ S   - More TorBrowser work
       - Figure out (or give up on) how to run Tor Browser and ordinary
         Firefox side-by-side.
 N   - Write a script to correctly total bandwidth-history observations
-N+P - Make sure RPMs can build correctly with geoip file
+    o Make sure RPMs can build correctly with geoip file
 N+P - Make sure other packages build correctly with geoip file
 N   - Write a paragraph or two for Paul's research project describing what
       we plan to help him research. Roger will then secretly retitle
@@ -280,16 +280,19 @@ Mike:
 =======================================================================
 
 Bugs/issues for Tor 0.2.0.x:
-N - Rip out the MIN_IPS_* stuff for geoip reporting.
-N - bridge authorities should not serve extrainfo docs.
-N - We still never call geoip_remove_old_clients(). Should we call it,
+  o Rip out the MIN_IPS_* stuff for geoip reporting.
+  o bridge authorities should not serve extrainfo docs.
+  o We still never call geoip_remove_old_clients(). Should we call it,
     with a cutoff of a day ago, each time we're about to build a
     descriptor/extrainfo pair?
-N - teach geoip_parse_entry() to skip over lines that start with #, so we
+    o Actually, let's do it every 48 hours, so we don't wind up saying
+      too much.
+  o teach geoip_parse_entry() to skip over lines that start with #, so we
     can put a little note at the top of the geoip file to say what it is.
 N d we should have an off-by-default way for relays to dump geoip data to
-    a file in their data directory, for measurement purposes.  it should be
-    listed along with their probability-of-selection
+    a file in their data directory, for measurement purposes.
+    - Basic implementation
+    - Include probability-of-selection
 R d let bridges set relaybandwidthrate as low as 5kb
 R - bug: if we launch using bridges, and then stop using bridges, we
     still have our bridges in our entryguards section, and may use them.

+ 2 - 0
doc/spec/proposals/117-ipv6-exits.txt

@@ -86,6 +86,8 @@ Contents
    (RELAY_RESOLVE) should perform and respond with both A and AAAA
    resources.
 
+   [NOTE: In a future version, it may make sense to .]
+
 1.4. Client interaction with IPv6 exit capability
 
 1.4.1. Usability goals

+ 1 - 1
src/or/directory.c

@@ -2598,7 +2598,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
   }
 
   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;

+ 8 - 4
src/or/geoip.c

@@ -76,6 +76,10 @@ geoip_parse_entry(const char *line)
     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 @@ geoip_remove_old_clients(time_t cutoff)
 }
 
 /** 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 up to the nearest
  * multiple of this value. */
 #define IP_GRANULARITY 8

+ 8 - 1
src/or/router.c

@@ -1823,7 +1823,14 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
     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());