Browse Source

Remove deprecated feature of separate DHT port.

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
e2748ec3ac
  1. 66
      src/preferences/options.ui
  2. 16
      src/preferences/options_imp.cpp
  3. 2
      src/preferences/options_imp.h
  4. 16
      src/preferences/preferences.h
  5. 49
      src/qtlibtorrent/qbtsession.cpp
  6. 6
      src/qtlibtorrent/qbtsession.h
  7. 6
      src/webui/prefjson.cpp

66
src/preferences/options.ui

@ -1948,73 +1948,13 @@ @@ -1948,73 +1948,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QGroupBox" name="checkDHT">
<property name="title">
<widget class="QCheckBox" name="checkDHT">
<property name="text">
<string>Enable DHT (decentralized network) to find more peers</string>
</property>
<property name="checkable">
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QGroupBox" name="checkDifferentDHTPort">
<property name="title">
<string>Use a different port for DHT and BitTorrent</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="dh_port_lbl">
<property name="text">
<string>DHT port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinDHTPort">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65525</number>
</property>
<property name="value">
<number>6881</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>

16
src/preferences/options_imp.cpp

@ -206,8 +206,6 @@ options_imp::options_imp(QWidget *parent): @@ -206,8 +206,6 @@ options_imp::options_imp(QWidget *parent):
connect(checkDHT, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkAnonymousMode, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkPeX, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkDifferentDHTPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinDHTPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkLSD, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(comboEncryption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -432,8 +430,6 @@ void options_imp::saveOptions() { @@ -432,8 +430,6 @@ void options_imp::saveOptions() {
pref.setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
pref.setDHTEnabled(isDHTEnabled());
pref.setPeXEnabled(checkPeX->isChecked());
pref.setDHTPortSameAsBT(isDHTPortSameAsBT());
pref.setDHTPort(getDHTPort());
pref.setLSDEnabled(isLSDEnabled());
pref.setEncryptionSetting(getEncryptionSetting());
pref.enableAnonymousMode(checkAnonymousMode->isChecked());
@ -695,8 +691,6 @@ void options_imp::loadOptions() { @@ -695,8 +691,6 @@ void options_imp::loadOptions() {
spinMaxUploadsPerTorrent->setEnabled(false);
}
checkDHT->setChecked(pref.isDHTEnabled());
checkDifferentDHTPort->setChecked(!pref.isDHTPortSameAsBT());
spinDHTPort->setValue(pref.getDHTPort());
checkPeX->setChecked(pref.isPeXEnabled());
checkLSD->setChecked(pref.isLSDEnabled());
comboEncryption->setCurrentIndex(pref.getEncryptionSetting());
@ -825,10 +819,6 @@ bool options_imp::systrayIntegration() const { @@ -825,10 +819,6 @@ bool options_imp::systrayIntegration() const {
return checkShowSystray->isChecked();
}
int options_imp::getDHTPort() const {
return spinDHTPort->value();
}
// Return Share ratio
qreal options_imp::getMaxRatio() const {
if (checkMaxRatio->isChecked()) {
@ -979,10 +969,6 @@ bool options_imp::addTorrentsInPause() const { @@ -979,10 +969,6 @@ bool options_imp::addTorrentsInPause() const {
return checkStartPaused->isChecked();
}
bool options_imp::isDHTPortSameAsBT() const {
return !checkDifferentDHTPort->isChecked();
}
// Proxy settings
bool options_imp::isProxyEnabled() const {
return comboProxyType->currentIndex();
@ -1342,7 +1328,6 @@ void options_imp::toggleAnonymousMode(bool enabled) @@ -1342,7 +1328,6 @@ void options_imp::toggleAnonymousMode(bool enabled)
if (enabled) {
// Disable DHT, LSD, UPnP / NAT-PMP
checkDHT->setEnabled(false);
checkDifferentDHTPort->setEnabled(false);
checkDHT->setChecked(false);
checkLSD->setEnabled(false);
checkLSD->setChecked(false);
@ -1350,7 +1335,6 @@ void options_imp::toggleAnonymousMode(bool enabled) @@ -1350,7 +1335,6 @@ void options_imp::toggleAnonymousMode(bool enabled)
checkUPnP->setChecked(false);
} else {
checkDHT->setEnabled(true);
checkDifferentDHTPort->setEnabled(true);
checkLSD->setEnabled(true);
checkUPnP->setEnabled(true);
}

2
src/preferences/options_imp.h

@ -126,8 +126,6 @@ private: @@ -126,8 +126,6 @@ private:
int getMaxUploads() const;
int getMaxUploadsPerTorrent() const;
bool isDHTEnabled() const;
bool isDHTPortSameAsBT() const;
int getDHTPort() const;
bool isLSDEnabled() const;
int getEncryptionSetting() const;
qreal getMaxRatio() const;

16
src/preferences/preferences.h

@ -658,22 +658,6 @@ public: @@ -658,22 +658,6 @@ public:
setValue(QString::fromUtf8("Preferences/Bittorrent/PeX"), enabled);
}
bool isDHTPortSameAsBT() const {
return value(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), true).toBool();
}
void setDHTPortSameAsBT(bool same) {
setValue(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), same);
}
int getDHTPort() const {
return value(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), 6881).toInt();
}
void setDHTPort(int port) {
setValue(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), port);
}
bool isLSDEnabled() const {
return value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
}

49
src/qtlibtorrent/qbtsession.cpp

@ -105,7 +105,7 @@ QBtSession::QBtSession() @@ -105,7 +105,7 @@ QBtSession::QBtSession()
: m_scanFolders(ScanFoldersModel::instance(this)),
preAllocateAll(false), global_ratio_limit(-1),
LSDEnabled(false),
DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
DHTEnabled(false), queueingEnabled(false),
m_torrentExportEnabled(false),
m_finishedTorrentExportEnabled(false)
#ifndef DISABLE_GUI
@ -488,25 +488,7 @@ void QBtSession::configureSession() { @@ -488,25 +488,7 @@ void QBtSession::configureSession() {
// * Max uploads per torrent limit
setMaxUploadsPerTorrent(pref.getMaxUploadsPerTorrent());
// * DHT
if (pref.isDHTEnabled()) {
// Set DHT Port
if (enableDHT(true)) {
int dht_port = 0;
#if LIBTORRENT_VERSION_NUM < 10000
if (!pref.isDHTPortSameAsBT())
dht_port = pref.getDHTPort();
setDHTPort(dht_port);
#endif
if (dht_port == 0) dht_port = new_listenPort;
addConsoleMessage(tr("DHT support [ON], port: UDP/%1").arg(dht_port), QString::fromUtf8("blue"));
} else {
addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("red"));
}
} else {
enableDHT(false);
addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
}
enableDHT(pref.isDHTEnabled());
// * PeX
if (PeXEnabled) {
addConsoleMessage(tr("PeX support [ON]"), QString::fromUtf8("blue"));
@ -1531,7 +1513,7 @@ void QBtSession::saveSessionState() { @@ -1531,7 +1513,7 @@ void QBtSession::saveSessionState() {
}
// Enable DHT
bool QBtSession::enableDHT(bool b) {
void QBtSession::enableDHT(bool b) {
if (b) {
if (!DHTEnabled) {
try {
@ -1543,20 +1525,23 @@ bool QBtSession::enableDHT(bool b) { @@ -1543,20 +1525,23 @@ bool QBtSession::enableDHT(bool b) {
s->add_dht_router(std::make_pair(std::string("dht.transmissionbt.com"), 6881));
s->add_dht_router(std::make_pair(std::string("dht.aelitis.com"), 6881)); // Vuze
DHTEnabled = true;
addConsoleMessage(tr("DHT support [ON]"), QString::fromUtf8("blue"));
qDebug("DHT enabled");
}catch(std::exception &e) {
}
catch(std::exception &e) {
qDebug("Could not enable DHT, reason: %s", e.what());
return false;
addConsoleMessage(tr("DHT support [OFF]. Reason: %1").arg(misc::toQString(e.what())), QString::fromUtf8("red"));
}
}
} else {
}
else {
if (DHTEnabled) {
DHTEnabled = false;
s->stop_dht();
addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
qDebug("DHT disabled");
}
}
return true;
}
qreal QBtSession::getRealRatio(const libtorrent::torrent_status &status) const {
@ -2000,20 +1985,6 @@ void QBtSession::updateRatioTimer() @@ -2000,20 +1985,6 @@ void QBtSession::updateRatioTimer()
}
}
#if LIBTORRENT_VERSION_NUM < 10000
// Set DHT port (>= 1 or 0 if same as BT)
void QBtSession::setDHTPort(int dht_port) {
if (dht_port >= 0) {
if (dht_port == current_dht_port) return;
struct dht_settings DHTSettings;
DHTSettings.service_port = dht_port;
s->set_dht_settings(DHTSettings);
current_dht_port = dht_port;
qDebug("Set DHT Port to %d", dht_port);
}
}
#endif
// Enable IP Filtering
void QBtSession::enableIPFilter(const QString &filter_path, bool force) {
qDebug("Enabling IPFiler");

6
src/qtlibtorrent/qbtsession.h

@ -150,9 +150,6 @@ public slots: @@ -150,9 +150,6 @@ public slots:
void setMaxRatioPerTorrent(const QString &hash, qreal ratio);
qreal getMaxRatioPerTorrent(const QString &hash, bool *usesGlobalRatio) const;
void removeRatioPerTorrent(const QString &hash);
#if LIBTORRENT_VERSION_NUM < 10000
void setDHTPort(int dht_port);
#endif
void setProxySettings(libtorrent::proxy_settings proxySettings);
void setSessionSettings(const libtorrent::session_settings &sessionSettings);
void setDefaultSavePath(const QString &savepath);
@ -167,7 +164,7 @@ public slots: @@ -167,7 +164,7 @@ public slots:
void setUploadLimit(QString hash, long val);
void enableUPnP(bool b);
void enableLSD(bool b);
bool enableDHT(bool b);
void enableDHT(bool b);
#ifdef DISABLE_GUI
void addConsoleMessage(QString msg, QString color=QString::null);
#else
@ -287,7 +284,6 @@ private: @@ -287,7 +284,6 @@ private:
int high_ratio_action;
bool LSDEnabled;
bool DHTEnabled;
int current_dht_port;
bool PeXEnabled;
bool queueingEnabled;
bool appendLabelToSavePath;

6
src/webui/prefjson.cpp

@ -106,8 +106,6 @@ QByteArray prefjson::getPreferences() @@ -106,8 +106,6 @@ QByteArray prefjson::getPreferences()
data["scheduler_days"] = pref.getSchedulerDays();
// Bittorrent
data["dht"] = pref.isDHTEnabled();
data["dhtSameAsBT"] = pref.isDHTPortSameAsBT();
data["dht_port"] = pref.getDHTPort();
data["pex"] = pref.isPeXEnabled();
data["lsd"] = pref.isLSDEnabled();
data["encryption"] = pref.getEncryptionSetting();
@ -270,10 +268,6 @@ void prefjson::setPreferences(const QString& json) @@ -270,10 +268,6 @@ void prefjson::setPreferences(const QString& json)
// Bittorrent
if (m.contains("dht"))
pref.setDHTEnabled(m["dht"].toBool());
if (m.contains("dhtSameAsBT"))
pref.setDHTPortSameAsBT(m["dhtSameAsBT"].toBool());
if (m.contains("dht_port"))
pref.setDHTPort(m["dht_port"].toInt());
if (m.contains("pex"))
pref.setPeXEnabled(m["pex"].toBool());
qDebug("Pex support: %d", (int)m["pex"].toBool());

Loading…
Cancel
Save