Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose libtorrent max_concurrent_http_announces in advanced settings #13319

Merged
merged 1 commit into from Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/base/bittorrent/session.cpp
Expand Up @@ -318,6 +318,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
Expand Down Expand Up @@ -1279,6 +1280,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
Expand Down Expand Up @@ -3377,6 +3382,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;
Expand Down
3 changes: 3 additions & 0 deletions src/base/bittorrent/session.h
Expand Up @@ -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;
Expand Down Expand Up @@ -674,6 +676,7 @@ namespace BitTorrent
CachedSettingValue<bool> m_ignoreLimitsOnLAN;
CachedSettingValue<bool> m_includeOverheadInLimits;
CachedSettingValue<QString> m_announceIP;
CachedSettingValue<int> m_maxConcurrentHTTPAnnounces;
CachedSettingValue<int> m_stopTrackerTimeout;
CachedSettingValue<int> m_maxConnections;
CachedSettingValue<int> m_maxUploads;
Expand Down
15 changes: 14 additions & 1 deletion src/gui/advancedsettings.cpp
Expand Up @@ -121,6 +121,9 @@ enum AdvSettingsRows
ANNOUNCE_ALL_TRACKERS,
ANNOUNCE_ALL_TIERS,
ANNOUNCE_IP,
#if (LIBTORRENT_VERSION_NUM >= 10207)
MAX_CONCURRENT_HTTP_ANNOUNCES,
Chocobo1 marked this conversation as resolved.
Show resolved Hide resolved
#endif
STOP_TRACKER_TIMEOUT,
PEER_TURNOVER,
PEER_TURNOVER_CUTOFF,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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", "(?)"))
Expand Down
4 changes: 2 additions & 2 deletions src/gui/advancedsettings.h
Expand Up @@ -60,8 +60,8 @@ private slots:
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,
Expand Down
5 changes: 3 additions & 2 deletions src/webui/api/appcontroller.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/webui/www/private/views/preferences.html
Expand Up @@ -1153,6 +1153,14 @@
<input type="text" id="announceIP" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="maxConcurrentHTTPAnnounces">QBT_TR(Max concurrent HTTP announces (requires libtorrent >= 1.2.7):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="maxConcurrentHTTPAnnounces" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'));
Expand Down