aboutsummaryrefslogtreecommitdiff
path: root/src/feature/nodelist/dirlist.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-06-23 11:19:50 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-06-24 13:51:37 -0400
commitb76325190b3fb2d01fb0c9f0d2ffe76a284d1766 (patch)
tree783d711aa801a6124bc4acecf0feca9bc82cc5c1 /src/feature/nodelist/dirlist.c
parent2f3b4e38888116f434297fb45ac093acd2d01e55 (diff)
downloadtor-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/nodelist/dirlist.c')
-rw-r--r--src/feature/nodelist/dirlist.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/feature/nodelist/dirlist.c b/src/feature/nodelist/dirlist.c
index 4481daba6f..f49d991f9b 100644
--- a/src/feature/nodelist/dirlist.c
+++ b/src/feature/nodelist/dirlist.c
@@ -343,25 +343,25 @@ trusted_dir_server_new(const char *nickname, const char *address,
const char *digest, const char *v3_auth_digest,
dirinfo_type_t type, double weight)
{
- uint32_t a;
tor_addr_t addr;
char *hostname=NULL;
dir_server_t *result;
if (!address) { /* The address is us; we should guess. */
- if (resolve_my_address_v4(LOG_WARN, get_options(),
- &a, NULL, &hostname) < 0) {
+ if (!find_my_address(get_options(), AF_INET, LOG_WARN, &addr,
+ NULL, &hostname)) {
log_warn(LD_CONFIG,
"Couldn't find a suitable address when adding ourself as a "
"trusted directory server.");
return NULL;
}
if (!hostname)
- hostname = tor_dup_ip(a);
+ hostname = tor_addr_to_str_dup(&addr);
if (!hostname)
return NULL;
} else {
+ uint32_t a;
if (tor_lookup_hostname(address, &a)) {
log_warn(LD_CONFIG,
"Unable to lookup address for directory server at '%s'",
@@ -369,8 +369,8 @@ trusted_dir_server_new(const char *nickname, const char *address,
return NULL;
}
hostname = tor_strdup(address);
+ tor_addr_from_ipv4h(&addr, a);
}
- tor_addr_from_ipv4h(&addr, a);
result = dir_server_new(1, nickname, &addr, hostname,
dir_port, or_port,