|
@ -90,8 +90,7 @@ static void natural_mask(struct apattern *pat); |
|
|
!defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV) |
|
|
!defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV) |
|
|
static int config_domain(ares_channel channel, char *str); |
|
|
static int config_domain(ares_channel channel, char *str); |
|
|
static int config_lookup(ares_channel channel, const char *str, |
|
|
static int config_lookup(ares_channel channel, const char *str, |
|
|
const char *bindch, const char *altbindch, |
|
|
const char *bindch, const char *filech); |
|
|
const char *filech); |
|
|
|
|
|
static char *try_config(char *s, const char *opt, char scc); |
|
|
static char *try_config(char *s, const char *opt, char scc); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -165,8 +164,6 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, |
|
|
channel->sock_state_cb_data = NULL; |
|
|
channel->sock_state_cb_data = NULL; |
|
|
channel->sock_create_cb = NULL; |
|
|
channel->sock_create_cb = NULL; |
|
|
channel->sock_create_cb_data = NULL; |
|
|
channel->sock_create_cb_data = NULL; |
|
|
channel->sock_config_cb = NULL; |
|
|
|
|
|
channel->sock_config_cb_data = NULL; |
|
|
|
|
|
|
|
|
|
|
|
channel->last_server = 0; |
|
|
channel->last_server = 0; |
|
|
channel->last_timeout_processed = (time_t)now.tv_sec; |
|
|
channel->last_timeout_processed = (time_t)now.tv_sec; |
|
@ -294,8 +291,6 @@ int ares_dup(ares_channel *dest, ares_channel src) |
|
|
/* Now clone the options that ares_save_options() doesn't support. */ |
|
|
/* Now clone the options that ares_save_options() doesn't support. */ |
|
|
(*dest)->sock_create_cb = src->sock_create_cb; |
|
|
(*dest)->sock_create_cb = src->sock_create_cb; |
|
|
(*dest)->sock_create_cb_data = src->sock_create_cb_data; |
|
|
(*dest)->sock_create_cb_data = src->sock_create_cb_data; |
|
|
(*dest)->sock_config_cb = src->sock_config_cb; |
|
|
|
|
|
(*dest)->sock_config_cb_data = src->sock_config_cb_data; |
|
|
|
|
|
|
|
|
|
|
|
strncpy((*dest)->local_dev_name, src->local_dev_name, |
|
|
strncpy((*dest)->local_dev_name, src->local_dev_name, |
|
|
sizeof(src->local_dev_name)); |
|
|
sizeof(src->local_dev_name)); |
|
@ -1030,6 +1025,11 @@ static int get_DNS_AdaptersAddresses(char **outptr) |
|
|
} |
|
|
} |
|
|
else if (namesrvr.sa->sa_family == AF_INET6) |
|
|
else if (namesrvr.sa->sa_family == AF_INET6) |
|
|
{ |
|
|
{ |
|
|
|
|
|
/* Windows apparently always reports some IPv6 DNS servers that
|
|
|
|
|
|
* prefixed with fec0:0:0:ffff. These ususally do not point to |
|
|
|
|
|
* working DNS servers, so we ignore them. */ |
|
|
|
|
|
if (strncmp(txtaddr, "fec0:0:0:ffff:", 14) == 0) |
|
|
|
|
|
continue; |
|
|
if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any, |
|
|
if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any, |
|
|
sizeof(namesrvr.sa6->sin6_addr)) == 0) |
|
|
sizeof(namesrvr.sa6->sin6_addr)) == 0) |
|
|
continue; |
|
|
continue; |
|
@ -1269,7 +1269,7 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
if ((p = try_config(line, "domain", ';')) && update_domains) |
|
|
if ((p = try_config(line, "domain", ';')) && update_domains) |
|
|
status = config_domain(channel, p); |
|
|
status = config_domain(channel, p); |
|
|
else if ((p = try_config(line, "lookup", ';')) && !channel->lookups) |
|
|
else if ((p = try_config(line, "lookup", ';')) && !channel->lookups) |
|
|
status = config_lookup(channel, p, "bind", NULL, "file"); |
|
|
status = config_lookup(channel, p, "bind", "file"); |
|
|
else if ((p = try_config(line, "search", ';')) && update_domains) |
|
|
else if ((p = try_config(line, "search", ';')) && update_domains) |
|
|
status = set_search(channel, p); |
|
|
status = set_search(channel, p); |
|
|
else if ((p = try_config(line, "nameserver", ';')) && |
|
|
else if ((p = try_config(line, "nameserver", ';')) && |
|
@ -1310,7 +1310,8 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
ARES_SUCCESS) |
|
|
ARES_SUCCESS) |
|
|
{ |
|
|
{ |
|
|
if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups) |
|
|
if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups) |
|
|
(void)config_lookup(channel, p, "dns", "resolve", "files"); |
|
|
/* ignore errors */ |
|
|
|
|
|
(void)config_lookup(channel, p, "dns", "files"); |
|
|
} |
|
|
} |
|
|
fclose(fp); |
|
|
fclose(fp); |
|
|
} |
|
|
} |
|
@ -1319,16 +1320,15 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
switch(error) { |
|
|
switch(error) { |
|
|
case ENOENT: |
|
|
case ENOENT: |
|
|
case ESRCH: |
|
|
case ESRCH: |
|
|
|
|
|
status = ARES_EOF; |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", |
|
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", |
|
|
error, strerror(error))); |
|
|
error, strerror(error))); |
|
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", |
|
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", |
|
|
"/etc/nsswitch.conf")); |
|
|
"/etc/nsswitch.conf")); |
|
|
|
|
|
status = ARES_EFILE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* ignore error, maybe we will get luck in next if clause */ |
|
|
|
|
|
status = ARES_EOF; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1341,7 +1341,7 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
{ |
|
|
{ |
|
|
if ((p = try_config(line, "order", '\0')) && !channel->lookups) |
|
|
if ((p = try_config(line, "order", '\0')) && !channel->lookups) |
|
|
/* ignore errors */ |
|
|
/* ignore errors */ |
|
|
(void)config_lookup(channel, p, "bind", NULL, "hosts"); |
|
|
(void)config_lookup(channel, p, "bind", "hosts"); |
|
|
} |
|
|
} |
|
|
fclose(fp); |
|
|
fclose(fp); |
|
|
} |
|
|
} |
|
@ -1350,16 +1350,15 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
switch(error) { |
|
|
switch(error) { |
|
|
case ENOENT: |
|
|
case ENOENT: |
|
|
case ESRCH: |
|
|
case ESRCH: |
|
|
|
|
|
status = ARES_EOF; |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", |
|
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", |
|
|
error, strerror(error))); |
|
|
error, strerror(error))); |
|
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", |
|
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", |
|
|
"/etc/host.conf")); |
|
|
"/etc/host.conf")); |
|
|
|
|
|
status = ARES_EFILE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* ignore error, maybe we will get luck in next if clause */ |
|
|
|
|
|
status = ARES_EOF; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1372,7 +1371,7 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
{ |
|
|
{ |
|
|
if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups) |
|
|
if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups) |
|
|
/* ignore errors */ |
|
|
/* ignore errors */ |
|
|
(void)config_lookup(channel, p, "bind", NULL, "local"); |
|
|
(void)config_lookup(channel, p, "bind", "local"); |
|
|
} |
|
|
} |
|
|
fclose(fp); |
|
|
fclose(fp); |
|
|
} |
|
|
} |
|
@ -1381,15 +1380,14 @@ static int init_by_resolv_conf(ares_channel channel) |
|
|
switch(error) { |
|
|
switch(error) { |
|
|
case ENOENT: |
|
|
case ENOENT: |
|
|
case ESRCH: |
|
|
case ESRCH: |
|
|
|
|
|
status = ARES_EOF; |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", |
|
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", |
|
|
error, strerror(error))); |
|
|
error, strerror(error))); |
|
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf")); |
|
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf")); |
|
|
|
|
|
status = ARES_EFILE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* ignore error, default value will be chosen for `channel->lookups` */ |
|
|
|
|
|
status = ARES_EOF; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1593,15 +1591,11 @@ static int config_domain(ares_channel channel, char *str) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
static int config_lookup(ares_channel channel, const char *str, |
|
|
static int config_lookup(ares_channel channel, const char *str, |
|
|
const char *bindch, const char *altbindch, |
|
|
const char *bindch, const char *filech) |
|
|
const char *filech) |
|
|
|
|
|
{ |
|
|
{ |
|
|
char lookups[3], *l; |
|
|
char lookups[3], *l; |
|
|
const char *vqualifier p; |
|
|
const char *vqualifier p; |
|
|
|
|
|
|
|
|
if (altbindch == NULL) |
|
|
|
|
|
altbindch = bindch; |
|
|
|
|
|
|
|
|
|
|
|
/* Set the lookup order. Only the first letter of each work
|
|
|
/* Set the lookup order. Only the first letter of each work
|
|
|
* is relevant, and it has to be "b" for DNS or "f" for the |
|
|
* is relevant, and it has to be "b" for DNS or "f" for the |
|
|
* host file. Ignore everything else. |
|
|
* host file. Ignore everything else. |
|
@ -1610,8 +1604,8 @@ static int config_lookup(ares_channel channel, const char *str, |
|
|
p = str; |
|
|
p = str; |
|
|
while (*p) |
|
|
while (*p) |
|
|
{ |
|
|
{ |
|
|
if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) { |
|
|
if ((*p == *bindch || *p == *filech) && l < lookups + 2) { |
|
|
if (*p == *bindch || *p == *altbindch) *l++ = 'b'; |
|
|
if (*p == *bindch) *l++ = 'b'; |
|
|
else *l++ = 'f'; |
|
|
else *l++ = 'f'; |
|
|
} |
|
|
} |
|
|
while (*p && !ISSPACE(*p) && (*p != ',')) |
|
|
while (*p && !ISSPACE(*p) && (*p != ',')) |
|
@ -2096,14 +2090,6 @@ void ares_set_socket_callback(ares_channel channel, |
|
|
channel->sock_create_cb_data = data; |
|
|
channel->sock_create_cb_data = data; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ares_set_socket_configure_callback(ares_channel channel, |
|
|
|
|
|
ares_sock_config_callback cb, |
|
|
|
|
|
void *data) |
|
|
|
|
|
{ |
|
|
|
|
|
channel->sock_config_cb = cb; |
|
|
|
|
|
channel->sock_config_cb_data = data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int ares_set_sortlist(ares_channel channel, const char *sortstr) |
|
|
int ares_set_sortlist(ares_channel channel, const char *sortstr) |
|
|
{ |
|
|
{ |
|
|
int nsort = 0; |
|
|
int nsort = 0; |
|
|