diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 2f464635f..450f088dd 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -284,6 +284,7 @@ Session::Session(QObject *parent) , m_isUTPEnabled(BITTORRENT_SESSION_KEY("uTPEnabled"), true) , m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true) , m_utpMixedMode(BITTORRENT_SESSION_KEY("uTPMixedMode"), m_isUTPEnabled) + , m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY("MultiConnectionsPerIp"), false) , m_isAddTrackersEnabled(BITTORRENT_SESSION_KEY("AddTrackersEnabled"), false) , m_additionalTrackers(BITTORRENT_SESSION_KEY("AdditionalTrackers")) , m_globalMaxRatio(BITTORRENT_SESSION_KEY("GlobalMaxRatio"), -1, [](qreal r) { return r < 0 ? -1. : r;}) @@ -1310,6 +1311,8 @@ void Session::configure(libtorrent::settings_pack &settingsPack) break; } + settingsPack.set_bool(libt::settings_pack::allow_multiple_connections_per_ip, multiConnectionsPerIpEnabled()); + settingsPack.set_bool(libt::settings_pack::apply_ip_filter_to_trackers, isTrackerFilteringEnabled()); settingsPack.set_bool(libt::settings_pack::enable_dht, isDHTEnabled()); @@ -1538,6 +1541,8 @@ void Session::configure(libtorrent::session_settings &sessionSettings) break; } + sessionSettings.allow_multiple_connections_per_ip = multiConnectionsPerIpEnabled(); + sessionSettings.apply_ip_filter_to_trackers = isTrackerFilteringEnabled(); if (isDHTEnabled()) { @@ -3116,6 +3121,19 @@ void Session::setUtpMixedMode(int mode) configureDeferred(); } +bool Session::multiConnectionsPerIpEnabled() const +{ + return m_multiConnectionsPerIpEnabled; +} + +void Session::setMultiConnectionsPerIpEnabled(bool enabled) +{ + if (enabled == m_multiConnectionsPerIpEnabled) return; + + m_multiConnectionsPerIpEnabled = enabled; + configureDeferred(); +} + bool Session::isTrackerFilteringEnabled() const { return m_isTrackerFilteringEnabled; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index b3454a2ee..2c3b4033d 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -375,6 +375,8 @@ namespace BitTorrent void setUTPRateLimited(bool limited); int utpMixedMode() const; void setUtpMixedMode(int mode); + bool multiConnectionsPerIpEnabled() const; + void setMultiConnectionsPerIpEnabled(bool enabled); bool isTrackerFilteringEnabled() const; void setTrackerFilteringEnabled(bool enabled); QStringList bannedIPs() const; @@ -600,6 +602,7 @@ namespace BitTorrent CachedSettingValue m_isUTPEnabled; CachedSettingValue m_isUTPRateLimited; CachedSettingValue m_utpMixedMode; + CachedSettingValue m_multiConnectionsPerIpEnabled; CachedSettingValue m_isAddTrackersEnabled; CachedSettingValue m_additionalTrackers; CachedSettingValue m_globalMaxRatio; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 590c6fe08..f97e5c0cd 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -84,6 +84,7 @@ enum AdvSettingsRows OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, UTP_MIX_MODE, + MULTI_CONNECTIONS_PER_IP, // embedded tracker TRACKER_STATUS, TRACKER_PORT, @@ -138,6 +139,8 @@ void AdvancedSettings::saveAdvancedSettings() session->setOutgoingPortsMax(outgoing_ports_max.value()); // uTP-TCP mixed mode session->setUtpMixedMode(comboUtpMixedMode.currentIndex()); + // multiple connections per IP + session->setMultiConnectionsPerIpEnabled(cbMultiConnectionsPerIp.isChecked()); // Recheck torrents on completion pref->recheckTorrentsOnCompletion(cb_recheck_completed.isChecked()); // Transfer list refresh interval @@ -307,6 +310,9 @@ void AdvancedSettings::loadAdvancedSettings() comboUtpMixedMode.addItems({"Prefer TCP", "Peer proportional (throttles TCP)"}); comboUtpMixedMode.setCurrentIndex(session->utpMixedMode()); addRow(UTP_MIX_MODE, tr("uTP-TCP mixed mode algorithm"), &comboUtpMixedMode); + // multiple connections per IP + cbMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled()); + addRow(MULTI_CONNECTIONS_PER_IP, tr("Allow multiple connections from the same IP address"), &cbMultiConnectionsPerIp); // Recheck completed torrents cb_recheck_completed.setChecked(pref->recheckTorrentsOnCompletion()); addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &cb_recheck_completed); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 1b9ecd0cf..a9d4c9e3d 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -78,7 +78,7 @@ private: QSpinBox spin_cache, spin_save_resume_data_interval, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port, spin_cache_ttl; QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, cb_super_seeding, cb_program_notifications, cb_torrent_added_notifications, cb_tracker_favicon, cb_tracker_status, - cb_confirm_torrent_recheck, cb_confirm_remove_all_tags, cb_listen_ipv6, cb_announce_all_trackers, cbGuidedReadCache; + cb_confirm_torrent_recheck, cb_confirm_remove_all_tags, cb_listen_ipv6, cb_announce_all_trackers, cbGuidedReadCache, cbMultiConnectionsPerIp; QComboBox combo_iface, combo_iface_address, comboUtpMixedMode; QLineEdit txtAnnounceIP;