mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
DHT port can be changed from Web UI
This commit is contained in:
parent
f2c4901dd0
commit
94c7c5cebe
@ -189,6 +189,10 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
|
|||||||
// Bittorrent
|
// Bittorrent
|
||||||
if(m.contains("dht"))
|
if(m.contains("dht"))
|
||||||
Preferences::setDHTEnabled(m["dht"].toBool());
|
Preferences::setDHTEnabled(m["dht"].toBool());
|
||||||
|
if(m.contains("dhtSameAsBT"))
|
||||||
|
Preferences::setDHTPortSameAsBT(m["dhtSameAsBT"].toBool());
|
||||||
|
if(m.contains("dht_port"))
|
||||||
|
Preferences::setDHTPort(m["dht_port"].toInt());
|
||||||
if(m.contains("pex"))
|
if(m.contains("pex"))
|
||||||
Preferences::setPeXEnabled(m["pex"].toBool());
|
Preferences::setPeXEnabled(m["pex"].toBool());
|
||||||
qDebug("Pex support: %d", (int)m["pex"].toBool());
|
qDebug("Pex support: %d", (int)m["pex"].toBool());
|
||||||
@ -274,6 +278,8 @@ QVariantMap EventManager::getGlobalPreferences() const {
|
|||||||
data["max_uploads_per_torrent"] = Preferences::getMaxUploadsPerTorrent();
|
data["max_uploads_per_torrent"] = Preferences::getMaxUploadsPerTorrent();
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
data["dht"] = Preferences::isDHTEnabled();
|
data["dht"] = Preferences::isDHTEnabled();
|
||||||
|
data["dhtSameAsBT"] = Preferences::isDHTPortSameAsBT();
|
||||||
|
data["dht_port"] = Preferences::getDHTPort();
|
||||||
data["pex"] = Preferences::isPeXEnabled();
|
data["pex"] = Preferences::isPeXEnabled();
|
||||||
data["lsd"] = Preferences::isLSDEnabled();
|
data["lsd"] = Preferences::isLSDEnabled();
|
||||||
data["encryption"] = Preferences::getEncryptionSetting();
|
data["encryption"] = Preferences::getEncryptionSetting();
|
||||||
|
@ -619,11 +619,21 @@ public:
|
|||||||
return settings.value(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), true).toBool();
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setDHTPortSameAsBT(bool same) {
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), same);
|
||||||
|
}
|
||||||
|
|
||||||
static int getDHTPort() {
|
static int getDHTPort() {
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
return settings.value(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), 6881).toInt();
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), 6881).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setDHTPort(int port) {
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), port);
|
||||||
|
}
|
||||||
|
|
||||||
static bool isLSDEnabled() {
|
static bool isLSDEnabled() {
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
return settings.value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
|
||||||
|
@ -55,6 +55,12 @@
|
|||||||
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="dht_checkbox"/></td><td>_(Enable DHT network (decentralized))</td>
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="dht_checkbox"/></td><td>_(Enable DHT network (decentralized))</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="DHTPortDiffThanBT_checkbox" onclick="updateDHTPortSettings();"/></td><td>_(Use a different port for DHT and Bittorrent)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="vertical-align: bottom; text-align: right;">_(DHT port:)</td><td><input type="text" id="DHTPort_txt" value="6881"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="pex_checkbox"/></td><td>_(Enable Peer Exchange / PeX (requires restart))</td>
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="pex_checkbox"/></td><td>_(Enable Peer Exchange / PeX (requires restart))</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -332,6 +338,10 @@
|
|||||||
var dht = 0;
|
var dht = 0;
|
||||||
if($defined($('dht_checkbox').get('checked')) && $('dht_checkbox').get('checked'))
|
if($defined($('dht_checkbox').get('checked')) && $('dht_checkbox').get('checked'))
|
||||||
dht = 1;
|
dht = 1;
|
||||||
|
var dhtSameAsBT = 1;
|
||||||
|
if($defined($('DHTPortDiffThanBT_checkbox').get('checked')) && $('DHTPortDiffThanBT_checkbox').get('checked'))
|
||||||
|
dhtSameAsBT = 0;
|
||||||
|
var dht_port = $("DHTPort_txt").get('value').toInt();
|
||||||
var pex = 0;
|
var pex = 0;
|
||||||
if($defined($('pex_checkbox').get('checked')) && $('pex_checkbox').get('checked'))
|
if($defined($('pex_checkbox').get('checked')) && $('pex_checkbox').get('checked'))
|
||||||
pex = 1;
|
pex = 1;
|
||||||
@ -459,6 +469,8 @@
|
|||||||
dict.set('max_uploads_per_torrent', max_uploads_per_torrent);
|
dict.set('max_uploads_per_torrent', max_uploads_per_torrent);
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
dict.set('dht', dht);
|
dict.set('dht', dht);
|
||||||
|
dict.set('dhtSameAsBT', dhtSameAsBT);
|
||||||
|
dict.set('dht_port', dht_port);
|
||||||
dict.set('pex', pex);
|
dict.set('pex', pex);
|
||||||
dict.set('lsd', lsd);
|
dict.set('lsd', lsd);
|
||||||
dict.set('encryption', $('encryption_select').get('value'));
|
dict.set('encryption', $('encryption_select').get('value'));
|
||||||
@ -636,6 +648,14 @@ updateFilterSettings = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDHTPortSettings = function() {
|
||||||
|
if($defined($('DHTPortDiffThanBT_checkbox').get('checked')) && $('DHTPortDiffThanBT_checkbox').get('checked')) {
|
||||||
|
$('DHTPort_txt').removeProperty('disabled');
|
||||||
|
} else {
|
||||||
|
$('DHTPort_txt').set('disabled', 'true');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateHTTPProxySettings = function() {
|
updateHTTPProxySettings = function() {
|
||||||
if($('http_proxy_type_select').get('value') != "none") {
|
if($('http_proxy_type_select').get('value') != "none") {
|
||||||
$('http_proxy_host_text').removeProperty('disabled');
|
$('http_proxy_host_text').removeProperty('disabled');
|
||||||
@ -807,6 +827,14 @@ loadPreferences = function() {
|
|||||||
} else {
|
} else {
|
||||||
$('dht_checkbox').removeProperty('checked');
|
$('dht_checkbox').removeProperty('checked');
|
||||||
}
|
}
|
||||||
|
var dhtSameAsBT = pref.dhtSameAsBT;
|
||||||
|
if(dhtSameAsBT) {
|
||||||
|
$('DHTPortDiffThanBT_checkbox').removeProperty('checked');
|
||||||
|
} else {
|
||||||
|
$('DHTPortDiffThanBT_checkbox').set('checked', 'checked');
|
||||||
|
}
|
||||||
|
$("DHTPort_txt").set("value", pref.dht_port);
|
||||||
|
updateDHTPortSettings();
|
||||||
var pex = pref.pex; //bool
|
var pex = pref.pex; //bool
|
||||||
if(pex) {
|
if(pex) {
|
||||||
$('pex_checkbox').set('checked', 'checked');
|
$('pex_checkbox').set('checked', 'checked');
|
||||||
|
Loading…
Reference in New Issue
Block a user