summaryrefslogtreecommitdiff
path: root/src/or/geoip.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-07-09 15:34:53 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2009-07-09 15:34:53 +0200
commitfa2374a16360cb3d9bfb18827c574c8f44345925 (patch)
tree30d5e149e2fe41b18e301ed40998f34530bf354e /src/or/geoip.c
parent041a7b989630c846fa087628145920198da001f6 (diff)
downloadtor-fa2374a16360cb3d9bfb18827c574c8f44345925.tar.gz
tor-fa2374a16360cb3d9bfb18827c574c8f44345925.zip
List unresolved requests in geoip stats as country '??'.
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r--src/or/geoip.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 13a6a28500..13b9b7d0f0 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -188,7 +188,14 @@ geoip_load_file(const char *filename, or_options_t *options)
return -1;
}
if (!geoip_countries) {
+ geoip_country_t *geoip_unresolved;
geoip_countries = smartlist_create();
+ /* Add a geoip_country_t for requests that could not be resolved to a
+ * country as first element (index 0) to geoip_countries. */
+ geoip_unresolved = tor_malloc_zero(sizeof(geoip_country_t));
+ strlcpy(geoip_unresolved->countrycode, "??",
+ sizeof(geoip_unresolved->countrycode));
+ smartlist_add(geoip_countries, geoip_unresolved);
country_idxplus1_by_lc_code = strmap_new();
}
if (geoip_entries) {
@@ -375,6 +382,8 @@ geoip_note_client_seen(geoip_client_action_t action,
if (action == GEOIP_CLIENT_NETWORKSTATUS ||
action == GEOIP_CLIENT_NETWORKSTATUS_V2) {
int country_idx = geoip_get_country_by_ip(addr);
+ if (country_idx < 0)
+ country_idx = 0; /** unresolved requests are stored at index 0. */
if (country_idx >= 0 && country_idx < smartlist_len(geoip_countries)) {
geoip_country_t *country = smartlist_get(geoip_countries, country_idx);
if (action == GEOIP_CLIENT_NETWORKSTATUS)
@@ -505,7 +514,7 @@ geoip_get_client_history(time_t now, geoip_client_action_t action)
continue;
country = geoip_get_country_by_ip((*ent)->ipaddr);
if (country < 0)
- continue;
+ country = 0; /** unresolved requests are stored at index 0. */
tor_assert(0 <= country && country < n_countries);
++counts[country];
++total;