|
|
@ -115,6 +115,7 @@ QBtSession::QBtSession() |
|
|
|
, m_tracker(0), m_shutdownAct(NO_SHUTDOWN), |
|
|
|
, m_tracker(0), m_shutdownAct(NO_SHUTDOWN), |
|
|
|
m_upnp(0), m_natpmp(0), m_dynDNSUpdater(0) |
|
|
|
m_upnp(0), m_natpmp(0), m_dynDNSUpdater(0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
setRandomPortset(false); |
|
|
|
BigRatioTimer = new QTimer(this); |
|
|
|
BigRatioTimer = new QTimer(this); |
|
|
|
BigRatioTimer->setInterval(10000); |
|
|
|
BigRatioTimer->setInterval(10000); |
|
|
|
connect(BigRatioTimer, SIGNAL(timeout()), SLOT(processBigRatios())); |
|
|
|
connect(BigRatioTimer, SIGNAL(timeout()), SLOT(processBigRatios())); |
|
|
@ -281,17 +282,32 @@ void QBtSession::setQueueingEnabled(bool enable) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QBtSession::setRandomPortset(bool set) { |
|
|
|
|
|
|
|
randomPortSet = set; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set BT session configuration
|
|
|
|
// Set BT session configuration
|
|
|
|
void QBtSession::configureSession() { |
|
|
|
void QBtSession::configureSession() { |
|
|
|
qDebug("Configuring session"); |
|
|
|
qDebug("Configuring session"); |
|
|
|
const Preferences pref; |
|
|
|
//removed the constant modifier for Preferences
|
|
|
|
// * Ports binding
|
|
|
|
Preferences pref; |
|
|
|
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(); |
|
|
|
if (old_listenPort != new_listenPort) { |
|
|
|
if(pref.useRandomPort() && !isRandomPortset()) { // to check if the randomPort checkbox is selected
|
|
|
|
qDebug("Session port changes in program preferences: %d -> %d", old_listenPort, new_listenPort); |
|
|
|
setRandomPortset(true); |
|
|
|
setListeningPort(new_listenPort); |
|
|
|
srand(time(0)); |
|
|
|
|
|
|
|
const unsigned short randomPort = rand() % USHRT_MAX + 1025; |
|
|
|
|
|
|
|
setListeningPort(randomPort); |
|
|
|
addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg(QString::number(getListenPort()))); |
|
|
|
addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg(QString::number(getListenPort()))); |
|
|
|
|
|
|
|
pref.setSessionPort(randomPort); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// * Ports binding
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (old_listenPort != new_listenPort) { |
|
|
|
|
|
|
|
qDebug("Session port changes in program preferences: %d -> %d", old_listenPort, new_listenPort); |
|
|
|
|
|
|
|
setListeningPort(new_listenPort); |
|
|
|
|
|
|
|
addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg(QString::number(getListenPort()))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Downloads
|
|
|
|
// Downloads
|
|
|
@ -1519,7 +1535,7 @@ void QBtSession::loadSessionState() { |
|
|
|
// bdecode
|
|
|
|
// bdecode
|
|
|
|
lazy_entry e; |
|
|
|
lazy_entry e; |
|
|
|
#if LIBTORRENT_VERSION_NUM >= 001600 |
|
|
|
#if LIBTORRENT_VERSION_NUM >= 001600 |
|
|
|
libtorrent::error_code ec; |
|
|
|
error_code ec; |
|
|
|
lazy_bdecode(&in[0], &in[0] + in.size(), e, ec); |
|
|
|
lazy_bdecode(&in[0], &in[0] + in.size(), e, ec); |
|
|
|
if (!ec) { |
|
|
|
if (!ec) { |
|
|
|
#else |
|
|
|
#else |
|
|
@ -1903,7 +1919,7 @@ void QBtSession::setListeningPort(int port) { |
|
|
|
Preferences pref; |
|
|
|
Preferences pref; |
|
|
|
std::pair<int,int> ports(port, port); |
|
|
|
std::pair<int,int> ports(port, port); |
|
|
|
#if LIBTORRENT_VERSION_NUM >= 001600 |
|
|
|
#if LIBTORRENT_VERSION_NUM >= 001600 |
|
|
|
libtorrent::error_code ec; |
|
|
|
error_code ec; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
const QString iface_name = pref.getNetworkInterface(); |
|
|
|
const QString iface_name = pref.getNetworkInterface(); |
|
|
|
if (iface_name.isEmpty()) { |
|
|
|
if (iface_name.isEmpty()) { |
|
|
|