mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Randomize the listening port only on startup.
This commit is contained in:
parent
2c90ded9aa
commit
153f3328f3
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
Preferences* Preferences::m_instance = 0;
|
Preferences* Preferences::m_instance = 0;
|
||||||
|
|
||||||
Preferences::Preferences() : dirty(false), lock(QReadWriteLock::Recursive) {
|
Preferences::Preferences() : m_randomPort(rand() % 64512 + 1024), dirty(false), lock(QReadWriteLock::Recursive) {
|
||||||
QIniSettings *settings = new QIniSettings;
|
QIniSettings *settings = new QIniSettings;
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
QIniSettings *settings_new = new QIniSettings("qBittorrent", "qBittorrent_new");
|
QIniSettings *settings_new = new QIniSettings("qBittorrent", "qBittorrent_new");
|
||||||
@ -537,6 +537,9 @@ void Preferences::setActionOnDblClOnTorrentFn(int act) {
|
|||||||
|
|
||||||
// Connection options
|
// Connection options
|
||||||
int Preferences::getSessionPort() const {
|
int Preferences::getSessionPort() const {
|
||||||
|
QReadLocker locker(&lock);
|
||||||
|
if (useRandomPort())
|
||||||
|
return m_randomPort;
|
||||||
return value("Preferences/Connection/PortRangeMin", 6881).toInt();
|
return value("Preferences/Connection/PortRangeMin", 6881).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ private:
|
|||||||
explicit Preferences();
|
explicit Preferences();
|
||||||
static Preferences* m_instance;
|
static Preferences* m_instance;
|
||||||
QHash<QString, QVariant> m_data;
|
QHash<QString, QVariant> m_data;
|
||||||
|
int m_randomPort;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
mutable QReadWriteLock lock;
|
mutable QReadWriteLock lock;
|
||||||
|
@ -309,9 +309,6 @@ void QBtSession::setQueueingEnabled(bool enable) {
|
|||||||
void QBtSession::configureSession() {
|
void QBtSession::configureSession() {
|
||||||
qDebug("Configuring session");
|
qDebug("Configuring session");
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
if (pref->useRandomPort()) {
|
|
||||||
pref->setSessionPort(rand() % USHRT_MAX + 1025);
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned short old_listenPort = getListenPort();
|
const unsigned short old_listenPort = getListenPort();
|
||||||
const unsigned short new_listenPort = pref->getSessionPort();
|
const unsigned short new_listenPort = pref->getSessionPort();
|
||||||
|
Loading…
Reference in New Issue
Block a user