FEATURE: Fall back to a random port if qBittorrent could not listen on the chosen port

This commit is contained in:
Christophe Dumez 2009-11-28 18:23:17 +00:00
parent e460f1c365
commit 396427e3b6
2 changed files with 11 additions and 2 deletions

View file

@ -23,6 +23,7 @@
- FEATURE: Show official documentation when pressing F1 key
- FEATURE: Search engine plugins now handle HTTP protocol gzip compression
- FEATURE: Enabled lazy bitfield as a counter-measure for ISP speed throttling
- FEATURE: Fall back to a random port if qBittorrent could not listen on the chosen port
- FEATURE: Announce to all trackers specified for a torrent (µTorrent behavior) (libtorrent >= v0.15 only)
- FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only)
- FEATURE: Support for storing symbolic links in .torrent files (libtorrent >= v0.15 only)

View file

@ -33,6 +33,7 @@
#include <QString>
#include <QTimer>
#include <QSettings>
#include <stdlib.h>
#include "filesystemwatcher.h"
#include "bittorrent.h"
@ -1496,9 +1497,16 @@ void Bittorrent::readAlerts() {
}
}
}
else if (dynamic_cast<listen_failed_alert*>(a.get())) {
else if (listen_failed_alert* p = dynamic_cast<listen_failed_alert*>(a.get())) {
// Level: fatal
addConsoleMessage(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red"));
int tried_port = p->endpoint.port();
srand(time(0));
int fallback_port = tried_port;
do {
fallback_port = rand() % 64512 + 1024;
} while(fallback_port == tried_port);
addConsoleMessage(tr("Couldn't listen on port %1, using %2 instead.").arg(QString::number(tried_port)).arg(QString::number(fallback_port)), QString::fromUtf8("red"));
setListeningPort(fallback_port);
//emit portListeningFailure();
}
/*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {