From bd3b86df3b18cbded5f69de2f4ed5f7c5e2487e3 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 28 May 2008 18:31:57 +0000 Subject: [PATCH] Several geoip changes/fixes as requested. svn:r14780 --- ChangeLog | 2 ++ doc/TODO | 17 ++++++++++------- doc/spec/proposals/117-ipv6-exits.txt | 2 ++ src/or/directory.c | 2 +- src/or/geoip.c | 12 ++++++++---- src/or/router.c | 9 ++++++++- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15cd5883d3..39d6161d93 100644 --- a/ChangeLog +++ b/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 diff --git a/doc/TODO b/doc/TODO index e6696f0a4d..085789be34 100644 --- a/doc/TODO +++ b/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. diff --git a/doc/spec/proposals/117-ipv6-exits.txt b/doc/spec/proposals/117-ipv6-exits.txt index ff4670fa58..c3bb149fd9 100644 --- a/doc/spec/proposals/117-ipv6-exits.txt +++ b/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 diff --git a/src/or/directory.c b/src/or/directory.c index 05dccb0fd6..e753df85eb 100644 --- a/src/or/directory.c +++ b/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; diff --git a/src/or/geoip.c b/src/or/geoip.c index 97ea9d7eb4..b3e993b25f 100644 --- a/src/or/geoip.c +++ b/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 diff --git a/src/or/router.c b/src/or/router.c index eb09ac4947..8f2bf65482 100644 --- a/src/or/router.c +++ b/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());