diff options
author | WGH <wgh@torlan.ru> | 2021-07-27 19:51:45 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2021-07-28 09:31:33 +0300 |
commit | 6f42b8d06fc24b6d7f8a0df382e1374684306d71 (patch) | |
tree | 2b1401ccf29966a4e71520af515a929a35db1a80 /src/murmur/Server.cpp | |
parent | 59275992c3ce345089bd58e1fc0ff271f6a11ef7 (diff) |
FIX(server): Always bind to both IPv6 and IPv4 by default
The check for configured network interfaces at startup has a problem
that if IPv4 is not configured for some reason, Mumble will bind to
IPv6-only socket, and will not be available over IPv4 until manually
restarted.
There's no harm binding to the "any" IPv6 address with IPV6_V6ONLY set
to 0 even if there're no assigned addresses of either address family.
The bind will succeed either way, and will accept connections on any
new address configured in the system regardless of the address family.
QHostAddress::Any tries to setup an AF_INET6 socket with IPV6_V6ONLY
set to 0, and falls back to AF_INET in case it's unavailable.
However, it will only happen if IPv6 is completely disabled on the
system, which is a rare configuration, but nevertheless it will fall
back gracefully.
Fixes #5208
Diffstat (limited to 'src/murmur/Server.cpp')
-rw-r--r-- | src/murmur/Server.cpp | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index c470f04e2..28f7cf1f7 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -61,44 +61,6 @@ void ExecEvent::execute() { SslServer::SslServer(QObject *p) : QTcpServer(p) { } -bool SslServer::hasDualStackSupport() { - // Create a AF_INET6 socket and try to switch off IPV6_V6ONLY. This - // should only fail if the system does not support dual-stack mode - // for this socket type. - - bool result = false; -#ifdef Q_OS_UNIX - int s = ::socket(AF_INET6, SOCK_STREAM, 0); - if (s != -1) { - const int ipv6only = 0; - if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast< const char * >(&ipv6only), sizeof(ipv6only)) - == 0) { - result = true; - } - ::close(s); - } -#else - WSADATA wsaData; - WORD wVersionRequested = MAKEWORD(2, 2); - if (WSAStartup(wVersionRequested, &wsaData) != 0) { - // Seems like we won't be doing any network stuff anyways - return false; - } - - SOCKET s = ::WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, nullptr, 0, WSA_FLAG_OVERLAPPED); - if (s != INVALID_SOCKET) { - const int ipv6only = 0; - if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast< const char * >(&ipv6only), sizeof(ipv6only)) - == 0) { - result = true; - } - closesocket(s); - } - WSACleanup(); -#endif - return result; -} - void SslServer::incomingConnection(qintptr v) { QSslSocket *s = new QSslSocket(this); s->setSocketDescriptor(v); |