summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kike.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kike.c b/kike.c
index 9ec2e63..68e71c0 100644
--- a/kike.c
+++ b/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);
}