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/nodelist/routerset.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/nodelist/routerset.c')
-rw-r--r-- | src/feature/nodelist/routerset.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/feature/nodelist/routerset.c b/src/feature/nodelist/routerset.c index ebc08b7a51..cba7203d44 100644 --- a/src/feature/nodelist/routerset.c +++ b/src/feature/nodelist/routerset.c @@ -306,12 +306,19 @@ routerset_add_unknown_ccs(routerset_t **setp, int only_if_some_cc_set) int routerset_contains_extendinfo(const routerset_t *set, const extend_info_t *ei) { - return routerset_contains(set, - &ei->addr, - ei->port, - ei->nickname, - ei->identity_digest, - -1 /*country*/); + 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]; + return routerset_contains2(set, + ap1 ? &ap1->addr : NULL, + ap1 ? ap1->port : 0, + ap2 ? &ap2->addr : NULL, + ap2 ? ap2->port : 0, + ei->nickname, + ei->identity_digest, + -1 /*country*/); } /** Return true iff <b>ri</b> is in <b>set</b>. If country is <b>-1</b>, we |