summaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-12-12 08:32:46 +0100
committerKarsten Loesing <karsten.loesing@gmx.net>2009-12-17 09:22:55 +0100
commite1e5c1b3aba96afbd6fa3b5ece262720dd45a80e (patch)
treef4d89ac71f472e1f26ad821b9bab2a4bdcd68619 /src/or/router.c
parent62c2a5a8838ac8eb97ab967e10e7a1e99d761d94 (diff)
downloadtor-e1e5c1b3aba96afbd6fa3b5ece262720dd45a80e.tar.gz
tor-e1e5c1b3aba96afbd6fa3b5ece262720dd45a80e.zip
Fix bridge statistics.
Fix statistics on client numbers by country as seen by bridges that were broken in 0.2.2.1-alpha. Also switch to reporting full 24-hour intervals instead of variable 12-to-48-hour intervals.
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c48
1 files changed, 11 insertions, 37 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 8b6d1d9bbd..7362e60f66 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1882,6 +1882,7 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
int result;
size_t len;
static int write_stats_to_extrainfo = 1;
+ time_t now = time(NULL);
base16_encode(identity, sizeof(identity),
extrainfo->cache_info.identity_digest, DIGEST_LEN);
@@ -1896,7 +1897,6 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
if (options->ExtraInfoStatistics && write_stats_to_extrainfo) {
char *contents = NULL;
- time_t now = time(NULL);
log_info(LD_GENERAL, "Adding stats to extra-info descriptor.");
if (options->DirReqStatistics &&
load_stats_file("stats"PATH_SEPARATOR"dirreq-stats",
@@ -1953,18 +1953,16 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
return -1;
if (should_record_bridge_info(options)) {
- char *geoip_summary = extrainfo_get_client_geoip_summary(time(NULL));
- if (geoip_summary) {
- char geoip_start[ISO_TIME_LEN+1];
- format_iso_time(geoip_start, geoip_get_history_start());
- result = tor_snprintf(s+strlen(s), maxlen-strlen(s),
- "geoip-start-time %s\n"
- "geoip-client-origins %s\n",
- geoip_start, geoip_summary);
- control_event_clients_seen(geoip_start, geoip_summary);
- tor_free(geoip_summary);
- if (result<0)
- return -1;
+ char *bridge_stats = geoip_get_bridge_stats_extrainfo(now);
+ if (bridge_stats) {
+ size_t pos = strlen(s);
+ if (strlcpy(s + pos, bridge_stats, maxlen - strlen(s)) !=
+ strlen(bridge_stats)) {
+ log_warn(LD_DIR, "Could not write bridge-stats to extra-info "
+ "descriptor.");
+ s[pos] = '\0';
+ }
+ tor_free(bridge_stats);
}
}
@@ -2013,30 +2011,6 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
return (int)strlen(s)+1;
}
-/** Wrapper function for geoip_get_client_history(). It first discards
- * any items in the client history that are too old -- it dumps anything
- * more than 48 hours old, but it only considers whether to dump at most
- * once per 48 hours, so we aren't too precise to an observer (see also
- * r14780).
- */
-char *
-extrainfo_get_client_geoip_summary(time_t now)
-{
- static time_t last_purged_at = 0;
- int geoip_purge_interval =
- (get_options()->DirReqStatistics || get_options()->EntryStatistics) ?
- DIR_ENTRY_RECORD_USAGE_RETAIN_IPS : 48*60*60;
- if (now > last_purged_at+geoip_purge_interval) {
- /* (Note that this also discards items in the client history with
- * action GEOIP_CLIENT_NETWORKSTATUS{_V2}, which doesn't matter
- * because bridge and directory stats are independent. Keep in mind
- * for future extensions, though.) */
- geoip_remove_old_clients(now-geoip_purge_interval);
- last_purged_at = now;
- }
- return geoip_get_client_history_bridge(now, GEOIP_CLIENT_CONNECT);
-}
-
/** Return true iff <b>s</b> is a legally valid server nickname. */
int
is_legal_nickname(const char *s)