summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-05-28 18:35:39 +0000
committerNick Mathewson <nickm@torproject.org>2008-05-28 18:35:39 +0000
commit1ffb56c4bd508151b564942e2fd6b1155c7379a6 (patch)
treed0372dc876d530cf5e47198c09831c582fc12698
parentb206123140dae8424aee205a0c3f531db07d29ba (diff)
downloadtor-1ffb56c4bd508151b564942e2fd6b1155c7379a6.tar.gz
tor-1ffb56c4bd508151b564942e2fd6b1155c7379a6.zip
Backport: Several geoip changes/fixes as requested.
svn:r14782
-rw-r--r--ChangeLog4
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/geoip.c20
-rw-r--r--src/or/router.c9
4 files changed, 29 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f83b98c18..9e1303809f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,10 @@ Changes in version 0.2.0.27-rc - 2008-05-??
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.
diff --git a/src/or/directory.c b/src/or/directory.c
index e7a0e0b823..6e2ccb605f 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2461,7 +2461,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 f81c18c85f..ce807a59df 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 down to the nearest
* multiple of this value. */
#define IP_GRANULARITY 8
@@ -344,8 +348,10 @@ geoip_get_client_history(time_t now)
++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 @@ geoip_get_client_history(time_t now)
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 @@ geoip_get_client_history(time_t now)
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));
diff --git a/src/or/router.c b/src/or/router.c
index 909fa3d4d5..5917727343 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1822,7 +1822,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());