Several geoip changes/fixes as requested.

svn:r14780
This commit is contained in:
Nick Mathewson
2008-05-28 18:31:57 +00:00
parent dd715016dd
commit bd3b86df3b
6 changed files with 31 additions and 13 deletions
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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());