diff options
author | Roger Dingledine <arma@torproject.org> | 2008-06-04 08:54:57 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2008-06-04 08:54:57 +0000 |
commit | 4b34404ac1bdffecc40c049ae5b2426c1d0ad23b (patch) | |
tree | 42ef8b5b63921589309848eb4723ee2904f22e22 | |
parent | 51300f9a902682aa7472335d9269859015183ac3 (diff) | |
download | tor-4b34404ac1bdffecc40c049ae5b2426c1d0ad23b.tar.gz tor-4b34404ac1bdffecc40c049ae5b2426c1d0ad23b.zip |
Only warn when we fail to load the geoip file if we were planning to
include geoip stats in our extrainfo document.
svn:r14934
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/or/config.c | 2 | ||||
-rw-r--r-- | src/or/geoip.c | 15 | ||||
-rw-r--r-- | src/or/or.h | 3 | ||||
-rw-r--r-- | src/or/router.c | 2 |
5 files changed, 18 insertions, 6 deletions
@@ -2,6 +2,8 @@ Changes in version 0.2.0.28-rc - 2008-06-?? o Minor fixes: - Bridge relays no longer print "xx=0" in their extrainfo document for every single country code in the geoip db. + - Only warn when we fail to load the geoip file if we were planning to + include geoip stats in our extrainfo document. - Fix unit tests in 0.2.0.27-rc. - Fix compile on Windows. diff --git a/src/or/config.c b/src/or/config.c index 90ebebd799..5e807faa64 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1272,7 +1272,7 @@ options_act(or_options_t *old_options) tor_snprintf(actual_fname, len, "%s\\geoip", conf_root); } #endif - geoip_load_file(actual_fname); + geoip_load_file(actual_fname, options); tor_free(actual_fname); } /* Check if we need to parse and add the EntryNodes config option. */ diff --git a/src/or/geoip.c b/src/or/geoip.c index 7d4e883bef..4f3a772cbf 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -122,6 +122,14 @@ _geoip_compare_key_to_entry(const void *_key, const void **_member) return 0; } +/** Return 1 if we should collect geoip stats on bridge users, and + * include them in our extrainfo descriptor. Else return 0. */ +int +should_record_bridge_info(or_options_t *options) +{ + return options->BridgeRelay && options->BridgeRecordUsageByCountry; +} + /** Clear the GeoIP database and reload it from the file * <b>filename</b>. Return 0 on success, -1 on failure. * @@ -133,12 +141,13 @@ _geoip_compare_key_to_entry(const void *_key, const void **_member) * integers, and CC is a country code. */ int -geoip_load_file(const char *filename) +geoip_load_file(const char *filename, or_options_t *options) { FILE *f; + int severity = should_record_bridge_info(options) ? LOG_WARN : LOG_INFO; clear_geoip_db(); if (!(f = fopen(filename, "r"))) { - log_warn(LD_GENERAL, "Failed to open GEOIP file %s.", filename); + log_fn(severity, LD_GENERAL, "Failed to open GEOIP file %s.", filename); return -1; } geoip_countries = smartlist_create(); @@ -239,7 +248,7 @@ geoip_note_client_seen(uint32_t addr, time_t now) { or_options_t *options = get_options(); clientmap_entry_t lookup, *ent; - if (!(options->BridgeRelay && options->BridgeRecordUsageByCountry)) + if (!should_record_bridge_info(options)) return; lookup.ipaddr = addr; ent = HT_FIND(clientmap, &client_history, &lookup); diff --git a/src/or/or.h b/src/or/or.h index 329260a476..cab39ecc43 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3268,7 +3268,8 @@ int dnsserv_launch_request(const char *name, int is_reverse); #ifdef GEOIP_PRIVATE int geoip_parse_entry(const char *line); #endif -int geoip_load_file(const char *filename); +int should_record_bridge_info(or_options_t *options); +int geoip_load_file(const char *filename, or_options_t *options); int geoip_get_country_by_ip(uint32_t ipaddr); int geoip_get_n_countries(void); const char *geoip_get_country_name(int num); diff --git a/src/or/router.c b/src/or/router.c index 5917727343..e74822924c 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1821,7 +1821,7 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo, if (result<0) return -1; - if (options->BridgeRelay && options->BridgeRecordUsageByCountry) { + if (should_record_bridge_info(options)) { static time_t last_purged_at = 0; char *geoip_summary; time_t now = time(NULL); |