mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Minor tweaks to nils' v4 vs v6 bridge usage code.
This commit is contained in:
parent
c03e3d66a9
commit
1f849f9181
@ -1027,9 +1027,9 @@ geoip_get_client_history(geoip_client_action_t action, int *total_ipv4, int *tot
|
||||
}
|
||||
}
|
||||
if (total_ipv4)
|
||||
(*total_ipv4) = ipv4_count;
|
||||
(*total_ipv4) = round_to_next_multiple_of(ipv4_count, granularity);
|
||||
if (total_ipv6)
|
||||
(*total_ipv6) = ipv6_count;
|
||||
(*total_ipv6) = round_to_next_multiple_of(ipv6_count, granularity);
|
||||
/* Don't record anything if we haven't seen enough IPs. */
|
||||
if (total < MIN_IPS_TO_NOTE_ANYTHING)
|
||||
goto done;
|
||||
@ -1185,9 +1185,6 @@ geoip_format_dirreq_stats(time_t now)
|
||||
*v3_direct_dl_string, *v2_direct_dl_string,
|
||||
*v3_tunneled_dl_string, *v2_tunneled_dl_string;
|
||||
char *result;
|
||||
int networkstatus_v2_ipv4, networkstatus_v2_ipv6,
|
||||
networkstatus_v3_ipv4, networkstatus_v3_ipv6;
|
||||
|
||||
|
||||
if (!start_of_dirreq_stats_interval)
|
||||
return NULL; /* Not initialized. */
|
||||
@ -1195,8 +1192,10 @@ geoip_format_dirreq_stats(time_t now)
|
||||
tor_assert(now >= start_of_dirreq_stats_interval);
|
||||
|
||||
format_iso_time(t, now);
|
||||
v2_ips_string = geoip_get_client_history(GEOIP_CLIENT_NETWORKSTATUS_V2, &networkstatus_v2_ipv4, &networkstatus_v2_ipv6);
|
||||
v3_ips_string = geoip_get_client_history(GEOIP_CLIENT_NETWORKSTATUS, &networkstatus_v3_ipv4, &networkstatus_v3_ipv6);
|
||||
v2_ips_string = geoip_get_client_history(GEOIP_CLIENT_NETWORKSTATUS_V2,
|
||||
NULL, NULL);
|
||||
v3_ips_string = geoip_get_client_history(GEOIP_CLIENT_NETWORKSTATUS,
|
||||
NULL, NULL);
|
||||
v2_reqs_string = geoip_get_request_history(
|
||||
GEOIP_CLIENT_NETWORKSTATUS_V2);
|
||||
v3_reqs_string = geoip_get_request_history(GEOIP_CLIENT_NETWORKSTATUS);
|
||||
@ -1231,8 +1230,6 @@ geoip_format_dirreq_stats(time_t now)
|
||||
tor_asprintf(&result, "dirreq-stats-end %s (%d s)\n"
|
||||
"dirreq-v3-ips %s\n"
|
||||
"dirreq-v2-ips %s\n"
|
||||
"dirreq-v3-ip-versions v4=%d,v6=%d\n"
|
||||
"dirreq-v2-ip-versions v4=%d,v6=%d\n"
|
||||
"dirreq-v3-reqs %s\n"
|
||||
"dirreq-v2-reqs %s\n"
|
||||
"dirreq-v3-resp ok=%u,not-enough-sigs=%u,unavailable=%u,"
|
||||
@ -1249,8 +1246,6 @@ geoip_format_dirreq_stats(time_t now)
|
||||
(unsigned) (now - start_of_dirreq_stats_interval),
|
||||
v3_ips_string ? v3_ips_string : "",
|
||||
v2_ips_string ? v2_ips_string : "",
|
||||
networkstatus_v3_ipv4, networkstatus_v3_ipv6,
|
||||
networkstatus_v2_ipv4, networkstatus_v2_ipv6,
|
||||
v3_reqs_string ? v3_reqs_string : "",
|
||||
v2_reqs_string ? v2_reqs_string : "",
|
||||
ns_v3_responses[GEOIP_SUCCESS],
|
||||
@ -1443,7 +1438,7 @@ format_bridge_stats_controller(time_t now)
|
||||
(void) now;
|
||||
|
||||
format_iso_time(started, start_of_bridge_stats_interval);
|
||||
data = geoip_get_client_history(GEOIP_CLIENT_CONNECT, 0, 0);
|
||||
data = geoip_get_client_history(GEOIP_CLIENT_CONNECT, NULL, NULL);
|
||||
|
||||
tor_asprintf(&out,
|
||||
"TimeStarted=\"%s\" CountrySummary=%s",
|
||||
@ -1580,10 +1575,9 @@ geoip_format_entry_stats(time_t now)
|
||||
format_iso_time(t, now);
|
||||
tor_asprintf(&result,
|
||||
"entry-stats-end %s (%u s)\n"
|
||||
"entry-ips %s\n"
|
||||
"entry-ip-versions v4=%d,v6=%d\n",
|
||||
"entry-ips %s\n",
|
||||
t, (unsigned) (now - start_of_entry_stats_interval),
|
||||
data ? data : "", total_ipv4, total_ipv6);
|
||||
data ? data : "");
|
||||
tor_free(data);
|
||||
return result;
|
||||
}
|
||||
|
@ -1392,13 +1392,11 @@ test_geoip(void)
|
||||
const char *bridge_stats_1 =
|
||||
"bridge-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"bridge-ips zz=24,xy=8\n"
|
||||
"bridge-ip-versions v4=11,v6=9\n",
|
||||
"bridge-ip-versions v4=16,v6=16\n",
|
||||
*dirreq_stats_1 =
|
||||
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"dirreq-v3-ips ab=8\n"
|
||||
"dirreq-v2-ips \n"
|
||||
"dirreq-v3-ip-versions v4=1,v6=0\n"
|
||||
"dirreq-v2-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v3-reqs ab=8\n"
|
||||
"dirreq-v2-reqs \n"
|
||||
"dirreq-v3-resp ok=0,not-enough-sigs=0,unavailable=0,not-found=0,"
|
||||
@ -1413,8 +1411,6 @@ test_geoip(void)
|
||||
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"dirreq-v3-ips \n"
|
||||
"dirreq-v2-ips \n"
|
||||
"dirreq-v3-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v2-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v3-reqs \n"
|
||||
"dirreq-v2-reqs \n"
|
||||
"dirreq-v3-resp ok=0,not-enough-sigs=0,unavailable=0,not-found=0,"
|
||||
@ -1429,8 +1425,6 @@ test_geoip(void)
|
||||
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"dirreq-v3-ips \n"
|
||||
"dirreq-v2-ips \n"
|
||||
"dirreq-v3-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v2-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v3-reqs \n"
|
||||
"dirreq-v2-reqs \n"
|
||||
"dirreq-v3-resp ok=8,not-enough-sigs=0,unavailable=0,not-found=0,"
|
||||
@ -1445,8 +1439,6 @@ test_geoip(void)
|
||||
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"dirreq-v3-ips \n"
|
||||
"dirreq-v2-ips \n"
|
||||
"dirreq-v3-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v2-ip-versions v4=0,v6=0\n"
|
||||
"dirreq-v3-reqs \n"
|
||||
"dirreq-v2-reqs \n"
|
||||
"dirreq-v3-resp ok=8,not-enough-sigs=0,unavailable=0,not-found=0,"
|
||||
@ -1459,12 +1451,10 @@ test_geoip(void)
|
||||
"dirreq-v2-tunneled-dl complete=0,timeout=0,running=0\n",
|
||||
*entry_stats_1 =
|
||||
"entry-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"entry-ips ab=8\n"
|
||||
"entry-ip-versions v4=1,v6=0\n",
|
||||
"entry-ips ab=8\n",
|
||||
*entry_stats_2 =
|
||||
"entry-stats-end 2010-08-12 13:27:30 (86400 s)\n"
|
||||
"entry-ips \n"
|
||||
"entry-ip-versions v4=0,v6=0\n";
|
||||
"entry-ips \n";
|
||||
tor_addr_t addr;
|
||||
struct in6_addr in6;
|
||||
int total_ipv4, total_ipv6;
|
||||
@ -1554,7 +1544,7 @@ test_geoip(void)
|
||||
test_assert(s);
|
||||
test_streq("zz=24,ab=16,xy=8", s);
|
||||
test_eq(total_ipv4, 16);
|
||||
test_eq(total_ipv6, 13);
|
||||
test_eq(total_ipv6, 16);
|
||||
tor_free(s);
|
||||
|
||||
/* Now clear out all the AB observations. */
|
||||
@ -1562,8 +1552,8 @@ test_geoip(void)
|
||||
s = geoip_get_client_history(GEOIP_CLIENT_CONNECT, &total_ipv4, &total_ipv6);
|
||||
test_assert(s);
|
||||
test_streq("zz=24,xy=8", s);
|
||||
test_eq(total_ipv4, 11);
|
||||
test_eq(total_ipv6, 9);
|
||||
test_eq(total_ipv4, 16);
|
||||
test_eq(total_ipv6, 16);
|
||||
|
||||
/* Start testing bridge statistics by making sure that we don't output
|
||||
* bridge stats without initializing them. */
|
||||
|
Loading…
Reference in New Issue
Block a user