diff options
author | teor <teor@torproject.org> | 2020-04-30 06:47:46 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2020-04-30 06:54:42 +1000 |
commit | 15a4180a7e041531d6923a41684e9e6ffc833760 (patch) | |
tree | 3868606983450a146dd001f5dbc5b8d5b0f9d80e /src/feature/relay | |
parent | 066d2deb3d322e960600d80739739199d8c4cfa6 (diff) | |
download | tor-15a4180a7e041531d6923a41684e9e6ffc833760.tar.gz tor-15a4180a7e041531d6923a41684e9e6ffc833760.zip |
relay: Refactor can extend over IPv6 checks
Split "can extend over IPv6" and "has advertised IPv6 ORPort" into
separate functions. They currently have the same result, but this may
change in 33818 with ExtendAllowIPv6Addresses.
Part of 33817.
Diffstat (limited to 'src/feature/relay')
-rw-r--r-- | src/feature/relay/circuitbuild_relay.c | 2 | ||||
-rw-r--r-- | src/feature/relay/router.c | 13 | ||||
-rw-r--r-- | src/feature/relay/router.h | 4 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/feature/relay/circuitbuild_relay.c b/src/feature/relay/circuitbuild_relay.c index 75b2767b82..b89866b477 100644 --- a/src/feature/relay/circuitbuild_relay.c +++ b/src/feature/relay/circuitbuild_relay.c @@ -251,7 +251,7 @@ STATIC const tor_addr_port_t * circuit_choose_ip_ap_for_extend(const tor_addr_port_t *ipv4_ap, const tor_addr_port_t *ipv6_ap) { - const bool ipv6_supported = router_has_advertised_ipv6_orport(get_options()); + const bool ipv6_supported = router_can_extend_over_ipv6(get_options()); /* If IPv6 is not supported, we can't use the IPv6 address. */ if (!ipv6_supported) { diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index b0a56012db..2858371af5 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -1491,14 +1491,23 @@ router_get_advertised_ipv6_or_ap(const or_options_t *options, } /** Returns true if this router has an advertised IPv6 ORPort. */ -MOCK_IMPL(bool, -router_has_advertised_ipv6_orport,(const or_options_t *options)) +bool +router_has_advertised_ipv6_orport(const or_options_t *options) { tor_addr_port_t ipv6_ap; router_get_advertised_ipv6_or_ap(options, &ipv6_ap); return tor_addr_port_is_valid_ap(&ipv6_ap, 0); } +/** Returns true if this router has an advertised IPv6 ORPort. */ +MOCK_IMPL(bool, +router_can_extend_over_ipv6,(const or_options_t *options)) +{ + /* We might add some extra checks here, such as ExtendAllowIPv6Addresses + * from ticket 33818. */ + return router_has_advertised_ipv6_orport(options); +} + /** Return the port that we should advertise as our DirPort; * this is one of three possibilities: * The one that is passed as <b>dirport</b> if the DirPort option is 0, or diff --git a/src/feature/relay/router.h b/src/feature/relay/router.h index 1a262a6799..39c550dd25 100644 --- a/src/feature/relay/router.h +++ b/src/feature/relay/router.h @@ -68,8 +68,8 @@ uint16_t router_get_active_listener_port_by_type_af(int listener_type, uint16_t router_get_advertised_or_port(const or_options_t *options); void router_get_advertised_ipv6_or_ap(const or_options_t *options, tor_addr_port_t *ipv6_ap_out); -MOCK_DECL(bool, router_has_advertised_ipv6_orport,( - const or_options_t *options)); +bool router_has_advertised_ipv6_orport(const or_options_t *options); +MOCK_DECL(bool, router_can_extend_over_ipv6,(const or_options_t *options)); uint16_t router_get_advertised_or_port_by_af(const or_options_t *options, sa_family_t family); uint16_t router_get_advertised_dir_port(const or_options_t *options, |