diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-06-30 16:06:05 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-02 14:17:51 -0400 |
commit | e93ad428e2507f676ce97450b919c2d849633669 (patch) | |
tree | da887bc09c2386cf6bdab97464b8c78793db420e /src/feature/client/bridges.c | |
parent | cca3164f8d22492c40276ebda670836f93dab536 (diff) | |
download | tor-e93ad428e2507f676ce97450b919c2d849633669.tar.gz tor-e93ad428e2507f676ce97450b919c2d849633669.zip |
Allow multiple addresses in extend_info_t.
In practice, there will be at most one ipv4 address and ipv6 address
for now, but this code is designed to not care which address is
which until forced to do so.
This patch does not yet actually create extend_info_t objects with
multiple addresses.
Closes #34069.
Diffstat (limited to 'src/feature/client/bridges.c')
-rw-r--r-- | src/feature/client/bridges.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/feature/client/bridges.c b/src/feature/client/bridges.c index 66b04f3bc2..3a3d1bb681 100644 --- a/src/feature/client/bridges.c +++ b/src/feature/client/bridges.c @@ -259,12 +259,25 @@ addr_is_a_configured_bridge(const tor_addr_t *addr, /** If we have a bridge configured whose digest matches * <b>ei->identity_digest</b>, or a bridge with no known digest whose address * matches <b>ei->addr</b>:<b>ei->port</b>, return 1. Else return 0. - * If <b>ei->onion_key</b> is NULL, check for address/port matches only. */ + * If <b>ei->onion_key</b> is NULL, check for address/port matches only. + * + * Note that if the extend_info_t contains multiple addresses, we return true + * only if _every_ address is a bridge. + */ int extend_info_is_a_configured_bridge(const extend_info_t *ei) { const char *digest = ei->onion_key ? ei->identity_digest : NULL; - return addr_is_a_configured_bridge(&ei->addr, ei->port, digest); + const tor_addr_port_t *ap1 = NULL, *ap2 = NULL; + if (! tor_addr_is_null(&ei->orports[0].addr)) + ap1 = &ei->orports[0]; + if (! tor_addr_is_null(&ei->orports[1].addr)) + ap2 = &ei->orports[1]; + IF_BUG_ONCE(ap1 == NULL) + return 0; + return addr_is_a_configured_bridge(&ap1->addr, ap1->port, digest) && + (ap2 == NULL || + addr_is_a_configured_bridge(&ap2->addr, ap2->port, digest)); } /** Wrapper around get_configured_bridge_by_addr_port_digest() to look |