From 01896064452ca59cebe3809984bc526b899243f2 Mon Sep 17 00:00:00 2001 From: treysis Date: Sun, 7 Mar 2021 16:15:36 +0100 Subject: [PATCH] Fix bad IPv6 address format for outgoingInterfaces Fixes https://github.com/qbittorrent/qBittorrent/issues/12892#issuecomment-792292336 --- src/base/bittorrent/session.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 683daa5f1..3f43bac91 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1444,12 +1444,14 @@ void Session::configureNetworkInterfaces(lt::settings_pack &settingsPack) const QHostAddress addr {ip}; if (!addr.isNull()) { - const QString ip = ((addr.protocol() == QAbstractSocket::IPv6Protocol) - ? ('[' + Utils::Net::canonicalIPv6Addr(addr).toString() + ']') - : addr.toString()); - endpoints << (ip + portString); + const bool isIPv6 = (addr.protocol() == QAbstractSocket::IPv6Protocol); + const QString ip = isIPv6 + ? Utils::Net::canonicalIPv6Addr(addr).toString() + : addr.toString(); + + endpoints << ((isIPv6 ? ('[' + ip + ']') : ip) + portString); - if ((ip != "0.0.0.0") && (ip != "[::]")) + if ((ip != QLatin1String("0.0.0.0")) && (ip != QLatin1String("::"))) outgoingInterfaces << ip; } else