Browse Source

Don't use IPv4 addresses when the user has enabled IPv6 address in the settings.

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
bf0ed595c7
  1. 6
      src/qtlibtorrent/qbtsession.cpp
  2. 8
      src/smtp.cpp

6
src/qtlibtorrent/qbtsession.cpp

@ -1925,16 +1925,18 @@ void QBtSession::setListeningPort(int port) {
QString ip; QString ip;
qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size()); qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size());
foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) { foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
if (!listen_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv6Protocol)) if ((!listen_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv6Protocol))
|| (listen_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv4Protocol)))
continue; continue;
qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name)); qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name));
s->listen_on(ports, ec, entry.ip().toString().toLatin1().constData(), session::listen_no_system_port); s->listen_on(ports, ec, entry.ip().toString().toLatin1().constData(), session::listen_no_system_port);
if (!ec) { if (!ec) {
ip = entry.ip().toString(); ip = entry.ip().toString();
addConsoleMessage(tr("qBittorrent is trying to listen on interface %1 port: %2", "e.g: qBittorrent is trying to listen on interface 192.168.0.1 port: TCP/6881").arg(ip).arg(QString::number(port)), "blue"); addConsoleMessage(tr("qBittorrent is trying to listen on interface %1 port: %2", "e.g: qBittorrent is trying to listen on interface 192.168.0.1 port: TCP/6881").arg(ip).arg(QString::number(port)), "blue");
break; return;
} }
} }
addConsoleMessage(tr("qBittorrent didn't find an %1 local address to listen on", "qBittorrent didn't find an IPv4 local address to listen on").arg(listen_ipv6 ? "IPv6" : "IPv4"), "red");
} }
// Set download rate limit // Set download rate limit

8
src/smtp.cpp

@ -81,13 +81,14 @@ QByteArray determineLocalAddress()
{ {
const Preferences* const pref = Preferences::instance(); const Preferences* const pref = Preferences::instance();
const QString iface_name = pref->getNetworkInterface(); const QString iface_name = pref->getNetworkInterface();
const bool listen_ipv6 = pref->getListenIPv6(); const bool use_ipv6 = pref->getListenIPv6();
QByteArray address = "127.0.0.1"; QByteArray address = "127.0.0.1";
if (iface_name.isEmpty()) { if (iface_name.isEmpty()) {
foreach (const QHostAddress& addr, QNetworkInterface::allAddresses()) { foreach (const QHostAddress& addr, QNetworkInterface::allAddresses()) {
if (addr == QHostAddress::LocalHost || addr == QHostAddress::LocalHostIPv6 if (addr == QHostAddress::LocalHost || addr == QHostAddress::LocalHostIPv6
|| (!listen_ipv6 && (addr.protocol() == QAbstractSocket::IPv6Protocol))) || (!use_ipv6 && (addr.protocol() == QAbstractSocket::IPv6Protocol))
|| (use_ipv6 && (addr.protocol() == QAbstractSocket::IPv4Protocol)))
continue; continue;
address = addr.toString().toLatin1(); address = addr.toString().toLatin1();
break; break;
@ -100,7 +101,8 @@ QByteArray determineLocalAddress()
foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) { foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
if (entry.ip() == QHostAddress::LocalHost || entry.ip() == QHostAddress::LocalHostIPv6 if (entry.ip() == QHostAddress::LocalHost || entry.ip() == QHostAddress::LocalHostIPv6
|| (!listen_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv6Protocol))) || (!use_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv6Protocol))
|| (use_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv4Protocol)))
continue; continue;
address = entry.ip().toString().toLatin1(); address = entry.ip().toString().toLatin1();

Loading…
Cancel
Save