mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Merge pull request #13257 from Sophist-UK/patch-1
Expose LibTorrent peer_turnover settings
This commit is contained in:
commit
cae5c5cea0
@ -375,6 +375,9 @@ Session::Session(QObject *parent)
|
||||
, m_isDisableAutoTMMWhenDefaultSavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/DefaultSavePathChanged"), true)
|
||||
, m_isDisableAutoTMMWhenCategorySavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/CategorySavePathChanged"), true)
|
||||
, m_isTrackerEnabled(BITTORRENT_KEY("TrackerEnabled"), false)
|
||||
, m_peerTurnover(BITTORRENT_SESSION_KEY("PeerTurnover"), 4)
|
||||
, m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY("PeerTurnoverCutOff"), 90)
|
||||
, m_peerTurnoverInterval(BITTORRENT_SESSION_KEY("PeerTurnoverInterval"), 300)
|
||||
, m_bannedIPs("State/BannedIPs"
|
||||
, QStringList()
|
||||
, [](const QStringList &value)
|
||||
@ -1208,6 +1211,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
|
||||
settingsPack.set_bool(lt::settings_pack::announce_to_all_trackers, announceToAllTrackers());
|
||||
settingsPack.set_bool(lt::settings_pack::announce_to_all_tiers, announceToAllTiers());
|
||||
|
||||
settingsPack.set_int(lt::settings_pack::peer_turnover, peerTurnover());
|
||||
settingsPack.set_int(lt::settings_pack::peer_turnover_cutoff, peerTurnoverCutoff());
|
||||
settingsPack.set_int(lt::settings_pack::peer_turnover_interval, peerTurnoverInterval());
|
||||
|
||||
settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads());
|
||||
settingsPack.set_int(lt::settings_pack::file_pool_size, filePoolSize());
|
||||
|
||||
@ -2934,6 +2941,48 @@ void Session::setAnnounceToAllTiers(const bool val)
|
||||
}
|
||||
}
|
||||
|
||||
int Session::peerTurnover() const
|
||||
{
|
||||
return m_peerTurnover;
|
||||
}
|
||||
|
||||
void Session::setPeerTurnover(const int val)
|
||||
{
|
||||
if (val == m_peerTurnover)
|
||||
return;
|
||||
|
||||
m_peerTurnover = val;
|
||||
configureDeferred();
|
||||
}
|
||||
|
||||
int Session::peerTurnoverCutoff() const
|
||||
{
|
||||
return m_peerTurnoverCutoff;
|
||||
}
|
||||
|
||||
void Session::setPeerTurnoverCutoff(const int val)
|
||||
{
|
||||
if (val == m_peerTurnoverCutoff)
|
||||
return;
|
||||
|
||||
m_peerTurnoverCutoff = val;
|
||||
configureDeferred();
|
||||
}
|
||||
|
||||
int Session::peerTurnoverInterval() const
|
||||
{
|
||||
return m_peerTurnoverInterval;
|
||||
}
|
||||
|
||||
void Session::setPeerTurnoverInterval(const int val)
|
||||
{
|
||||
if (val == m_peerTurnoverInterval)
|
||||
return;
|
||||
|
||||
m_peerTurnoverInterval = val;
|
||||
configureDeferred();
|
||||
}
|
||||
|
||||
int Session::asyncIOThreads() const
|
||||
{
|
||||
return qBound(1, m_asyncIOThreads.value(), 1024);
|
||||
|
@ -334,6 +334,12 @@ namespace BitTorrent
|
||||
void setAnnounceToAllTrackers(bool val);
|
||||
bool announceToAllTiers() const;
|
||||
void setAnnounceToAllTiers(bool val);
|
||||
int peerTurnover() const;
|
||||
void setPeerTurnover(int num);
|
||||
int peerTurnoverCutoff() const;
|
||||
void setPeerTurnoverCutoff(int num);
|
||||
int peerTurnoverInterval() const;
|
||||
void setPeerTurnoverInterval(int num);
|
||||
int asyncIOThreads() const;
|
||||
void setAsyncIOThreads(int num);
|
||||
int filePoolSize() const;
|
||||
@ -717,6 +723,9 @@ namespace BitTorrent
|
||||
CachedSettingValue<bool> m_isDisableAutoTMMWhenDefaultSavePathChanged;
|
||||
CachedSettingValue<bool> m_isDisableAutoTMMWhenCategorySavePathChanged;
|
||||
CachedSettingValue<bool> m_isTrackerEnabled;
|
||||
CachedSettingValue<int> m_peerTurnover;
|
||||
CachedSettingValue<int> m_peerTurnoverCutoff;
|
||||
CachedSettingValue<int> m_peerTurnoverInterval;
|
||||
CachedSettingValue<QStringList> m_bannedIPs;
|
||||
#if defined(Q_OS_WIN)
|
||||
CachedSettingValue<OSMemoryPriority> m_OSMemoryPriority;
|
||||
|
@ -122,6 +122,9 @@ enum AdvSettingsRows
|
||||
ANNOUNCE_ALL_TIERS,
|
||||
ANNOUNCE_IP,
|
||||
STOP_TRACKER_TIMEOUT,
|
||||
PEER_TURNOVER,
|
||||
PEER_TURNOVER_CUTOFF,
|
||||
PEER_TURNOVER_INTERVAL,
|
||||
|
||||
ROW_COUNT
|
||||
};
|
||||
@ -274,6 +277,10 @@ void AdvancedSettings::saveAdvancedSettings()
|
||||
|
||||
session->setAnnounceToAllTrackers(m_checkBoxAnnounceAllTrackers.isChecked());
|
||||
session->setAnnounceToAllTiers(m_checkBoxAnnounceAllTiers.isChecked());
|
||||
|
||||
session->setPeerTurnover(m_spinBoxPeerTurnover.value());
|
||||
session->setPeerTurnoverCutoff(m_spinBoxPeerTurnoverCutoff.value());
|
||||
session->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval.value());
|
||||
}
|
||||
|
||||
void AdvancedSettings::updateCacheSpinSuffix(int value)
|
||||
@ -609,6 +616,25 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
// Announce to all tiers
|
||||
m_checkBoxAnnounceAllTiers.setChecked(session->announceToAllTiers());
|
||||
addRow(ANNOUNCE_ALL_TIERS, tr("Always announce to all tiers"), &m_checkBoxAnnounceAllTiers);
|
||||
|
||||
m_spinBoxPeerTurnover.setMinimum(0);
|
||||
m_spinBoxPeerTurnover.setMaximum(100);
|
||||
m_spinBoxPeerTurnover.setValue(session->peerTurnover());
|
||||
m_spinBoxPeerTurnover.setSuffix(" %");
|
||||
addRow(PEER_TURNOVER, (tr("Peer turnover disconnect percentage") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#peer_turnover", "(?)"))
|
||||
, &m_spinBoxPeerTurnover);
|
||||
m_spinBoxPeerTurnoverCutoff.setMinimum(0);
|
||||
m_spinBoxPeerTurnoverCutoff.setMaximum(100);
|
||||
m_spinBoxPeerTurnoverCutoff.setSuffix(" %");
|
||||
m_spinBoxPeerTurnoverCutoff.setValue(session->peerTurnoverCutoff());
|
||||
addRow(PEER_TURNOVER_CUTOFF, (tr("Peer turnover threshold percentage") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#peer_turnover", "(?)"))
|
||||
, &m_spinBoxPeerTurnoverCutoff);
|
||||
m_spinBoxPeerTurnoverInterval.setMinimum(30);
|
||||
m_spinBoxPeerTurnoverInterval.setMaximum(3600);
|
||||
m_spinBoxPeerTurnoverInterval.setSuffix(tr(" s", " seconds"));
|
||||
m_spinBoxPeerTurnoverInterval.setValue(session->peerTurnoverInterval());
|
||||
addRow(PEER_TURNOVER_INTERVAL, (tr("Peer turnover disconnect interval") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#peer_turnover", "(?)"))
|
||||
, &m_spinBoxPeerTurnoverInterval);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -60,7 +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_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, 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,
|
||||
|
@ -322,6 +322,10 @@ void AppController::preferencesAction()
|
||||
data["announce_ip"] = session->announceIP();
|
||||
// Stop tracker timeout
|
||||
data["stop_tracker_timeout"] = session->stopTrackerTimeout();
|
||||
// Peer Turnover
|
||||
data["peer_turnover"] = session->peerTurnover();
|
||||
data["peer_turnover_cutoff"] = session->peerTurnoverCutoff();
|
||||
data["peer_turnover_interval"] = session->peerTurnoverInterval();
|
||||
|
||||
setResult(data);
|
||||
}
|
||||
@ -768,6 +772,13 @@ void AppController::setPreferencesAction()
|
||||
// Stop tracker timeout
|
||||
if (hasKey("stop_tracker_timeout"))
|
||||
session->setStopTrackerTimeout(it.value().toInt());
|
||||
// Peer Turnover
|
||||
if (hasKey("peer_turnover"))
|
||||
session->setPeerTurnover(it.value().toInt());
|
||||
if (hasKey("peer_turnover_cutoff"))
|
||||
session->setPeerTurnoverCutoff(it.value().toInt());
|
||||
if (hasKey("peer_turnover_interval"))
|
||||
session->setPeerTurnoverInterval(it.value().toInt());
|
||||
|
||||
// Save preferences
|
||||
pref->apply();
|
||||
|
@ -1161,6 +1161,30 @@
|
||||
<input type="text" id="stopTrackerTimeout" style="width: 15em;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="peerTurnover">QBT_TR(Peer turnover disconnect percentage:)QBT_TR[CONTEXT=OptionsDialog] <a href="https://www.libtorrent.org/reference-Settings.html#peer_turnover" target="_blank">(?)</a></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="peerTurnover" style="width: 15em;" /> %
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="peerTurnoverCutoff">QBT_TR(Peer turnover threshold percentage:)QBT_TR[CONTEXT=OptionsDialog] <a href="https://www.libtorrent.org/reference-Settings.html#peer_turnover" target="_blank">(?)</a></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="peerTurnoverCutoff" style="width: 15em;" /> %
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="peerTurnoverInterval">QBT_TR(Peer turnover disconnect interval:)QBT_TR[CONTEXT=OptionsDialog] <a href="https://www.libtorrent.org/reference-Settings.html#peer_turnover" target="_blank">(?)</a></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="peerTurnoverInterval" style="width: 15em;" /> s
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
@ -1857,6 +1881,9 @@
|
||||
$('announceAllTiers').setProperty('checked', pref.announce_to_all_tiers);
|
||||
$('announceIP').setProperty('value', pref.announce_ip);
|
||||
$('stopTrackerTimeout').setProperty('value', pref.stop_tracker_timeout);
|
||||
$('peerTurnover').setProperty('value', pref.peer_turnover);
|
||||
$('peerTurnoverCutoff').setProperty('value', pref.peer_turnover_cutoff);
|
||||
$('peerTurnoverInterval').setProperty('value', pref.peer_turnover_interval);
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
@ -2238,6 +2265,9 @@
|
||||
settings.set('announce_to_all_tiers', $('announceAllTiers').getProperty('checked'));
|
||||
settings.set('announce_ip', $('announceIP').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'));
|
||||
settings.set('peer_turnover_interval', $('peerTurnoverInterval').getProperty('value'));
|
||||
|
||||
// Send it to qBT
|
||||
const json_str = JSON.encode(settings);
|
||||
|
Loading…
Reference in New Issue
Block a user