mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Don't listen on IPv6 address by default. Prevents network connectivity problems. Closes #1880.
This commit is contained in:
parent
2b061dab0a
commit
66b375de07
4 changed files with 28 additions and 3 deletions
|
@ -13,7 +13,7 @@
|
|||
#include "preferences.h"
|
||||
|
||||
enum AdvSettingsCols {PROPERTY, VALUE};
|
||||
enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, 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,
|
||||
enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, 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_OS_WIN) || defined(Q_OS_MAC)
|
||||
UPDATE_CHECK,
|
||||
#endif
|
||||
|
@ -31,7 +31,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;
|
||||
QSpinBox spin_cache_ttl;
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
|
@ -98,6 +98,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())
|
||||
|
@ -249,6 +251,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);
|
||||
|
|
|
@ -1248,6 +1248,14 @@ void Preferences::setNetworkInterfaceName(const QString& iface) {
|
|||
setValue("Preferences/Connection/InterfaceName", iface);
|
||||
}
|
||||
|
||||
bool Preferences::getListenIPv6() const {
|
||||
return value("Preferences/Connection/InterfaceListenIPv6", false).toBool();
|
||||
}
|
||||
|
||||
void Preferences::setListenIPv6(bool enable) {
|
||||
setValue("Preferences/Connection/InterfaceListenIPv6", enable);
|
||||
}
|
||||
|
||||
QString Preferences::getNetworkAddress() const {
|
||||
return value("Preferences/Connection/InetAddress").toString();
|
||||
}
|
||||
|
|
|
@ -334,6 +334,8 @@ public:
|
|||
void setNetworkInterface(const QString& iface);
|
||||
QString getNetworkInterfaceName() const;
|
||||
void setNetworkInterfaceName(const QString& iface);
|
||||
bool getListenIPv6() const;
|
||||
void setListenIPv6(bool enable);
|
||||
QString getNetworkAddress() const;
|
||||
void setNetworkAddress(const QString& addr);
|
||||
bool isAnonymousModeEnabled() const;
|
||||
|
|
|
@ -1896,9 +1896,17 @@ void QBtSession::setListeningPort(int port) {
|
|||
std::pair<int,int> ports(port, port);
|
||||
libtorrent::error_code ec;
|
||||
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: %1", "e.g: qBittorrent is trying to listen on any interface port: TCP/6881").arg(QString::number(port)), "blue");
|
||||
s->listen_on(ports, ec, 0, session::listen_no_system_port);
|
||||
if (listen_ipv6)
|
||||
s->listen_on(ports, ec, "::", session::listen_no_system_port);
|
||||
else
|
||||
s->listen_on(ports, ec, "0.0.0.0", session::listen_no_system_port);
|
||||
|
||||
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
|
||||
|
@ -1911,6 +1919,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));
|
||||
s->listen_on(ports, ec, entry.ip().toString().toLatin1().constData(), session::listen_no_system_port);
|
||||
if (!ec) {
|
||||
|
|
Loading…
Reference in a new issue