diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2020-10-28 23:47:35 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2020-10-29 00:39:57 +0100 |
commit | 06d3b3bd2b8144411538ed722b1a9b679baa848f (patch) | |
tree | 6674ac3295f2c7e0630a0f226e7f0a7b4931cf36 /kike.c | |
parent | 132e4a38b8cb234f4992fe3078ad056c5f523d3e (diff) | |
download | xK-06d3b3bd2b8144411538ed722b1a9b679baa848f.tar.gz xK-06d3b3bd2b8144411538ed722b1a9b679baa848f.tar.xz xK-06d3b3bd2b8144411538ed722b1a9b679baa848f.zip |
kike: ensure NULL binds to both IPv4 and IPv6
Diffstat (limited to 'kike.c')
-rw-r--r-- | kike.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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); } |