mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 07:57:22 -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
|
#if LIBTORRENT_VERSION_NUM >= 1610
|
||||||
DISK_CACHE_TTL,
|
DISK_CACHE_TTL,
|
||||||
#endif
|
#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)
|
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
||||||
UPDATE_CHECK,
|
UPDATE_CHECK,
|
||||||
#endif
|
#endif
|
||||||
@@ -35,7 +35,7 @@ private:
|
|||||||
QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port;
|
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,
|
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_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;
|
QComboBox combo_iface;
|
||||||
#if LIBTORRENT_VERSION_NUM >= 1610
|
#if LIBTORRENT_VERSION_NUM >= 1610
|
||||||
QSpinBox spin_cache_ttl;
|
QSpinBox spin_cache_ttl;
|
||||||
@@ -106,6 +106,8 @@ public slots:
|
|||||||
pref.setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString());
|
pref.setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString());
|
||||||
pref.setNetworkInterfaceName(combo_iface.currentText());
|
pref.setNetworkInterfaceName(combo_iface.currentText());
|
||||||
}
|
}
|
||||||
|
// Listen on IPv6 address
|
||||||
|
pref.setListenIPv6(cb_listen_ipv6.isChecked());
|
||||||
// Network address
|
// Network address
|
||||||
QHostAddress addr(txt_network_address.text().trimmed());
|
QHostAddress addr(txt_network_address.text().trimmed());
|
||||||
if (addr.isNull())
|
if (addr.isNull())
|
||||||
@@ -259,6 +261,9 @@ private slots:
|
|||||||
combo_iface.setCurrentIndex(i);
|
combo_iface.setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
setRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface);
|
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
|
// Network address
|
||||||
txt_network_address.setText(pref.getNetworkAddress());
|
txt_network_address.setText(pref.getNetworkAddress());
|
||||||
setRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
|
setRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
|
||||||
|
|||||||
@@ -1130,7 +1130,15 @@ public:
|
|||||||
QString getNetworkInterface() const {
|
QString getNetworkInterface() const {
|
||||||
return value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString();
|
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) {
|
void setNetworkInterfaceName(const QString& iface) {
|
||||||
setValue(QString::fromUtf8("Preferences/Connection/InterfaceName"), iface);
|
setValue(QString::fromUtf8("Preferences/Connection/InterfaceName"), iface);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1983,13 +1983,25 @@ void QBtSession::setListeningPort(int port) {
|
|||||||
libtorrent::error_code ec;
|
libtorrent::error_code ec;
|
||||||
#endif
|
#endif
|
||||||
const QString iface_name = pref.getNetworkInterface();
|
const QString iface_name = pref.getNetworkInterface();
|
||||||
|
const bool listen_ipv6 = pref.getListenIPv6();
|
||||||
if (iface_name.isEmpty()) {
|
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");
|
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
|
#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
|
#else
|
||||||
s->listen_on(ports);
|
s->listen_on(ports, "::");
|
||||||
#endif
|
#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;
|
return;
|
||||||
}
|
}
|
||||||
// Attempt to listen on provided interface
|
// Attempt to listen on provided interface
|
||||||
@@ -2002,6 +2014,8 @@ 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))
|
||||||
|
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));
|
||||||
#if LIBTORRENT_VERSION_NUM >= 1600
|
#if LIBTORRENT_VERSION_NUM >= 1600
|
||||||
s->listen_on(ports, ec, entry.ip().toString().toAscii().constData(), session::listen_no_system_port);
|
s->listen_on(ports, ec, entry.ip().toString().toAscii().constData(), session::listen_no_system_port);
|
||||||
|
|||||||
Reference in New Issue
Block a user