Don't listen on IPv6 address by default. Prevents network connectivity problems. Closes #1880.

Conflicts:
	src/preferences/advancedsettings.h
	src/preferences/preferences.cpp
	src/preferences/preferences.h
	src/qtlibtorrent/qbtsession.cpp
This commit is contained in:
sledgehammer999
2014-08-23 16:10:37 +03:00
parent 9d05d864e2
commit da81d3351d
3 changed files with 32 additions and 5 deletions

View File

@@ -1983,13 +1983,25 @@ void QBtSession::setListeningPort(int port) {
libtorrent::error_code ec;
#endif
const QString iface_name = pref.getNetworkInterface();
const bool listen_ipv6 = pref.getListenIPv6();
if (iface_name.isEmpty()) {
addConsoleMessage(tr("qBittorrent is trying to listen on any interface port: TCP/%1", "e.g: qBittorrent is trying to listen on any interface port: TCP/6881").arg(QString::number(port)), "blue");
if (listen_ipv6)
#if LIBTORRENT_VERSION_NUM >= 1600
s->listen_on(ports, ec, 0, session::listen_no_system_port);
s->listen_on(ports, ec, "::", session::listen_no_system_port);
#else
s->listen_on(ports);
s->listen_on(ports, "::");
#endif
else
#if LIBTORRENT_VERSION_NUM >= 1600
s->listen_on(ports, ec, "0.0.0.0", session::listen_no_system_port);
#else
s->listen_on(ports, "0.0.0.0");
#endif
if (ec)
addConsoleMessage(tr("qBittorrent failed to listen on any interface port: %1. Reason: %2", "e.g: qBittorrent failed to listen on any interface port: TCP/6881. Reason: no such interface" ).arg(QString::number(port)).arg(misc::toQStringU(ec.message())), "red");
return;
}
// Attempt to listen on provided interface
@@ -2002,6 +2014,8 @@ void QBtSession::setListeningPort(int port) {
QString ip;
qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size());
foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
if (!listen_ipv6 && (entry.ip().protocol() == QAbstractSocket::IPv6Protocol))
continue;
qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name));
#if LIBTORRENT_VERSION_NUM >= 1600
s->listen_on(ports, ec, entry.ip().toString().toAscii().constData(), session::listen_no_system_port);