mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
BIT-1827: fix error on initializing DNS w/ IPv6 nameserver.
This just skips over IPv6 nameserver addresses for now and uses the first IPv4 one in the resolver config. Should be possible to support IPv6, but that may need more testing (e.g. need to make sure the code will be portable to various platforms).
This commit is contained in:
parent
105cdb5aaf
commit
26dc94c31d
3 changed files with 38 additions and 19 deletions
6
CHANGES
6
CHANGES
|
@ -1,4 +1,10 @@
|
|||
|
||||
2.5-345 | 2017-11-20 11:28:59 -0600
|
||||
|
||||
* BIT-1827: fix error on initializing DNS w/ IPv6 nameserver. (Corelight)
|
||||
|
||||
* Add --build-type flag to configure wrapper. (Corelight)
|
||||
|
||||
2.5-343 | 2017-11-17 15:27:04 -0800
|
||||
|
||||
* Fix ASCII logging of very large values of type "double".
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.5-343
|
||||
2.5-345
|
||||
|
|
25
src/nb_dns.c
25
src/nb_dns.c
|
@ -131,19 +131,28 @@ nb_dns_init(char *errstr)
|
|||
free(nd);
|
||||
return (NULL);
|
||||
}
|
||||
nd->s = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (nd->s < 0) {
|
||||
|
||||
for ( int i = 0; i < _res.nscount; ++i )
|
||||
{
|
||||
nd->server = _res.nsaddr_list[i];
|
||||
|
||||
/* XXX support IPv6 */
|
||||
if ( nd->server.sin_family != AF_INET )
|
||||
continue;
|
||||
|
||||
nd->s = socket(nd->server.sin_family, SOCK_DGRAM, 0);
|
||||
|
||||
if ( nd->s < 0 )
|
||||
{
|
||||
snprintf(errstr, NB_DNS_ERRSIZE, "socket(): %s",
|
||||
my_strerror(errno));
|
||||
free(nd);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* XXX should use resolver config */
|
||||
nd->server = _res.nsaddr_list[0];
|
||||
|
||||
if ( connect(nd->s, (struct sockaddr *)&nd->server,
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
sizeof(struct sockaddr)) < 0 )
|
||||
{
|
||||
snprintf(errstr, NB_DNS_ERRSIZE, "connect(%s): %s",
|
||||
inet_ntoa(nd->server.sin_addr), my_strerror(errno));
|
||||
close(nd->s);
|
||||
|
@ -154,6 +163,10 @@ nb_dns_init(char *errstr)
|
|||
return (nd);
|
||||
}
|
||||
|
||||
snprintf(errstr, NB_DNS_ERRSIZE, "no valid nameservers in resolver config");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nb_dns_finish(struct nb_dns_info *nd)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue