server: OS specific handling of 0.0.0.0 and ::

This commit is contained in:
Michael Davidsaver
2021-12-12 18:50:09 -08:00
parent e809da219d
commit a9aad63292
2 changed files with 30 additions and 12 deletions
-9
View File
@@ -386,15 +386,6 @@ ServIface::ServIface(const SockAddr &addr, server::Server::Pvt *server, bool fal
server->acceptor_loop.assertInLoop();
auto orig_port = bind_addr.port();
#ifdef __linux__
if(evsocket::canIPv6 && bind_addr.family()==AF_INET && bind_addr.isAny()) {
// 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);
if(evutil_make_listen_socket_reuseable(sock.sock))