diff --git a/src/core/bittorrent/session.cpp b/src/core/bittorrent/session.cpp
index ad64966e0..873d994a8 100644
--- a/src/core/bittorrent/session.cpp
+++ b/src/core/bittorrent/session.cpp
@@ -1828,35 +1828,40 @@ void Session::setProxySettings(libt::proxy_settings proxySettings)
proxySettings.proxy_peer_connections = Preferences::instance()->proxyPeerConnections();
m_nativeSession->set_proxy(proxySettings);
- // Define environment variable
- QString proxy_str;
- switch(proxySettings.type) {
- case libt::proxy_settings::http_pw:
- proxy_str = QString("http://%1:%2@%3:%4").arg(Utils::String::fromStdString(proxySettings.username)).arg(Utils::String::fromStdString(proxySettings.password))
- .arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
- break;
- case libt::proxy_settings::http:
- proxy_str = QString("http://%1:%2").arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
- break;
- case libt::proxy_settings::socks5:
- proxy_str = QString("%1:%2").arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
- break;
- case libt::proxy_settings::socks5_pw:
- proxy_str = QString("%1:%2@%3:%4").arg(Utils::String::fromStdString(proxySettings.username)).arg(Utils::String::fromStdString(proxySettings.password))
- .arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
- break;
- default:
- qDebug("Disabling HTTP communications proxy");
+ // Define environment variable for urllib in search engine plugins
+ if (Preferences::instance()->isProxyOnlyForTorrents()) {
qputenv("http_proxy", QByteArray());
qputenv("sock_proxy", QByteArray());
- return;
}
- // We need this for urllib in search engine plugins
- qDebug("HTTP communications proxy string: %s", qPrintable(proxy_str));
- if ((proxySettings.type == libt::proxy_settings::socks5) || (proxySettings.type == libt::proxy_settings::socks5_pw))
- qputenv("sock_proxy", proxy_str.toLocal8Bit());
- else
- qputenv("http_proxy", proxy_str.toLocal8Bit());
+ else {
+ QString proxy_str;
+ switch(proxySettings.type) {
+ case libt::proxy_settings::http_pw:
+ proxy_str = QString("http://%1:%2@%3:%4").arg(Utils::String::fromStdString(proxySettings.username)).arg(Utils::String::fromStdString(proxySettings.password))
+ .arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
+ break;
+ case libt::proxy_settings::http:
+ proxy_str = QString("http://%1:%2").arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
+ break;
+ case libt::proxy_settings::socks5:
+ proxy_str = QString("%1:%2").arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
+ break;
+ case libt::proxy_settings::socks5_pw:
+ proxy_str = QString("%1:%2@%3:%4").arg(Utils::String::fromStdString(proxySettings.username)).arg(Utils::String::fromStdString(proxySettings.password))
+ .arg(Utils::String::fromStdString(proxySettings.hostname)).arg(proxySettings.port);
+ break;
+ default:
+ qDebug("Disabling HTTP communications proxy");
+ qputenv("http_proxy", QByteArray());
+ qputenv("sock_proxy", QByteArray());
+ return;
+ }
+ qDebug("HTTP communications proxy string: %s", qPrintable(proxy_str));
+ if ((proxySettings.type == libt::proxy_settings::socks5) || (proxySettings.type == libt::proxy_settings::socks5_pw))
+ qputenv("sock_proxy", proxy_str.toLocal8Bit());
+ else
+ qputenv("http_proxy", proxy_str.toLocal8Bit());
+ }
}
// Will resume torrents in backup directory
diff --git a/src/core/net/downloadmanager.cpp b/src/core/net/downloadmanager.cpp
index 4e1ff2047..7aed502c7 100644
--- a/src/core/net/downloadmanager.cpp
+++ b/src/core/net/downloadmanager.cpp
@@ -110,7 +110,7 @@ void DownloadManager::applyProxySettings()
QNetworkProxy proxy;
const Preferences* const pref = Preferences::instance();
- if (pref->isProxyEnabled()) {
+ if (pref->isProxyEnabled() && !pref->isProxyOnlyForTorrents()) {
// Proxy enabled
proxy.setHostName(pref->getProxyIp());
proxy.setPort(pref->getProxyPort());
diff --git a/src/core/preferences.cpp b/src/core/preferences.cpp
index c37719cbf..990d9f0c2 100644
--- a/src/core/preferences.cpp
+++ b/src/core/preferences.cpp
@@ -832,6 +832,16 @@ void Preferences::setForceProxy(bool enabled)
setValue("Preferences/Connection/ProxyForce", enabled);
}
+void Preferences::setProxyOnlyForTorrents(bool enabled)
+{
+ setValue("Preferences/Connection/ProxyOnlyForTorrents", enabled);
+}
+
+bool Preferences::isProxyOnlyForTorrents() const
+{
+ return value("Preferences/Connection/ProxyOnlyForTorrents", false).toBool();
+}
+
// Bittorrent options
int Preferences::getMaxConnecs() const
{
diff --git a/src/core/preferences.h b/src/core/preferences.h
index b44179a5d..0024bb78f 100644
--- a/src/core/preferences.h
+++ b/src/core/preferences.h
@@ -246,6 +246,8 @@ public:
void setProxyPeerConnections(bool enabled);
bool getForceProxy() const;
void setForceProxy(bool enabled);
+ void setProxyOnlyForTorrents(bool enabled);
+ bool isProxyOnlyForTorrents() const;
// Bittorrent options
int getMaxConnecs() const;
diff --git a/src/gui/options.ui b/src/gui/options.ui
index 5bdfc2fa9..48d0db07b 100644
--- a/src/gui/options.ui
+++ b/src/gui/options.ui
@@ -1374,6 +1374,19 @@
+ -
+
+
+ Use proxy only for torrents
+
+
+ RSS feeds, search engine, software updates or anything else other than torrent transfers and related operations (such as peer exchanges) will use a direct connection
+
+
+ false
+
+
+
-
diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp
index 24b7a9533..543aa85ce 100644
--- a/src/gui/options_imp.cpp
+++ b/src/gui/options_imp.cpp
@@ -233,6 +233,7 @@ options_imp::options_imp(QWidget *parent):
connect(spinProxyPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkProxyPeerConnecs, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
connect(checkForceProxy, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
+ connect(isProxyOnlyForTorrents, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
connect(checkProxyAuth, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(textProxyUsername, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textProxyPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
@@ -441,6 +442,7 @@ void options_imp::saveOptions() {
pref->setProxyPort(getProxyPort());
pref->setProxyPeerConnections(checkProxyPeerConnecs->isChecked());
pref->setForceProxy(checkForceProxy->isChecked());
+ pref->setProxyOnlyForTorrents(isProxyOnlyForTorrents->isChecked());
pref->setProxyAuthEnabled(isProxyAuthEnabled());
pref->setProxyUsername(getProxyUsername());
pref->setProxyPassword(getProxyPassword());
@@ -694,6 +696,7 @@ void options_imp::loadOptions() {
spinProxyPort->setValue(pref->getProxyPort());
checkProxyPeerConnecs->setChecked(pref->proxyPeerConnections());
checkForceProxy->setChecked(pref->getForceProxy());
+ isProxyOnlyForTorrents->setChecked(pref->isProxyOnlyForTorrents());
checkProxyAuth->setChecked(pref->isProxyAuthEnabled());
textProxyUsername->setText(pref->getProxyUsername());
textProxyPassword->setText(pref->getProxyPassword());
@@ -996,6 +999,7 @@ void options_imp::enableProxy(int index) {
spinProxyPort->setEnabled(true);
checkProxyPeerConnecs->setEnabled(true);
checkForceProxy->setEnabled(true);
+ isProxyOnlyForTorrents->setEnabled(true);
if (index > 1) {
checkProxyAuth->setEnabled(true);
} else {
@@ -1010,6 +1014,7 @@ void options_imp::enableProxy(int index) {
spinProxyPort->setEnabled(false);
checkProxyPeerConnecs->setEnabled(false);
checkForceProxy->setEnabled(false);
+ isProxyOnlyForTorrents->setEnabled(false);
checkProxyAuth->setEnabled(false);
checkProxyAuth->setChecked(false);
}