mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 23:47:23 -06:00
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:
@@ -17,7 +17,7 @@ enum AdvSettingsRows {DISK_CACHE,
|
||||
#if LIBTORRENT_VERSION_NUM >= 1610
|
||||
DISK_CACHE_TTL,
|
||||
#endif
|
||||
OS_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
|
||||
OS_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_LISTEN_IPV6, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
|
||||
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
||||
UPDATE_CHECK,
|
||||
#endif
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port;
|
||||
QCheckBox cb_os_cache, cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
|
||||
cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion,
|
||||
cb_enable_tracker_ext;
|
||||
cb_enable_tracker_ext, cb_listen_ipv6;
|
||||
QComboBox combo_iface;
|
||||
#if LIBTORRENT_VERSION_NUM >= 1610
|
||||
QSpinBox spin_cache_ttl;
|
||||
@@ -106,6 +106,8 @@ public slots:
|
||||
pref.setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString());
|
||||
pref.setNetworkInterfaceName(combo_iface.currentText());
|
||||
}
|
||||
// Listen on IPv6 address
|
||||
pref.setListenIPv6(cb_listen_ipv6.isChecked());
|
||||
// Network address
|
||||
QHostAddress addr(txt_network_address.text().trimmed());
|
||||
if (addr.isNull())
|
||||
@@ -259,6 +261,9 @@ private slots:
|
||||
combo_iface.setCurrentIndex(i);
|
||||
}
|
||||
setRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface);
|
||||
// Listen on IPv6 address
|
||||
cb_listen_ipv6.setChecked(pref.getListenIPv6());
|
||||
setRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6);
|
||||
// Network address
|
||||
txt_network_address.setText(pref.getNetworkAddress());
|
||||
setRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
|
||||
|
||||
@@ -1131,6 +1131,14 @@ public:
|
||||
return value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString();
|
||||
}
|
||||
|
||||
bool getListenIPv6() const {
|
||||
return value("Preferences/Connection/InterfaceListenIPv6", false).toBool();
|
||||
}
|
||||
|
||||
void setListenIPv6(bool enable) {
|
||||
setValue("Preferences/Connection/InterfaceListenIPv6", enable);
|
||||
}
|
||||
|
||||
void setNetworkInterfaceName(const QString& iface) {
|
||||
setValue(QString::fromUtf8("Preferences/Connection/InterfaceName"), iface);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user