Browse Source

- BUGFIX: Catching DHT exception in case there is a problem

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
8ea34135e4
  1. 1
      Changelog
  2. 3
      TODO
  3. 9
      src/GUI.cpp
  4. 20
      src/bittorrent.cpp
  5. 2
      src/bittorrent.h

1
Changelog

@ -65,6 +65,7 @@
- BUGFIX: ETA was wrong for torrents with filtered files - BUGFIX: ETA was wrong for torrents with filtered files
- BUGFIX: Fixed drag'n drop on non-KDE systems - BUGFIX: Fixed drag'n drop on non-KDE systems
- BUGFIX: Removed build dependency on Python - BUGFIX: Removed build dependency on Python
- BUGFIX: Catching DHT exception in case there is a problem
- COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned torrent properties a little
- COSMETIC: Totally redesigned program preferences - COSMETIC: Totally redesigned program preferences
- COSMETIC: Display more logs messages concerning features - COSMETIC: Display more logs messages concerning features

3
TODO

@ -57,5 +57,6 @@
- Translations update (IN PROGRESS) - Translations update (IN PROGRESS)
rc6->rc7 changelog: rc6->rc7 changelog:
- Removed build dependency on Python - BUGFIX: Catching DHT exception in case there is a problem
- BUGFIX: Removed build dependency on Python
- I18N: Updated Turkish translation - I18N: Updated Turkish translation

9
src/GUI.cpp

@ -884,11 +884,14 @@ void GUI::configureSession(bool deleteOptions) {
BTSession->setMaxUploadsPerTorrent(options->getMaxUploadsPerTorrent()); BTSession->setMaxUploadsPerTorrent(options->getMaxUploadsPerTorrent());
// * DHT // * DHT
if(options->isDHTEnabled()) { if(options->isDHTEnabled()) {
BTSession->enableDHT(true);
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue"));
// Set DHT Port // Set DHT Port
BTSession->setDHTPort(new_listenPort); BTSession->setDHTPort(new_listenPort);
}else{ if(BTSession->enableDHT(true)) {
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue"));
} else {
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("red"));
}
} else {
BTSession->enableDHT(false); BTSession->enableDHT(false);
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue")); downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
} }

20
src/bittorrent.cpp

@ -639,7 +639,7 @@ void bittorrent::enableLSD(bool b) {
} }
// Enable DHT // Enable DHT
void bittorrent::enableDHT(bool b) { bool bittorrent::enableDHT(bool b) {
if(b) { if(b) {
if(!DHTEnabled) { if(!DHTEnabled) {
boost::filesystem::ifstream dht_state_file((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toUtf8().data(), std::ios_base::binary); boost::filesystem::ifstream dht_state_file((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toUtf8().data(), std::ios_base::binary);
@ -648,12 +648,17 @@ void bittorrent::enableDHT(bool b) {
try{ try{
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>()); dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
}catch (std::exception&) {} }catch (std::exception&) {}
s->start_dht(dht_state); try {
s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881)); s->start_dht(dht_state);
s->add_dht_router(std::make_pair(std::string("router.utorrent.com"), 6881)); s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.bitcomet.com"), 6881)); s->add_dht_router(std::make_pair(std::string("router.utorrent.com"), 6881));
DHTEnabled = true; s->add_dht_router(std::make_pair(std::string("router.bitcomet.com"), 6881));
qDebug("DHT enabled"); DHTEnabled = true;
qDebug("DHT enabled");
}catch(std::exception e) {
qDebug("Could not enable DHT, reason: %s", e.what());
return false;
}
} }
} else { } else {
if(DHTEnabled) { if(DHTEnabled) {
@ -662,6 +667,7 @@ void bittorrent::enableDHT(bool b) {
qDebug("DHT disabled"); qDebug("DHT disabled");
} }
} }
return true;
} }
void bittorrent::saveTorrentSpeedLimits(QString hash) { void bittorrent::saveTorrentSpeedLimits(QString hash) {

2
src/bittorrent.h

@ -135,7 +135,7 @@ class bittorrent : public QObject{
void enableUPnP(bool b); void enableUPnP(bool b);
void enableNATPMP(bool b); void enableNATPMP(bool b);
void enableLSD(bool b); void enableLSD(bool b);
void enableDHT(bool b); bool enableDHT(bool b);
protected slots: protected slots:
void scanDirectory(); void scanDirectory();

Loading…
Cancel
Save