diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 4553d8a1c..d631fc20a 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -353,6 +353,7 @@ Session::Session(QObject *parent) , m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), false) , m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false) , m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP")) + , m_maxConcurrentHTTPAnnounces(BITTORRENT_SESSION_KEY("MaxConcurrentHTTPAnnounces"), 50) #if (LIBTORRENT_VERSION_NUM >= 10206) , m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 5) #else @@ -1314,6 +1315,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) settingsPack.set_bool(lt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits()); // IP address to announce to trackers settingsPack.set_str(lt::settings_pack::announce_ip, announceIP().toStdString()); +#if (LIBTORRENT_VERSION_NUM >= 10207) + // Max concurrent HTTP announces + settingsPack.set_int(lt::settings_pack::max_concurrent_http_announces, maxConcurrentHTTPAnnounces()); +#endif // Stop tracker timeout settingsPack.set_int(lt::settings_pack::stop_tracker_timeout, stopTrackerTimeout()); // * Max connections limit @@ -3412,6 +3417,20 @@ void Session::setAnnounceIP(const QString &ip) } } +int Session::maxConcurrentHTTPAnnounces() const +{ + return m_maxConcurrentHTTPAnnounces; +} + +void Session::setMaxConcurrentHTTPAnnounces(const int value) +{ + if (value == m_maxConcurrentHTTPAnnounces) + return; + + m_maxConcurrentHTTPAnnounces = value; + configureDeferred(); +} + int Session::stopTrackerTimeout() const { return m_stopTrackerTimeout; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 567f1dffc..979bf30b6 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -390,6 +390,8 @@ namespace BitTorrent void setIncludeOverheadInLimits(bool include); QString announceIP() const; void setAnnounceIP(const QString &ip); + int maxConcurrentHTTPAnnounces() const; + void setMaxConcurrentHTTPAnnounces(int value); int stopTrackerTimeout() const; void setStopTrackerTimeout(int value); int maxConnections() const; @@ -674,6 +676,7 @@ namespace BitTorrent CachedSettingValue m_ignoreLimitsOnLAN; CachedSettingValue m_includeOverheadInLimits; CachedSettingValue m_announceIP; + CachedSettingValue m_maxConcurrentHTTPAnnounces; CachedSettingValue m_stopTrackerTimeout; CachedSettingValue m_maxConnections; CachedSettingValue m_maxUploads; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 5c8d05242..e67df5d29 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -121,6 +121,9 @@ enum AdvSettingsRows ANNOUNCE_ALL_TRACKERS, ANNOUNCE_ALL_TIERS, ANNOUNCE_IP, +#if (LIBTORRENT_VERSION_NUM >= 10207) + MAX_CONCURRENT_HTTP_ANNOUNCES, +#endif STOP_TRACKER_TIMEOUT, PEER_TURNOVER, PEER_TURNOVER_CUTOFF, @@ -252,6 +255,10 @@ void AdvancedSettings::saveAdvancedSettings() // Construct a QHostAddress to filter malformed strings const QHostAddress addr(m_lineEditAnnounceIP.text().trimmed()); session->setAnnounceIP(addr.toString()); +#if (LIBTORRENT_VERSION_NUM >= 10207) + // Max concurrent HTTP announces + session->setMaxConcurrentHTTPAnnounces(m_spinBoxMaxConcurrentHTTPAnnounces.value()); +#endif // Stop tracker timeout session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value()); // Program notification @@ -559,7 +566,13 @@ void AdvancedSettings::loadAdvancedSettings() // Announce IP m_lineEditAnnounceIP.setText(session->announceIP()); addRow(ANNOUNCE_IP, tr("IP Address to report to trackers (requires restart)"), &m_lineEditAnnounceIP); - // stop tracker timeout +#if (LIBTORRENT_VERSION_NUM >= 10207) + // Max concurrent HTTP announces + m_spinBoxMaxConcurrentHTTPAnnounces.setValue(session->maxConcurrentHTTPAnnounces()); + addRow(MAX_CONCURRENT_HTTP_ANNOUNCES, (tr("Max concurrent HTTP announces") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces", "(?)")) + , &m_spinBoxMaxConcurrentHTTPAnnounces); +#endif + // Stop tracker timeout m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout()); m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds")); addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", "(?)")) diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 07e41ee68..f1e184439 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -60,8 +60,8 @@ private: QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxCache, m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxCacheTTL, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark, - m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxStopTrackerTimeout, m_spinBoxSavePathHistoryLength, - m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval; + m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout, + m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval; QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts, m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers, diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index ea7edc5e2..8f3c75313 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -320,7 +320,7 @@ void AppController::preferencesAction() data["announce_to_all_trackers"] = session->announceToAllTrackers(); data["announce_to_all_tiers"] = session->announceToAllTiers(); data["announce_ip"] = session->announceIP(); - // Stop tracker timeout + data["max_concurrent_http_announces"] = session->maxConcurrentHTTPAnnounces(); data["stop_tracker_timeout"] = session->stopTrackerTimeout(); // Peer Turnover data["peer_turnover"] = session->peerTurnover(); @@ -769,7 +769,8 @@ void AppController::setPreferencesAction() const QHostAddress announceAddr {it.value().toString().trimmed()}; session->setAnnounceIP(announceAddr.isNull() ? QString {} : announceAddr.toString()); } - // Stop tracker timeout + if (hasKey("max_concurrent_http_announces")) + session->setMaxConcurrentHTTPAnnounces(it.value().toInt()); if (hasKey("stop_tracker_timeout")) session->setStopTrackerTimeout(it.value().toInt()); // Peer Turnover diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 4c7df25d8..00a46fda7 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1153,6 +1153,14 @@ + + + + + + + + @@ -1880,6 +1888,7 @@ $('announceAllTrackers').setProperty('checked', pref.announce_to_all_trackers); $('announceAllTiers').setProperty('checked', pref.announce_to_all_tiers); $('announceIP').setProperty('value', pref.announce_ip); + $('maxConcurrentHTTPAnnounces').setProperty('value', pref.max_concurrent_http_announces); $('stopTrackerTimeout').setProperty('value', pref.stop_tracker_timeout); $('peerTurnover').setProperty('value', pref.peer_turnover); $('peerTurnoverCutoff').setProperty('value', pref.peer_turnover_cutoff); @@ -2264,6 +2273,7 @@ settings.set('announce_to_all_trackers', $('announceAllTrackers').getProperty('checked')); settings.set('announce_to_all_tiers', $('announceAllTiers').getProperty('checked')); settings.set('announce_ip', $('announceIP').getProperty('value')); + settings.set('max_concurrent_http_announces', $('maxConcurrentHTTPAnnounces').getProperty('value')); settings.set('stop_tracker_timeout', $('stopTrackerTimeout').getProperty('value')); settings.set('peer_turnover', $('peerTurnover').getProperty('value')); settings.set('peer_turnover_cutoff', $('peerTurnoverCutoff').getProperty('value'));