From e2748ec3aced32ce99491bd63a1bdcfa6387f7f8 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Wed, 16 Jul 2014 00:01:56 +0300 Subject: [PATCH] Remove deprecated feature of separate DHT port. --- src/preferences/options.ui | 66 ++------------------------------- src/preferences/options_imp.cpp | 16 -------- src/preferences/options_imp.h | 2 - src/preferences/preferences.h | 16 -------- src/qtlibtorrent/qbtsession.cpp | 49 +++++------------------- src/qtlibtorrent/qbtsession.h | 6 +-- src/webui/prefjson.cpp | 6 --- 7 files changed, 14 insertions(+), 147 deletions(-) diff --git a/src/preferences/options.ui b/src/preferences/options.ui index ca8990d7c..9b9dc5406 100755 --- a/src/preferences/options.ui +++ b/src/preferences/options.ui @@ -1948,73 +1948,13 @@ - - + + Enable DHT (decentralized network) to find more peers - + true - - - - - Use a different port for DHT and BitTorrent - - - true - - - false - - - - 9 - - - - - 5 - - - - - DHT port: - - - - - - - 1 - - - 65525 - - - 6881 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index 3707cb02b..022d1eeb6 100755 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -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() { 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() { 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 { 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 { 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) 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) checkUPnP->setChecked(false); } else { checkDHT->setEnabled(true); - checkDifferentDHTPort->setEnabled(true); checkLSD->setEnabled(true); checkUPnP->setEnabled(true); } diff --git a/src/preferences/options_imp.h b/src/preferences/options_imp.h index 7f86b61cd..d0d8474e6 100755 --- a/src/preferences/options_imp.h +++ b/src/preferences/options_imp.h @@ -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; diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index aaf3efb52..34ced52b6 100755 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -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(); } diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 9eb75da29..2f3317c95 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -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() { // * 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() { } // 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) { 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() } } -#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"); diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h index 434f99178..4f386a3b1 100755 --- a/src/qtlibtorrent/qbtsession.h +++ b/src/qtlibtorrent/qbtsession.h @@ -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: 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: int high_ratio_action; bool LSDEnabled; bool DHTEnabled; - int current_dht_port; bool PeXEnabled; bool queueingEnabled; bool appendLabelToSavePath; diff --git a/src/webui/prefjson.cpp b/src/webui/prefjson.cpp index b46725950..cf265de92 100644 --- a/src/webui/prefjson.cpp +++ b/src/webui/prefjson.cpp @@ -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) // 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());