mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 21:38:51 +03:00
FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port
This commit is contained in:
parent
aec3087528
commit
da32321f10
6 changed files with 85 additions and 57 deletions
|
@ -1,6 +1,7 @@
|
|||
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.8.0
|
||||
- FEATURE: Added support for secure SMTP connection (SSL)
|
||||
- FEATURE: Added support for SMTP authentication
|
||||
- FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port
|
||||
- BUGFIX: Change systray icon on the fly (no restart needed)
|
||||
- COSMETIC: Added monochrome icon for light themes
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<width>489</width>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -493,7 +493,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<width>489</width>
|
||||
<height>849</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -963,7 +963,7 @@ QGroupBox {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<width>489</width>
|
||||
<height>456</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -1406,7 +1406,7 @@ QGroupBox {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>518</width>
|
||||
<width>504</width>
|
||||
<height>384</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -1784,8 +1784,8 @@ QGroupBox {
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-24</y>
|
||||
<width>503</width>
|
||||
<y>0</y>
|
||||
<width>496</width>
|
||||
<height>408</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -2161,7 +2161,7 @@ QGroupBox {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>518</width>
|
||||
<width>504</width>
|
||||
<height>384</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -2179,11 +2179,7 @@ QGroupBox {
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupWebUiServer">
|
||||
<property name="title">
|
||||
<string>HTTP Server</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblWebUiPort">
|
||||
<property name="text">
|
||||
|
@ -2218,6 +2214,15 @@ QGroupBox {
|
|||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkWebUIUPnP">
|
||||
<property name="text">
|
||||
<string>Use UPnP / NAT-PMP to forward the port from my router</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -2310,8 +2315,8 @@ QGroupBox {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>518</width>
|
||||
<height>384</height>
|
||||
<width>86</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_36"/>
|
||||
|
|
|
@ -199,6 +199,7 @@ options_imp::options_imp(QWidget *parent):
|
|||
// Web UI tab
|
||||
connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(spinWebUiPort, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton()));
|
||||
connect(checkWebUIUPnP, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
|
||||
connect(textWebUiUsername, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||
connect(textWebUiPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||
connect(checkBypassLocalAuth, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
|
@ -422,6 +423,7 @@ void options_imp::saveOptions(){
|
|||
if(isWebUiEnabled())
|
||||
{
|
||||
pref.setWebUiPort(webUiPort());
|
||||
pref.setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
|
||||
pref.setWebUiUsername(webUiUsername());
|
||||
// FIXME: Check that the password is valid (not empty at least)
|
||||
pref.setWebUiPassword(webUiPassword());
|
||||
|
@ -660,6 +662,7 @@ void options_imp::loadOptions(){
|
|||
// Web UI
|
||||
checkWebUi->setChecked(pref.isWebUiEnabled());
|
||||
spinWebUiPort->setValue(pref.getWebUiPort());
|
||||
checkWebUIUPnP->setChecked(pref.useUPnPForWebUIPort());
|
||||
textWebUiUsername->setText(pref.getWebUiUsername());
|
||||
textWebUiPassword->setText(pref.getWebUiPassword());
|
||||
checkBypassLocalAuth->setChecked(!pref.isWebUiLocalAuthEnabled());
|
||||
|
|
|
@ -706,6 +706,14 @@ public:
|
|||
setValue("Preferences/WebUI/Port", port);
|
||||
}
|
||||
|
||||
bool useUPnPForWebUIPort() const {
|
||||
return value("Preferences/WebUI/UseUPnP", true).toBool();
|
||||
}
|
||||
|
||||
void setUPnPForWebUIPort(bool enabled) {
|
||||
setValue("Preferences/WebUI/UseUPnP", enabled);
|
||||
}
|
||||
|
||||
QString getWebUiUsername() const {
|
||||
return value("Preferences/WebUI/Username", "admin").toString();
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
#include <libtorrent/alert_types.hpp>
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include <libtorrent/version.hpp>
|
||||
#include <libtorrent/upnp.hpp>
|
||||
#include <libtorrent/natpmp.hpp>
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
@ -89,13 +91,14 @@ enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL };
|
|||
QBtSession::QBtSession()
|
||||
: m_scanFolders(ScanFoldersModel::instance(this)),
|
||||
preAllocateAll(false), addInPause(false), global_ratio_limit(-1),
|
||||
UPnPEnabled(false), LSDEnabled(false),
|
||||
LSDEnabled(false),
|
||||
DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
|
||||
torrentExport(false)
|
||||
#ifndef DISABLE_GUI
|
||||
, geoipDBLoaded(false), resolve_countries(false)
|
||||
#endif
|
||||
, m_tracker(0), m_shutdownAct(NO_SHUTDOWN)
|
||||
, m_tracker(0), m_shutdownAct(NO_SHUTDOWN),
|
||||
m_upnp(0), m_natpmp(0)
|
||||
{
|
||||
BigRatioTimer = new QTimer(this);
|
||||
BigRatioTimer->setInterval(10000);
|
||||
|
@ -1324,19 +1327,26 @@ void QBtSession::setMaxUploadsPerTorrent(int max) {
|
|||
}
|
||||
|
||||
void QBtSession::enableUPnP(bool b) {
|
||||
Preferences pref;
|
||||
if(b) {
|
||||
if(!UPnPEnabled) {
|
||||
if(!m_upnp) {
|
||||
qDebug("Enabling UPnP / NAT-PMP");
|
||||
s->start_upnp();
|
||||
s->start_natpmp();
|
||||
UPnPEnabled = true;
|
||||
m_upnp = s->start_upnp();
|
||||
m_natpmp = s->start_natpmp();
|
||||
}
|
||||
// Use UPnP/NAT-PMP for Web UI too
|
||||
if(pref.isWebUiEnabled() && pref.useUPnPForWebUIPort()) {
|
||||
const qint16 port = pref.getWebUiPort();
|
||||
m_upnp->add_mapping(upnp::tcp, port, port);
|
||||
m_natpmp->add_mapping(natpmp::tcp, port, port);
|
||||
}
|
||||
} else {
|
||||
if(UPnPEnabled) {
|
||||
if(m_upnp) {
|
||||
qDebug("Disabling UPnP / NAT-PMP");
|
||||
s->stop_upnp();
|
||||
s->stop_natpmp();
|
||||
UPnPEnabled = false;
|
||||
m_upnp = 0;
|
||||
m_natpmp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,6 @@ private:
|
|||
bool addInPause;
|
||||
qreal global_ratio_limit;
|
||||
int high_ratio_action;
|
||||
bool UPnPEnabled;
|
||||
bool LSDEnabled;
|
||||
bool DHTEnabled;
|
||||
int current_dht_port;
|
||||
|
@ -269,7 +268,9 @@ private:
|
|||
QPointer<QTracker> m_tracker;
|
||||
TorrentSpeedMonitor *m_speedMonitor;
|
||||
shutDownAction m_shutdownAct;
|
||||
|
||||
// Port forwarding
|
||||
libtorrent::upnp *m_upnp;
|
||||
libtorrent::natpmp *m_natpmp;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue