Browse Source

- Fix to port settings

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
4f9eca78d9
  1. 12
      src/bittorrent.cpp
  2. 1
      src/bittorrent.h

12
src/bittorrent.cpp

@ -63,7 +63,7 @@
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4}; enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4};
// Main constructor // Main constructor
Bittorrent::Bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), DHTEnabled(false), queueingEnabled(false), geoipDBLoaded(false), exiting(false) { Bittorrent::Bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), DHTEnabled(false), current_dht_port(0), queueingEnabled(false), geoipDBLoaded(false), exiting(false) {
resolve_countries = false; resolve_countries = false;
// To avoid some exceptions // To avoid some exceptions
fs::path::default_name_check(fs::no_check); fs::path::default_name_check(fs::no_check);
@ -254,11 +254,16 @@ void Bittorrent::configureSession() {
// Connection // Connection
// * Ports binding // * Ports binding
unsigned short old_listenPort = getListenPort(); unsigned short old_listenPort = getListenPort();
unsigned short new_listenPort;
if(old_listenPort != Preferences::getSessionPort()) {
setListeningPort(Preferences::getSessionPort()); setListeningPort(Preferences::getSessionPort());
unsigned short new_listenPort = getListenPort(); new_listenPort = getListenPort();
if(new_listenPort != old_listenPort) { if(new_listenPort != old_listenPort) {
addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg( misc::toQString(new_listenPort))); addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg( misc::toQString(new_listenPort)));
} }
} else {
new_listenPort = old_listenPort;
}
// * Global download limit // * Global download limit
int down_limit = Preferences::getGlobalDownloadLimit(); int down_limit = Preferences::getGlobalDownloadLimit();
if(down_limit <= 0) { if(down_limit <= 0) {
@ -1499,9 +1504,11 @@ void Bittorrent::setDeleteRatio(float ratio) {
// Set DHT port (>= 1000 or 0 if same as BT) // Set DHT port (>= 1000 or 0 if same as BT)
void Bittorrent::setDHTPort(int dht_port) { void Bittorrent::setDHTPort(int dht_port) {
if(dht_port == 0 || dht_port >= 1000) { if(dht_port == 0 || dht_port >= 1000) {
if(dht_port == current_dht_port) return;
struct dht_settings DHTSettings; struct dht_settings DHTSettings;
DHTSettings.service_port = dht_port; DHTSettings.service_port = dht_port;
s->set_dht_settings(DHTSettings); s->set_dht_settings(DHTSettings);
current_dht_port = dht_port;
qDebug("Set DHT Port to %d", dht_port); qDebug("Set DHT Port to %d", dht_port);
} }
} }
@ -1797,6 +1804,7 @@ QHash<QString, TrackerInfos> Bittorrent::getTrackersInfo(QString hash) const{
} }
int Bittorrent::getListenPort() const{ int Bittorrent::getListenPort() const{
qDebug("LISTEN PORT: %d", s->listen_port());
return s->listen_port(); return s->listen_port();
} }

1
src/bittorrent.h

@ -107,6 +107,7 @@ private:
bool NATPMPEnabled; bool NATPMPEnabled;
bool LSDEnabled; bool LSDEnabled;
bool DHTEnabled; bool DHTEnabled;
int current_dht_port;
bool PeXEnabled; bool PeXEnabled;
bool queueingEnabled; bool queueingEnabled;
bool appendLabelToSavePath; bool appendLabelToSavePath;

Loading…
Cancel
Save