diff options
author | David Goulet <dgoulet@torproject.org> | 2020-07-14 11:03:24 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-20 14:54:13 -0400 |
commit | 9f61a6bdc3ba7d6ef623d9fce8486058c5cefdcd (patch) | |
tree | 49db4e1f6b30b7cbee0e13b7508e36902642d260 /src/feature/client | |
parent | b239f178a22eb4c5b36e9e1490f237ac42f42449 (diff) | |
download | tor-9f61a6bdc3ba7d6ef623d9fce8486058c5cefdcd.tar.gz tor-9f61a6bdc3ba7d6ef623d9fce8486058c5cefdcd.zip |
pt: Use new address discovery interface when creating extrainfo
In case the transport has no usable address configured (likely 0.0.0.0 or
[::]), attempt to find the IPv4 and on failure, fallback to the IPv6. If none
are found, a log error is emitted and the transport is skiped.
Related to #40025
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/client')
-rw-r--r-- | src/feature/client/transports.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c index 2bdc0ae151..ecc952e2ac 100644 --- a/src/feature/client/transports.c +++ b/src/feature/client/transports.c @@ -1643,17 +1643,25 @@ pt_get_extra_info_descriptor_string(void) SMARTLIST_FOREACH_BEGIN(mp->transports, const transport_t *, t) { char *transport_args = NULL; + const char *addrport = NULL; /* If the transport proxy returned "0.0.0.0" as its address, and * we know our external IP address, use it. Otherwise, use the * returned address. */ - const char *addrport = NULL; - uint32_t external_ip_address = 0; - if (tor_addr_is_null(&t->addr) && - router_pick_published_address(get_options(), - &external_ip_address, 0) >= 0) { + if (tor_addr_is_null(&t->addr)) { tor_addr_t addr; - tor_addr_from_ipv4h(&addr, external_ip_address); + /* Attempt to find the IPv4 and then attempt to find the IPv6 if we + * can't find it. */ + bool found = relay_find_addr_to_publish(get_options(), AF_INET, 0, + &addr); + if (!found) { + found = relay_find_addr_to_publish(get_options(), AF_INET6, 0, + &addr); + } + if (!found) { + log_err(LD_PT, "Unable to find address for transport %s", t->name); + continue; + } addrport = fmt_addrport(&addr, t->port); } else { addrport = fmt_addrport(&t->addr, t->port); |