addr: Use false/true with relay_find_addr_to_publish()

Previous development introduced the error of using 0/1 for a boolean
parameter. Fix that everywhere

Related #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet
2020-07-16 09:26:58 -04:00
parent a37a027e61
commit 0b89eba7d5
3 changed files with 12 additions and 10 deletions
+2 -2
View File
@@ -1652,10 +1652,10 @@ pt_get_extra_info_descriptor_string(void)
tor_addr_t addr;
/* 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,
bool found = relay_find_addr_to_publish(get_options(), AF_INET, false,
&addr);
if (!found) {
found = relay_find_addr_to_publish(get_options(), AF_INET6, 0,
found = relay_find_addr_to_publish(get_options(), AF_INET6, false,
&addr);
}
if (!found) {
+4 -2
View File
@@ -2040,8 +2040,10 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out))
/* Find our resolved address both IPv4 and IPv6. In case the address is not
* found, the object is set to an UNSPEC address. */
bool have_v4 = relay_find_addr_to_publish(options, AF_INET, 0, &ipv4_addr);
bool have_v6 = relay_find_addr_to_publish(options, AF_INET6, 0, &ipv6_addr);
bool have_v4 = relay_find_addr_to_publish(options, AF_INET, false,
&ipv4_addr);
bool have_v6 = relay_find_addr_to_publish(options, AF_INET6, false,
&ipv6_addr);
/* Tor requires a relay to have an IPv4 so bail if we can't find it. */
if (!have_v4) {
+6 -6
View File
@@ -316,11 +316,11 @@ test_find_addr_to_publish(void *arg)
tt_assert(tor_addr_eq(&ipv6_addr, &cache_addr));
/* 1. Address located in the resolved cache. */
ret = relay_find_addr_to_publish(&options, AF_INET, 1, &cache_addr);
ret = relay_find_addr_to_publish(&options, AF_INET, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv4_addr, &cache_addr));
ret = relay_find_addr_to_publish(&options, AF_INET6, 1, &cache_addr);
ret = relay_find_addr_to_publish(&options, AF_INET6, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv6_addr, &cache_addr));
resolved_addr_reset_last(AF_INET);
@@ -330,21 +330,21 @@ test_find_addr_to_publish(void *arg)
* the find_my_address() code path because that is extensively tested in
* another unit tests. */
resolved_addr_set_suggested(&ipv4_addr);
ret = relay_find_addr_to_publish(&options, AF_INET, 1, &cache_addr);
ret = relay_find_addr_to_publish(&options, AF_INET, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv4_addr, &cache_addr));
resolved_addr_set_suggested(&ipv6_addr);
ret = relay_find_addr_to_publish(&options, AF_INET6, 1, &cache_addr);
ret = relay_find_addr_to_publish(&options, AF_INET6, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv6_addr, &cache_addr));
resolve_addr_reset_suggested(AF_INET);
resolve_addr_reset_suggested(AF_INET6);
/* 3. No IP anywhere. */
ret = relay_find_addr_to_publish(&options, AF_INET, 1, &cache_addr);
ret = relay_find_addr_to_publish(&options, AF_INET, true, &cache_addr);
tt_assert(!ret);
ret = relay_find_addr_to_publish(&options, AF_INET6, 1, &cache_addr);
ret = relay_find_addr_to_publish(&options, AF_INET6, true, &cache_addr);
tt_assert(!ret);
done: