diff options
author | teor <teor@torproject.org> | 2020-01-08 17:34:37 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2020-03-21 03:43:48 +1000 |
commit | bac8bc0ff11d5b4502f2e71138d23f71fc25e72a (patch) | |
tree | c9fef463f73ab238bd84d72c0384d2a12d3de4a9 | |
parent | 861337fd6d286329537e07f667602992b82e921f (diff) | |
download | tor-bac8bc0ff11d5b4502f2e71138d23f71fc25e72a.tar.gz tor-bac8bc0ff11d5b4502f2e71138d23f71fc25e72a.zip |
router: Refactor IPv6 ORPort function logic
Return early when there is no suitable IPv6 ORPort.
Show the address and port on error, using a convenience function.
Code simplification and refactoring.
Cleanup after 32588.
-rw-r--r-- | src/feature/relay/router.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 760daa249e..283f7c326b 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -1460,20 +1460,21 @@ router_get_advertised_ipv6_or_ap(const or_options_t *options, return; } - /* Like IPv4, if the relay is configured using the default - * authorities, disallow internal IPs. Otherwise, allow them. */ + /* If the relay is configured using the default authorities, disallow + * internal IPs. Otherwise, allow them. For IPv4 ORPorts and DirPorts, + * this check is done in resolve_my_address(). See #33681. */ const int default_auth = using_default_dir_authorities(options); - if (! tor_addr_is_internal(addr, 0) || ! default_auth) { - tor_addr_copy(&ipv6_ap_out->addr, addr); - ipv6_ap_out->port = port; - } else { - char addrbuf[TOR_ADDR_BUF_LEN]; + if (tor_addr_is_internal(addr, 0) && default_auth) { log_warn(LD_CONFIG, - "Unable to use configured IPv6 address \"%s\" in a " + "Unable to use configured IPv6 ORPort \"%s\" in a " "descriptor. Skipping it. " "Try specifying a globally reachable address explicitly.", - tor_addr_to_str(addrbuf, addr, sizeof(addrbuf), 1)); + fmt_addrport(addr, port)); + return; } + + tor_addr_copy(&ipv6_ap_out->addr, addr); + ipv6_ap_out->port = port; } /** Return the port that we should advertise as our DirPort; |