server: 0.0.0.0 -> :: promotion is Linux specific

This commit is contained in:
Michael Davidsaver
2021-12-12 13:58:58 -08:00
parent 8fb7956ca1
commit 89fd1bba7a
3 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -386,11 +386,14 @@ ServIface::ServIface(const SockAddr &addr, server::Server::Pvt *server, bool fal
server->acceptor_loop.assertInLoop();
auto orig_port = bind_addr.port();
#ifdef __linux__
if(server->canIPv6 && bind_addr.family()==AF_INET && bind_addr.isAny()) {
// promote to IPv6 with IPv4 support
// Linux IP stack disallows binding both 0.0.0.0 and [::] for the same port.
// so promote to IPv6 when possible
bind_addr = SockAddr::any(AF_INET6, bind_addr.port());
log_debug_printf(connsetup, "Promote 0.0.0.0 -> [::]%s", "\n");
}
#endif
sock = evsocket(bind_addr.family(), SOCK_STREAM, 0);