mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-23 22:47:12 +01:00
List unresolved requests in geoip stats as country '??'.
This commit is contained in:
parent
041a7b9896
commit
fa2374a163
2 changed files with 12 additions and 2 deletions
|
@ -16,7 +16,8 @@ Changes in version 0.2.2.1-alpha - 2009-??-??
|
||||||
to make sure nothing writes beyond the end of an area. This might
|
to make sure nothing writes beyond the end of an area. This might
|
||||||
help debug some conceivable causes of bug 930.
|
help debug some conceivable causes of bug 930.
|
||||||
- Directories that are configured with the --enable-geoip-stats flag
|
- Directories that are configured with the --enable-geoip-stats flag
|
||||||
now write their GeoIP stats to disk exactly every 24 hours.
|
now write their GeoIP stats to disk exactly every 24 hours. Also,
|
||||||
|
unresolved requests are listed with country code '??'.
|
||||||
- Exit nodes can write statistics on the number of exit streams and
|
- Exit nodes can write statistics on the number of exit streams and
|
||||||
transferred bytes per port to disk every 24 hours. To enable this,
|
transferred bytes per port to disk every 24 hours. To enable this,
|
||||||
run configure with the --enable-exit-stats option, and set
|
run configure with the --enable-exit-stats option, and set
|
||||||
|
|
|
@ -188,7 +188,14 @@ geoip_load_file(const char *filename, or_options_t *options)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!geoip_countries) {
|
if (!geoip_countries) {
|
||||||
|
geoip_country_t *geoip_unresolved;
|
||||||
geoip_countries = smartlist_create();
|
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();
|
country_idxplus1_by_lc_code = strmap_new();
|
||||||
}
|
}
|
||||||
if (geoip_entries) {
|
if (geoip_entries) {
|
||||||
|
@ -375,6 +382,8 @@ geoip_note_client_seen(geoip_client_action_t action,
|
||||||
if (action == GEOIP_CLIENT_NETWORKSTATUS ||
|
if (action == GEOIP_CLIENT_NETWORKSTATUS ||
|
||||||
action == GEOIP_CLIENT_NETWORKSTATUS_V2) {
|
action == GEOIP_CLIENT_NETWORKSTATUS_V2) {
|
||||||
int country_idx = geoip_get_country_by_ip(addr);
|
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)) {
|
if (country_idx >= 0 && country_idx < smartlist_len(geoip_countries)) {
|
||||||
geoip_country_t *country = smartlist_get(geoip_countries, country_idx);
|
geoip_country_t *country = smartlist_get(geoip_countries, country_idx);
|
||||||
if (action == GEOIP_CLIENT_NETWORKSTATUS)
|
if (action == GEOIP_CLIENT_NETWORKSTATUS)
|
||||||
|
@ -505,7 +514,7 @@ geoip_get_client_history(time_t now, geoip_client_action_t action)
|
||||||
continue;
|
continue;
|
||||||
country = geoip_get_country_by_ip((*ent)->ipaddr);
|
country = geoip_get_country_by_ip((*ent)->ipaddr);
|
||||||
if (country < 0)
|
if (country < 0)
|
||||||
continue;
|
country = 0; /** unresolved requests are stored at index 0. */
|
||||||
tor_assert(0 <= country && country < n_countries);
|
tor_assert(0 <= country && country < n_countries);
|
||||||
++counts[country];
|
++counts[country];
|
||||||
++total;
|
++total;
|
||||||
|
|
Loading…
Add table
Reference in a new issue