mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
dns.c: Load IPv6 DNS resolvers if configured.
IPv6 nameserver addresses are stored in different part of the __res_state structure, so look there if we appear to have support for it. ASTERISK-28004 #close Change-Id: I67067077d8a406ee996664518d9c8fbf11f6977d
This commit is contained in:
committed by
Kevin Harwell
parent
976521c9a2
commit
695fc3dbd7
17
main/dns.c
17
main/dns.c
@@ -605,7 +605,22 @@ struct ao2_container *ast_dns_get_nameservers(void)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < state->nscount; i++) {
|
||||
ast_str_container_add(nameservers, ast_inet_ntoa(state->nsaddr_list[i].sin_addr));
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
const char *addrp = NULL;
|
||||
|
||||
/* glibc sets sin_family to 0 when the nameserver is an IPv6 address */
|
||||
if (state->nsaddr_list[i].sin_family) {
|
||||
addrp = inet_ntop(AF_INET, &state->nsaddr_list[i].sin_addr, addr, sizeof(addr));
|
||||
#if defined(HAVE_RES_NINIT) && defined(HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS)
|
||||
} else if (state->_u._ext.nsaddrs[i]) {
|
||||
addrp = inet_ntop(AF_INET6, &state->_u._ext.nsaddrs[i]->sin6_addr, addr, sizeof(addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (addrp) {
|
||||
ast_debug(1, "Discovered nameserver: %s\n", addrp);
|
||||
ast_str_container_add(nameservers, addrp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_RES_NINIT
|
||||
|
Reference in New Issue
Block a user