Browse Source

Merge pull request #7657 from Chocobo1/upnp

Disable upnp & nat-pmp on startup if disabled in options. Closes #7338.
adaptive-webui-19844
sledgehammer999 7 years ago committed by GitHub
parent
commit
9f8e7917a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/base/bittorrent/session.cpp

21
src/base/bittorrent/session.cpp

@ -370,10 +370,10 @@ Session::Session(QObject *parent) @@ -370,10 +370,10 @@ Session::Session(QObject *parent)
m_seedingLimitTimer = new QTimer(this);
m_seedingLimitTimer->setInterval(10000);
connect(m_seedingLimitTimer, SIGNAL(timeout()), SLOT(processShareLimits()));
connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits);
// Set severity level of libtorrent session
int alertMask = libt::alert::error_notification
const int alertMask = libt::alert::error_notification
| libt::alert::peer_notification
| libt::alert::port_mapping_notification
| libt::alert::storage_notification
@ -381,8 +381,7 @@ Session::Session(QObject *parent) @@ -381,8 +381,7 @@ Session::Session(QObject *parent)
| libt::alert::status_notification
| libt::alert::ip_block_notification
| libt::alert::progress_notification
| libt::alert::stats_notification
;
| libt::alert::stats_notification;
#if LIBTORRENT_VERSION_NUM < 10100
libt::fingerprint fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
@ -418,13 +417,12 @@ Session::Session(QObject *parent) @@ -418,13 +417,12 @@ Session::Session(QObject *parent)
dispatchAlerts(alertPtr.release());
});
#else
std::string peerId = libt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
const std::string peerId = libt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
libt::settings_pack pack;
pack.set_int(libt::settings_pack::alert_mask, alertMask);
pack.set_str(libt::settings_pack::peer_fingerprint, peerId);
pack.set_bool(libt::settings_pack::listen_system_port_fallback, false);
pack.set_str(libt::settings_pack::user_agent, USER_AGENT);
pack.set_bool(libt::settings_pack::upnp_ignore_nonrouters, true);
pack.set_bool(libt::settings_pack::use_dht_as_fallback, false);
// Disable support for SSL torrents for now
pack.set_int(libt::settings_pack::ssl_listen, 0);
@ -440,6 +438,11 @@ Session::Session(QObject *parent) @@ -440,6 +438,11 @@ Session::Session(QObject *parent)
// Soon to be deprecated there
// More info: https://github.com/arvidn/libtorrent/issues/2251
pack.set_bool(libt::settings_pack::use_disk_cache_pool, false);
// libtorrent 1.1 enables UPnP & NAT-PMP by default
// turn them off before `libt::session` ctor to avoid split second effects
pack.set_bool(libt::settings_pack::enable_upnp, false);
pack.set_bool(libt::settings_pack::enable_natpmp, false);
pack.set_bool(libt::settings_pack::upnp_ignore_nonrouters, true);
configure(pack);
m_nativeSession = new libt::session(pack, 0);
@ -493,13 +496,13 @@ Session::Session(QObject *parent) @@ -493,13 +496,13 @@ Session::Session(QObject *parent)
m_refreshTimer = new QTimer(this);
m_refreshTimer->setInterval(refreshInterval());
connect(m_refreshTimer, SIGNAL(timeout()), SLOT(refresh()));
connect(m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
m_refreshTimer->start();
// Regular saving of fastresume data
m_resumeDataTimer = new QTimer(this);
m_resumeDataTimer->setInterval(saveResumeDataInterval() * 60 * 1000);
connect(m_resumeDataTimer, SIGNAL(timeout()), SLOT(generateResumeData()));
connect(m_resumeDataTimer, &QTimer::timeout, this, [this]() { generateResumeData(); });
m_statistics = new Statistics(this);
@ -519,7 +522,7 @@ Session::Session(QObject *parent) @@ -519,7 +522,7 @@ Session::Session(QObject *parent)
m_ioThread = new QThread(this);
m_resumeDataSavingManager = new ResumeDataSavingManager(m_resumeFolderPath);
m_resumeDataSavingManager->moveToThread(m_ioThread);
connect(m_ioThread, SIGNAL(finished()), m_resumeDataSavingManager, SLOT(deleteLater()));
connect(m_ioThread, &QThread::finished, m_resumeDataSavingManager, &QObject::deleteLater);
m_ioThread->start();
m_resumeDataTimer->start();

Loading…
Cancel
Save