diff --git a/src/config.cpp b/src/config.cpp index fa36478..3ed5337 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -489,13 +489,40 @@ void Config::expand() auto& ifmap = IfaceMap::instance(); - for(auto& ep : ifaces) { - if(!ep.addr.isMCast()) {} - else if(!ep.iface.empty()) { + for(size_t i=0; i [::]%s", "\n"); + + } else if(evsocket::ipstack!=evsocket::Linsock) { + /* Other IP stacks allow binding different sockets. + * OSX has the added oddity of ordering dependence. + * 0.0.0.0 and the :: is allowed, but not the reverse. + * + * So when possible, we always bind both in the allowed order. + */ + ep.addr = SockAddr::any(AF_INET, ep.addr.port()); + ifaces.emplace(ifaces.begin()+i+1u, + SockAddr::any(AF_INET6, ep.addr.port())); + i++; // continue after newly inserted EP + } + + } else if(!ep.addr.isMCast()) { + // no-op + + } else if(!ep.iface.empty()) { ifaces.emplace_back(ifmap.address_of(ep.iface)); } else { ifaces.emplace_back(SockAddr::any(ep.addr.family())); } + // ep invalidated by emplace() } if(auto_beacon) { diff --git a/src/serverconn.cpp b/src/serverconn.cpp index 1de3180..ec5aa62 100644 --- a/src/serverconn.cpp +++ b/src/serverconn.cpp @@ -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))