diff options
author | David Goulet <dgoulet@torproject.org> | 2020-06-23 11:19:50 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-06-24 13:51:37 -0400 |
commit | b76325190b3fb2d01fb0c9f0d2ffe76a284d1766 (patch) | |
tree | 783d711aa801a6124bc4acecf0feca9bc82cc5c1 /src/feature/relay/relay_find_addr.c | |
parent | 2f3b4e38888116f434297fb45ac093acd2d01e55 (diff) | |
download | tor-b76325190b3fb2d01fb0c9f0d2ffe76a284d1766.tar.gz tor-b76325190b3fb2d01fb0c9f0d2ffe76a284d1766.zip |
addr: Remove resolve_my_address_v4()
Replace it by find_my_address() everywhere. This changes many parts of the
code that uses it to use a tor_addr_t instead of a plain uint32_t for IPv4.
Many changes to the unit test to also use the new interface.
Part #33233
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/relay/relay_find_addr.c')
-rw-r--r-- | src/feature/relay/relay_find_addr.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/feature/relay/relay_find_addr.c b/src/feature/relay/relay_find_addr.c index 70cb77d4bf..a51457ddbb 100644 --- a/src/feature/relay/relay_find_addr.c +++ b/src/feature/relay/relay_find_addr.c @@ -45,8 +45,7 @@ void router_new_address_suggestion(const char *suggestion, const dir_connection_t *d_conn) { - tor_addr_t addr, last_resolved_addr; - uint32_t cur = 0; /* Current IPv4 address. */ + tor_addr_t addr, my_addr, last_resolved_addr; const or_options_t *options = get_options(); /* first, learn what the IP address actually is */ @@ -72,10 +71,10 @@ router_new_address_suggestion(const char *suggestion, } /* Attempt to find our address. */ - if (resolve_my_address_v4(LOG_INFO, options, &cur, NULL, NULL) >= 0) { + if (find_my_address(options, AF_INET, LOG_INFO, &my_addr, NULL, NULL)) { /* We're all set -- we already know our address. Great. */ - tor_addr_from_ipv4h(&last_guessed_ip, cur); /* store it in case we - need it later */ + tor_addr_copy(&last_guessed_ip, &my_addr); /* store it in case we + need it later */ return; } @@ -121,7 +120,7 @@ router_pick_published_address, (const or_options_t *options, uint32_t *addr, { tor_addr_t last_resolved_addr; - /* First, check the cached output from resolve_my_address_v4(). */ + /* First, check the cached output from find_my_address(). */ resolved_addr_get_last(AF_INET, &last_resolved_addr); if (!tor_addr_is_null(&last_resolved_addr)) { *addr = tor_addr_to_ipv4h(&last_resolved_addr); @@ -130,8 +129,10 @@ router_pick_published_address, (const or_options_t *options, uint32_t *addr, /* Second, consider doing a resolve attempt right here. */ if (!cache_only) { - if (resolve_my_address_v4(LOG_INFO, options, addr, NULL, NULL) >= 0) { - log_info(LD_CONFIG,"Success: chose address '%s'.", fmt_addr32(*addr)); + tor_addr_t my_addr; + if (find_my_address(options, AF_INET, LOG_INFO, &my_addr, NULL, NULL)) { + log_info(LD_CONFIG,"Success: chose address '%s'.", fmt_addr(&my_addr)); + *addr = tor_addr_to_ipv4h(&my_addr); return 0; } } |