Merge pull request #19291 from Chocobo1/limits

Expose 'bdecode limits' settings
This commit is contained in:
Chocobo1
2023-07-11 11:24:09 +08:00
committed by GitHub
13 changed files with 152 additions and 24 deletions

View File

@@ -326,6 +326,8 @@ void AppController::preferencesAction()
data[u"current_interface_address"_s] = session->networkInterfaceAddress();
// Save resume data interval
data[u"save_resume_data_interval"_s] = session->saveResumeDataInterval();
// .torrent file size limit
data[u"torrent_file_size_limit"_s] = pref->getTorrentFileSizeLimit();
// Recheck completed torrents
data[u"recheck_completed_torrents"_s] = pref->recheckTorrentsOnCompletion();
// Refresh interval
@@ -336,6 +338,10 @@ void AppController::preferencesAction()
data[u"reannounce_when_address_changed"_s] = session->isReannounceWhenAddressChangedEnabled();
// libtorrent preferences
// Bdecode depth limit
data[u"bdecode_depth_limit"_s] = pref->getBdecodeDepthLimit();
// Bdecode token limit
data[u"bdecode_token_limit"_s] = pref->getBdecodeTokenLimit();
// Async IO threads
data[u"async_io_threads"_s] = session->asyncIOThreads();
// Hashing threads
@@ -859,6 +865,9 @@ void AppController::setPreferencesAction()
// Save resume data interval
if (hasKey(u"save_resume_data_interval"_s))
session->setSaveResumeDataInterval(it.value().toInt());
// .torrent file size limit
if (hasKey(u"torrent_file_size_limit"_s))
pref->setTorrentFileSizeLimit(it.value().toLongLong());
// Recheck completed torrents
if (hasKey(u"recheck_completed_torrents"_s))
pref->recheckTorrentsOnCompletion(it.value().toBool());
@@ -873,6 +882,12 @@ void AppController::setPreferencesAction()
session->setReannounceWhenAddressChangedEnabled(it.value().toBool());
// libtorrent preferences
// Bdecode depth limit
if (hasKey(u"bdecode_depth_limit"_s))
pref->setBdecodeDepthLimit(it.value().toInt());
// Bdecode token limit
if (hasKey(u"bdecode_token_limit"_s))
pref->setBdecodeTokenLimit(it.value().toInt());
// Async IO threads
if (hasKey(u"async_io_threads"_s))
session->setAsyncIOThreads(it.value().toInt());

View File

@@ -52,7 +52,7 @@
#include "base/utils/version.h"
#include "api/isessionmanager.h"
inline const Utils::Version<3, 2> API_VERSION {2, 9, 1};
inline const Utils::Version<3, 2> API_VERSION {2, 9, 2};
class APIController;
class AuthController;

View File

@@ -977,6 +977,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<input type="text" id="saveResumeDataInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(min)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="torrentFileSizeLimit">QBT_TR(.torrent file size limit:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="torrentFileSizeLimit" style="width: 15em;">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="recheckTorrentsOnCompletion">QBT_TR(Recheck torrents on completion:)QBT_TR[CONTEXT=OptionsDialog]</label>
@@ -1038,6 +1046,22 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<fieldset class="settings">
<legend>QBT_TR(libtorrent Section)QBT_TR[CONTEXT=OptionsDialog]&nbsp;(<a href="https://www.libtorrent.org/reference-Settings.html" target="_blank">QBT_TR(Open documentation)QBT_TR[CONTEXT=HttpServer]</a>)</legend>
<table>
<tr>
<td>
<label for="bdecodeDepthLimit">QBT_TR(Bdecode depth limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Bdecoding.html#bdecode()" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="bdecodeDepthLimit" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="bdecodeTokenLimit">QBT_TR(Bdecode token limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Bdecoding.html#bdecode()" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="bdecodeTokenLimit" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="asyncIOThreads">QBT_TR(Asynchronous I/O threads:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#aio_threads" target="_blank">(?)</a></label>
@@ -2151,11 +2175,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
updateNetworkInterfaces(pref.current_network_interface, pref.current_interface_name);
updateInterfaceAddresses(pref.current_network_interface, pref.current_interface_address);
$('saveResumeDataInterval').setProperty('value', pref.save_resume_data_interval);
$('torrentFileSizeLimit').setProperty('value', (pref.torrent_file_size_limit / 1024 / 1024));
$('recheckTorrentsOnCompletion').setProperty('checked', pref.recheck_completed_torrents);
$('refreshInterval').setProperty('value', pref.refresh_interval);
$('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries);
$('reannounceWhenAddressChanged').setProperty('checked', pref.reannounce_when_address_changed);
// libtorrent section
$('bdecodeDepthLimit').setProperty('value', pref.bdecode_depth_limit);
$('bdecodeTokenLimit').setProperty('value', pref.bdecode_token_limit);
$('asyncIOThreads').setProperty('value', pref.async_io_threads);
$('hashingThreads').setProperty('value', pref.hashing_threads);
$('filePoolSize').setProperty('value', pref.file_pool_size);
@@ -2567,12 +2594,15 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings.set('current_network_interface', $('networkInterface').getProperty('value'));
settings.set('current_interface_address', $('optionalIPAddressToBind').getProperty('value'));
settings.set('save_resume_data_interval', $('saveResumeDataInterval').getProperty('value'));
settings.set('torrent_file_size_limit', ($('torrentFileSizeLimit').getProperty('value') * 1024 * 1024));
settings.set('recheck_completed_torrents', $('recheckTorrentsOnCompletion').getProperty('checked'));
settings.set('refresh_interval', $('refreshInterval').getProperty('value'));
settings.set('resolve_peer_countries', $('resolvePeerCountries').getProperty('checked'));
settings.set('reannounce_when_address_changed', $('reannounceWhenAddressChanged').getProperty('checked'));
// libtorrent section
settings.set('bdecode_depth_limit', $('bdecodeDepthLimit').getProperty('value'));
settings.set('bdecode_token_limit', $('bdecodeTokenLimit').getProperty('value'));
settings.set('async_io_threads', $('asyncIOThreads').getProperty('value'));
settings.set('hashing_threads', $('hashingThreads').getProperty('value'));
settings.set('file_pool_size', $('filePoolSize').getProperty('value'));