Relays and bridges are not counting directory requests coming in via IPv6
While testing my #8786 (moved) branch I found that relays and bridges are currently not counting directory requests coming in via IPv6 at all. The reason is the if
in the following code snippet from directory_handle_command_get()
:
struct in_addr in;
tor_addr_t addr;
if (tor_inet_aton((TO_CONN(conn))->address, &in)) {
tor_addr_from_ipv4h(&addr, ntohl(in.s_addr));
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS,
&addr, NULL,
time(NULL));
tor_inet_aton
expects an IPv4 address in dotted-quad notation and returns 0 if it's given an IPv6 address.
When digging deeper into Git history, I found that I had changed that code to &TO_CONN(conn)->addr
4 years ago and then again to the code above in 4741aa4 because "Roger notes that address and addr are two different things."
I think this was a mistake and that we can fix this by just reverting 4741aa4. I'll post a branch in a minute that I tested using Chutney's "bridges+ipv6" network (together with teor's #17153 (moved) fix).
Please correct me if we should really use address
here instead of addr
. In that case we'll probably want to look if address
contains an IPv6 address string and handle that separately.