Browse Source

Add I2P settings to WebUI

PR #19700.
adaptive-webui-19844
thalieht 1 year ago committed by GitHub
parent
commit
a3888811f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      src/webui/api/appcontroller.cpp
  2. 2
      src/webui/webapplication.h
  3. 88
      src/webui/www/private/views/preferences.html

28
src/webui/api/appcontroller.cpp

@ -193,6 +193,16 @@ void AppController::preferencesAction()
data[u"max_uploads"_s] = session->maxUploads(); data[u"max_uploads"_s] = session->maxUploads();
data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent(); data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent();
// I2P
data[u"i2p_enabled"_s] = session->isI2PEnabled();
data[u"i2p_address"_s] = session->I2PAddress();
data[u"i2p_port"_s] = session->I2PPort();
data[u"i2p_mixed_mode"_s] = session->I2PMixedMode();
data[u"i2p_inbound_quantity"_s] = session->I2PInboundQuantity();
data[u"i2p_outbound_quantity"_s] = session->I2POutboundQuantity();
data[u"i2p_inbound_length"_s] = session->I2PInboundLength();
data[u"i2p_outbound_length"_s] = session->I2POutboundLength();
// Proxy Server // Proxy Server
const auto *proxyManager = Net::ProxyConfigurationManager::instance(); const auto *proxyManager = Net::ProxyConfigurationManager::instance();
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration(); Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();
@ -632,6 +642,24 @@ void AppController::setPreferencesAction()
if (hasKey(u"max_uploads_per_torrent"_s)) if (hasKey(u"max_uploads_per_torrent"_s))
session->setMaxUploadsPerTorrent(it.value().toInt()); session->setMaxUploadsPerTorrent(it.value().toInt());
// I2P
if (hasKey(u"i2p_enabled"_s))
session->setI2PEnabled(it.value().toBool());
if (hasKey(u"i2p_address"_s))
session->setI2PAddress(it.value().toString());
if (hasKey(u"i2p_port"_s))
session->setI2PPort(it.value().toInt());
if (hasKey(u"i2p_mixed_mode"_s))
session->setI2PMixedMode(it.value().toBool());
if (hasKey(u"i2p_inbound_quantity"_s))
session->setI2PInboundQuantity(it.value().toInt());
if (hasKey(u"i2p_outbound_quantity"_s))
session->setI2POutboundQuantity(it.value().toInt());
if (hasKey(u"i2p_inbound_length"_s))
session->setI2PInboundLength(it.value().toInt());
if (hasKey(u"i2p_outbound_length"_s))
session->setI2POutboundLength(it.value().toInt());
// Proxy Server // Proxy Server
auto *proxyManager = Net::ProxyConfigurationManager::instance(); auto *proxyManager = Net::ProxyConfigurationManager::instance();
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration(); Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();

2
src/webui/webapplication.h

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

88
src/webui/www/private/views/preferences.html

@ -349,6 +349,33 @@
</table> </table>
</fieldset> </fieldset>
<fieldset class="settings">
<legend>
<input type="checkbox" id="i2pEnabledCheckbox" onclick="qBittorrent.Preferences.updateI2PSettingsEnabled();" />
<label for="i2pEnabledCheckbox">QBT_TR(I2P (Experimental) (requires libtorrent &gt;= 2.0))QBT_TR[CONTEXT=OptionsDialog]</label>
</legend>
<table>
<tr>
<td>
<label for="i2pAddress">QBT_TR(Host:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="i2pAddress" />
</td>
<td>
<label for="i2pPort">QBT_TR(Port:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="number" id="i2pPort" min="0" max="65535" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 5em;" />
</td>
</tr>
</table>
<div class="formRow">
<input type="checkbox" id="i2pMixedMode" title="QBT_TR(If &quot;mixed mode&quot; is enabled, I2P torrents are allowed to also get peers from other sources than the tracker, and connect to regular IPs, not providing any anonymization. This may be useful if the user is not interested in the anonymization of I2P, but still wants to be able to connect to I2P peers.)QBT_TR[CONTEXT=OptionsDialog]" />
<label for="i2pMixedMode">QBT_TR(Mixed mode)QBT_TR[CONTEXT=OptionsDialog]</label>
</div>
</fieldset>
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(Proxy Server)QBT_TR[CONTEXT=OptionsDialog]</legend> <legend>QBT_TR(Proxy Server)QBT_TR[CONTEXT=OptionsDialog]</legend>
<table> <table>
@ -1436,6 +1463,38 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<input type="text" id="dhtBootstrapNodes" placeholder="QBT_TR(Resets to default if empty)QBT_TR[CONTEXT=OptionsDialog]" style="width: 15em;" /> <input type="text" id="dhtBootstrapNodes" placeholder="QBT_TR(Resets to default if empty)QBT_TR[CONTEXT=OptionsDialog]" style="width: 15em;" />
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="i2pInboundQuantity">QBT_TR(I2P inbound quantity (requires libtorrent &gt;= 2.0):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_inbound_quantity" target="_blank">(?)</a></label>
</td>
<td>
<input id="i2pInboundQuantity" type="number" min="1" max="16" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="i2pOutboundQuantity">QBT_TR(I2P outbound quantity (requires libtorrent &gt;= 2.0):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_outbound_quantity" target="_blank">(?)</a></label>
</td>
<td>
<input id="i2pOutboundQuantity" type="number" min="1" max="16" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="i2pInboundLength">QBT_TR(I2P inbound length (requires libtorrent &gt;= 2.0):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_inbound_length" target="_blank">(?)</a></label>
</td>
<td>
<input id="i2pInboundLength" type="number" min="0" max="7" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="i2pOutboundLength">QBT_TR(I2P outbound length (requires libtorrent &gt;= 2.0):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_outbound_length" target="_blank">(?)</a></label>
</td>
<td>
<input id="i2pOutboundLength" type="number" min="0" max="7" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;" />
</td>
</tr>
</table> </table>
</fieldset> </fieldset>
</div> </div>
@ -1471,6 +1530,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled, updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled,
updateMaxUploadsEnabled: updateMaxUploadsEnabled, updateMaxUploadsEnabled: updateMaxUploadsEnabled,
updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled, updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled,
updateI2PSettingsEnabled: updateI2PSettingsEnabled,
updatePeerProxySettings: updatePeerProxySettings, updatePeerProxySettings: updatePeerProxySettings,
updatePeerProxyAuthSettings: updatePeerProxyAuthSettings, updatePeerProxyAuthSettings: updatePeerProxyAuthSettings,
updateFilterSettings: updateFilterSettings, updateFilterSettings: updateFilterSettings,
@ -1660,6 +1720,13 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('max_uploads_per_torrent_value').setProperty('disabled', !isMaxUploadsPerTorrentEnabled); $('max_uploads_per_torrent_value').setProperty('disabled', !isMaxUploadsPerTorrentEnabled);
}; };
const updateI2PSettingsEnabled = function() {
const isI2PEnabled = $('i2pEnabledCheckbox').getProperty('checked');
$('i2pAddress').setProperty('disabled', !isI2PEnabled);
$('i2pPort').setProperty('disabled', !isI2PEnabled);
$('i2pMixedMode').setProperty('disabled', !isI2PEnabled);
};
const updatePeerProxySettings = function() { const updatePeerProxySettings = function() {
const proxyType = $('peer_proxy_type_select').getProperty('value'); const proxyType = $('peer_proxy_type_select').getProperty('value');
const isProxyDisabled = (proxyType === "None"); const isProxyDisabled = (proxyType === "None");
@ -2039,6 +2106,13 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
} }
updateMaxUploadsPerTorrentEnabled(); updateMaxUploadsPerTorrentEnabled();
// I2P
$('i2pEnabledCheckbox').setProperty('checked', pref.i2p_enabled);
$('i2pAddress').setProperty('value', pref.i2p_address);
$('i2pPort').setProperty('value', pref.i2p_port);
$('i2pMixedMode').setProperty('checked', pref.i2p_mixed_mode);
updateI2PSettingsEnabled();
// Proxy Server // Proxy Server
$('peer_proxy_type_select').setProperty('value', pref.proxy_type); $('peer_proxy_type_select').setProperty('value', pref.proxy_type);
$('peer_proxy_host_text').setProperty('value', pref.proxy_ip); $('peer_proxy_host_text').setProperty('value', pref.proxy_ip);
@ -2259,6 +2333,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('peerTurnoverInterval').setProperty('value', pref.peer_turnover_interval); $('peerTurnoverInterval').setProperty('value', pref.peer_turnover_interval);
$('requestQueueSize').setProperty('value', pref.request_queue_size); $('requestQueueSize').setProperty('value', pref.request_queue_size);
$('dhtBootstrapNodes').setProperty('value', pref.dht_bootstrap_nodes); $('dhtBootstrapNodes').setProperty('value', pref.dht_bootstrap_nodes);
$('i2pInboundQuantity').setProperty('value', pref.i2p_inbound_quantity);
$('i2pOutboundQuantity').setProperty('value', pref.i2p_outbound_quantity);
$('i2pInboundLength').setProperty('value', pref.i2p_inbound_length);
$('i2pOutboundLength').setProperty('value', pref.i2p_outbound_length);
} }
} }
}).send(); }).send();
@ -2378,6 +2456,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
} }
settings.set('max_uploads_per_torrent', max_uploads_per_torrent); settings.set('max_uploads_per_torrent', max_uploads_per_torrent);
// I2P
settings.set('i2p_enabled', $('i2pEnabledCheckbox').getProperty('checked'));
settings.set('i2p_address', $('i2pAddress').getProperty('value'));
settings.set('i2p_port', $('i2pPort').getProperty('value').toInt());
settings.set('i2p_mixed_mode', $('i2pMixedMode').getProperty('checked'));
// Proxy Server // Proxy Server
settings.set('proxy_type', $('peer_proxy_type_select').getProperty('value')); settings.set('proxy_type', $('peer_proxy_type_select').getProperty('value'));
settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value')); settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value'));
@ -2693,6 +2777,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings.set('peer_turnover_interval', $('peerTurnoverInterval').getProperty('value')); settings.set('peer_turnover_interval', $('peerTurnoverInterval').getProperty('value'));
settings.set('request_queue_size', $('requestQueueSize').getProperty('value')); settings.set('request_queue_size', $('requestQueueSize').getProperty('value'));
settings.set('dht_bootstrap_nodes', $('dhtBootstrapNodes').getProperty('value')); settings.set('dht_bootstrap_nodes', $('dhtBootstrapNodes').getProperty('value'));
settings.set('i2p_inbound_quantity', $('i2pInboundQuantity').getProperty('value'));
settings.set('i2p_outbound_quantity', $('i2pOutboundQuantity').getProperty('value'));
settings.set('i2p_inbound_length', $('i2pInboundLength').getProperty('value'));
settings.set('i2p_outbound_length', $('i2pOutboundLength').getProperty('value'));
// Send it to qBT // Send it to qBT
const json_str = JSON.encode(settings); const json_str = JSON.encode(settings);

Loading…
Cancel
Save