diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2018-10-20 20:15:06 +0300 |
---|---|---|
committer | rl1987 <rl1987@sdf.lonestar.org> | 2018-10-20 20:34:08 +0300 |
commit | d827902cb1107593473552974be5fcbb1fbb4abe (patch) | |
tree | 42ee1b9c484a52330d965dee11baec88a3a27ab3 /src/feature/relay/dns.c | |
parent | 1a1b088f8cab73ca258c35e83d21df900f8e2e32 (diff) | |
download | tor-d827902cb1107593473552974be5fcbb1fbb4abe.tar.gz tor-d827902cb1107593473552974be5fcbb1fbb4abe.zip |
Unit test for DNS fallback in configure_nameservers
Diffstat (limited to 'src/feature/relay/dns.c')
-rw-r--r-- | src/feature/relay/dns.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c index f056629b8d..1b4914b49a 100644 --- a/src/feature/relay/dns.c +++ b/src/feature/relay/dns.c @@ -1357,6 +1357,36 @@ evdns_err_is_transient(int err) } } +/** + * Return number of configured nameservers in <b>the_evdns_base</b>. + */ +size_t +number_of_configured_nameservers(void) +{ + return evdns_base_count_nameservers(the_evdns_base); +} + +/** + * Return address of configured nameserver in <b>the_evdns_base</b> + * at index <b>idx</b>. + */ +tor_addr_t * +configured_nameserver_address(const size_t idx) +{ + struct sockaddr_storage sa; + ev_socklen_t sa_len = sizeof(sa); + + if (evdns_base_get_nameserver_addr(the_evdns_base, (int)idx, + (struct sockaddr *)&sa, + sa_len) > 0) { + tor_addr_t *tor_addr = tor_malloc(sizeof(tor_addr_t)); + tor_addr_from_sockaddr(tor_addr, (const struct sockaddr *)&sa, NULL); + return tor_addr; + } + + return NULL; +} + /** Configure eventdns nameservers if force is true, or if the configuration * has changed since the last time we called this function, or if we failed on * our last attempt. On Unix, this reads from /etc/resolv.conf or |