kike: ensure NULL binds to both IPv4 and IPv6
This commit is contained in:
parent
132e4a38b8
commit
06d3b3bd2b
11
kike.c
11
kike.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* kike.c: the experimental IRC daemon
|
||||
*
|
||||
* Copyright (c) 2014 - 2018, Přemysl Eric Janouch <p@janouch.name>
|
||||
* Copyright (c) 2014 - 2020, Přemysl Eric Janouch <p@janouch.name>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
|
@ -3801,6 +3801,14 @@ irc_listen (struct addrinfo *gai_iter)
|
|||
soft_assert (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
&yes, sizeof yes) != -1);
|
||||
|
||||
#if defined SOL_IPV6 && defined IPV6_V6ONLY
|
||||
// Make NULL always bind to both IPv4 and IPv6, irrespectively of the order
|
||||
// of results; only INADDR6_ANY seems to be affected by this
|
||||
if (gai_iter->ai_family == AF_INET6)
|
||||
soft_assert (setsockopt (fd, SOL_IPV6, IPV6_V6ONLY,
|
||||
&yes, sizeof yes) != -1);
|
||||
#endif
|
||||
|
||||
char host[NI_MAXHOST], port[NI_MAXSERV];
|
||||
host[0] = port[0] = '\0';
|
||||
int err = getnameinfo (gai_iter->ai_addr, gai_iter->ai_addrlen,
|
||||
|
@ -3855,7 +3863,6 @@ irc_listen_resolve (struct server_context *ctx,
|
|||
|
||||
ctx->listen_fds[ctx->n_listen_fds++] = fd;
|
||||
poller_fd_set (event, POLLIN);
|
||||
break;
|
||||
}
|
||||
freeaddrinfo (gai_result);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue