mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 22:37:59 +00:00
Allow to use proxy per subsystem
This commit is contained in:
parent
4745a40f0b
commit
6ac14d0c57
@ -44,7 +44,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
const int MIGRATION_VERSION = 5;
|
||||
const int MIGRATION_VERSION = 6;
|
||||
const QString MIGRATION_VERSION_KEY = u"Meta/MigrationVersion"_qs;
|
||||
|
||||
void exportWebUIHttpsFiles()
|
||||
@ -343,7 +343,7 @@ namespace
|
||||
switch (number)
|
||||
{
|
||||
case 0:
|
||||
settingsStorage->storeValue(key, Net::ProxyType::None);
|
||||
settingsStorage->storeValue(key, u"None"_qs);
|
||||
break;
|
||||
case 1:
|
||||
settingsStorage->storeValue(key, Net::ProxyType::HTTP);
|
||||
@ -352,10 +352,10 @@ namespace
|
||||
settingsStorage->storeValue(key, Net::ProxyType::SOCKS5);
|
||||
break;
|
||||
case 3:
|
||||
settingsStorage->storeValue(key, Net::ProxyType::HTTP_PW);
|
||||
settingsStorage->storeValue(key, u"HTTP_PW"_qs);
|
||||
break;
|
||||
case 4:
|
||||
settingsStorage->storeValue(key, Net::ProxyType::SOCKS5_PW);
|
||||
settingsStorage->storeValue(key, u"SOCKS5_PW"_qs);
|
||||
break;
|
||||
case 5:
|
||||
settingsStorage->storeValue(key, Net::ProxyType::SOCKS4);
|
||||
@ -369,6 +369,42 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void migrateProxySettings()
|
||||
{
|
||||
auto *settingsStorage = SettingsStorage::instance();
|
||||
const auto proxyType = settingsStorage->loadValue<QString>(u"Network/Proxy/Type"_qs, u"None"_qs);
|
||||
const auto onlyForTorrents = settingsStorage->loadValue<bool>(u"Network/Proxy/OnlyForTorrents"_qs)
|
||||
|| (proxyType == u"SOCKS4");
|
||||
|
||||
if (proxyType == u"None")
|
||||
{
|
||||
settingsStorage->storeValue(u"Network/Proxy/Type"_qs, Net::ProxyType::HTTP);
|
||||
|
||||
settingsStorage->storeValue(u"Network/Proxy/Profiles/BitTorrent"_qs, false);
|
||||
settingsStorage->storeValue(u"Network/Proxy/Profiles/RSS"_qs, false);
|
||||
settingsStorage->storeValue(u"Network/Proxy/Profiles/Misc"_qs, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsStorage->storeValue(u"Network/Proxy/Profiles/BitTorrent"_qs, true);
|
||||
settingsStorage->storeValue(u"Network/Proxy/Profiles/RSS"_qs, !onlyForTorrents);
|
||||
settingsStorage->storeValue(u"Network/Proxy/Profiles/Misc"_qs, !onlyForTorrents);
|
||||
|
||||
if (proxyType == u"HTTP_PW"_qs)
|
||||
{
|
||||
settingsStorage->storeValue(u"Network/Proxy/Type"_qs, Net::ProxyType::HTTP);
|
||||
settingsStorage->storeValue(u"Network/Proxy/AuthEnabled"_qs, true);
|
||||
}
|
||||
else if (proxyType == u"SOCKS5_PW"_qs)
|
||||
{
|
||||
settingsStorage->storeValue(u"Network/Proxy/Type"_qs, Net::ProxyType::SOCKS5);
|
||||
settingsStorage->storeValue(u"Network/Proxy/AuthEnabled"_qs, true);
|
||||
}
|
||||
}
|
||||
|
||||
settingsStorage->removeValue(u"Network/Proxy/OnlyForTorrents"_qs);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
void migrateMemoryPrioritySettings()
|
||||
{
|
||||
@ -442,6 +478,9 @@ bool upgrade()
|
||||
migrateChineseLocale();
|
||||
}
|
||||
|
||||
if (version < 6)
|
||||
migrateProxySettings();
|
||||
|
||||
version = MIGRATION_VERSION;
|
||||
}
|
||||
|
||||
|
@ -1629,37 +1629,40 @@ lt::settings_pack SessionImpl::loadLTSettings() const
|
||||
settingsPack.set_int(lt::settings_pack::active_checking, maxActiveCheckingTorrents());
|
||||
|
||||
// proxy
|
||||
const auto proxyManager = Net::ProxyConfigurationManager::instance();
|
||||
const Net::ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||
|
||||
switch (proxyConfig.type)
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::none);
|
||||
if (Preferences::instance()->useProxyForBT())
|
||||
{
|
||||
case Net::ProxyType::HTTP:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::http);
|
||||
break;
|
||||
case Net::ProxyType::HTTP_PW:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::http_pw);
|
||||
break;
|
||||
case Net::ProxyType::SOCKS4:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::socks4);
|
||||
break;
|
||||
case Net::ProxyType::SOCKS5:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::socks5);
|
||||
break;
|
||||
case Net::ProxyType::SOCKS5_PW:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::socks5_pw);
|
||||
break;
|
||||
case Net::ProxyType::None:
|
||||
default:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::none);
|
||||
}
|
||||
const auto proxyManager = Net::ProxyConfigurationManager::instance();
|
||||
const Net::ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||
|
||||
switch (proxyConfig.type)
|
||||
{
|
||||
case Net::ProxyType::SOCKS4:
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::socks4);
|
||||
break;
|
||||
|
||||
case Net::ProxyType::HTTP:
|
||||
if (proxyConfig.authEnabled)
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::http_pw);
|
||||
else
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::http);
|
||||
break;
|
||||
|
||||
case Net::ProxyType::SOCKS5:
|
||||
if (proxyConfig.authEnabled)
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::socks5_pw);
|
||||
else
|
||||
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::socks5);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (proxyConfig.type != Net::ProxyType::None)
|
||||
{
|
||||
settingsPack.set_str(lt::settings_pack::proxy_hostname, proxyConfig.ip.toStdString());
|
||||
settingsPack.set_int(lt::settings_pack::proxy_port, proxyConfig.port);
|
||||
|
||||
if (proxyManager->isAuthenticationRequired())
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
settingsPack.set_str(lt::settings_pack::proxy_username, proxyConfig.username.toStdString());
|
||||
settingsPack.set_str(lt::settings_pack::proxy_password, proxyConfig.password.toStdString());
|
||||
@ -2493,7 +2496,7 @@ bool SessionImpl::addTorrent(const QString &source, const AddTorrentParams ¶
|
||||
LogMsg(tr("Downloading torrent, please wait... Source: \"%1\"").arg(source));
|
||||
// Launch downloader
|
||||
Net::DownloadManager::instance()->download(Net::DownloadRequest(source).limit(MAX_TORRENT_SIZE)
|
||||
, true, this, &SessionImpl::handleDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes(), this, &SessionImpl::handleDownloadFinished);
|
||||
m_downloadedTorrents[source] = params;
|
||||
return true;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void DNSUpdater::checkPublicIP()
|
||||
|
||||
DownloadManager::instance()->download(
|
||||
DownloadRequest(u"http://checkip.dyndns.org"_qs).userAgent(QStringLiteral("qBittorrent/" QBT_VERSION_2))
|
||||
, true, this, &DNSUpdater::ipRequestFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes(), this, &DNSUpdater::ipRequestFinished);
|
||||
|
||||
m_lastIPCheckTime = QDateTime::currentDateTime();
|
||||
}
|
||||
@ -129,7 +129,7 @@ void DNSUpdater::updateDNSService()
|
||||
m_lastIPCheckTime = QDateTime::currentDateTime();
|
||||
DownloadManager::instance()->download(
|
||||
DownloadRequest(getUpdateUrl()).userAgent(QStringLiteral("qBittorrent/" QBT_VERSION_2))
|
||||
, true, this, &DNSUpdater::ipUpdateFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes(), this, &DNSUpdater::ipUpdateFinished);
|
||||
}
|
||||
|
||||
QString DNSUpdater::getUpdateUrl() const
|
||||
|
@ -119,12 +119,14 @@ Net::DownloadManager *Net::DownloadManager::m_instance = nullptr;
|
||||
Net::DownloadManager::DownloadManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_networkCookieJar {new NetworkCookieJar(this)}
|
||||
, m_networkManager {new QNetworkAccessManager(this)}
|
||||
{
|
||||
m_networkManager->setCookieJar(m_networkCookieJar);
|
||||
connect(m_networkManager, &QNetworkAccessManager::sslErrors, this, &Net::DownloadManager::ignoreSslErrors);
|
||||
|
||||
connect(ProxyConfigurationManager::instance(), &ProxyConfigurationManager::proxyConfigurationChanged
|
||||
, this, &DownloadManager::applyProxySettings);
|
||||
connect(Preferences::instance(), &Preferences::changed, this, &DownloadManager::applyProxySettings);
|
||||
applyProxySettings();
|
||||
}
|
||||
|
||||
@ -224,10 +226,10 @@ void Net::DownloadManager::applyProxySettings()
|
||||
|
||||
m_proxy = QNetworkProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
if (!proxyManager->isProxyOnlyForTorrents() && (proxyConfig.type != ProxyType::None))
|
||||
if (proxyConfig.type != ProxyType::SOCKS4)
|
||||
{
|
||||
// Proxy enabled
|
||||
if ((proxyConfig.type == ProxyType::SOCKS5) || (proxyConfig.type == ProxyType::SOCKS5_PW))
|
||||
if (proxyConfig.type == ProxyType::SOCKS5)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "using SOCKS proxy";
|
||||
m_proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
@ -242,7 +244,7 @@ void Net::DownloadManager::applyProxySettings()
|
||||
m_proxy.setPort(proxyConfig.port);
|
||||
|
||||
// Authentication?
|
||||
if (proxyManager->isAuthenticationRequired())
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
qDebug("Proxy requires authentication, authenticating...");
|
||||
m_proxy.setUser(proxyConfig.username);
|
||||
|
@ -129,7 +129,9 @@ void GeoIPManager::downloadDatabaseFile()
|
||||
{
|
||||
const QDateTime curDatetime = QDateTime::currentDateTimeUtc();
|
||||
const QString curUrl = DATABASE_URL.arg(QLocale::c().toString(curDatetime, u"yyyy-MM"));
|
||||
DownloadManager::instance()->download({curUrl}, true, this, &GeoIPManager::downloadFinished);
|
||||
DownloadManager::instance()->download(
|
||||
{curUrl}, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &GeoIPManager::downloadFinished);
|
||||
}
|
||||
|
||||
QString GeoIPManager::lookup(const QHostAddress &hostAddr) const
|
||||
|
@ -35,6 +35,7 @@ bool Net::operator==(const ProxyConfiguration &left, const ProxyConfiguration &r
|
||||
return (left.type == right.type)
|
||||
&& (left.ip == right.ip)
|
||||
&& (left.port == right.port)
|
||||
&& (left.authEnabled == right.authEnabled)
|
||||
&& (left.username == right.username)
|
||||
&& (left.password == right.password);
|
||||
}
|
||||
@ -49,19 +50,20 @@ using namespace Net;
|
||||
ProxyConfigurationManager *ProxyConfigurationManager::m_instance = nullptr;
|
||||
|
||||
ProxyConfigurationManager::ProxyConfigurationManager(QObject *parent)
|
||||
: QObject {parent}
|
||||
, m_storeProxyOnlyForTorrents {SETTINGS_KEY(u"OnlyForTorrents"_qs)}
|
||||
: QObject(parent)
|
||||
, m_storeProxyType {SETTINGS_KEY(u"Type"_qs)}
|
||||
, m_storeProxyIP {SETTINGS_KEY(u"IP"_qs)}
|
||||
, m_storeProxyPort {SETTINGS_KEY(u"Port"_qs)}
|
||||
, m_storeProxyAuthEnabled {SETTINGS_KEY(u"AuthEnabled"_qs)}
|
||||
, m_storeProxyUsername {SETTINGS_KEY(u"Username"_qs)}
|
||||
, m_storeProxyPassword {SETTINGS_KEY(u"Password"_qs)}
|
||||
{
|
||||
m_config.type = m_storeProxyType.get(ProxyType::None);
|
||||
if ((m_config.type < ProxyType::None) || (m_config.type > ProxyType::SOCKS4))
|
||||
m_config.type = ProxyType::None;
|
||||
m_config.type = m_storeProxyType.get(ProxyType::HTTP);
|
||||
if ((m_config.type < ProxyType::HTTP) || (m_config.type > ProxyType::SOCKS4))
|
||||
m_config.type = ProxyType::HTTP;
|
||||
m_config.ip = m_storeProxyIP.get(u"0.0.0.0"_qs);
|
||||
m_config.port = m_storeProxyPort.get(8080);
|
||||
m_config.authEnabled = m_storeProxyAuthEnabled;
|
||||
m_config.username = m_storeProxyUsername;
|
||||
m_config.password = m_storeProxyPassword;
|
||||
}
|
||||
@ -96,25 +98,10 @@ void ProxyConfigurationManager::setProxyConfiguration(const ProxyConfiguration &
|
||||
m_storeProxyType = config.type;
|
||||
m_storeProxyIP = config.ip;
|
||||
m_storeProxyPort = config.port;
|
||||
m_storeProxyAuthEnabled = config.authEnabled;
|
||||
m_storeProxyUsername = config.username;
|
||||
m_storeProxyPassword = config.password;
|
||||
|
||||
emit proxyConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool ProxyConfigurationManager::isProxyOnlyForTorrents() const
|
||||
{
|
||||
return m_storeProxyOnlyForTorrents || (m_config.type == ProxyType::SOCKS4);
|
||||
}
|
||||
|
||||
void ProxyConfigurationManager::setProxyOnlyForTorrents(const bool onlyForTorrents)
|
||||
{
|
||||
m_storeProxyOnlyForTorrents = onlyForTorrents;
|
||||
}
|
||||
|
||||
bool ProxyConfigurationManager::isAuthenticationRequired() const
|
||||
{
|
||||
return m_config.type == ProxyType::SOCKS5_PW
|
||||
|| m_config.type == ProxyType::HTTP_PW;
|
||||
}
|
||||
|
@ -39,20 +39,18 @@ namespace Net
|
||||
|
||||
enum class ProxyType
|
||||
{
|
||||
None = 0,
|
||||
HTTP = 1,
|
||||
SOCKS5 = 2,
|
||||
HTTP_PW = 3,
|
||||
SOCKS5_PW = 4,
|
||||
SOCKS4 = 5
|
||||
};
|
||||
Q_ENUM_NS(ProxyType)
|
||||
|
||||
struct ProxyConfiguration
|
||||
{
|
||||
ProxyType type = ProxyType::None;
|
||||
ProxyType type = ProxyType::HTTP;
|
||||
QString ip = u"0.0.0.0"_qs;
|
||||
ushort port = 8080;
|
||||
bool authEnabled = false;
|
||||
QString username;
|
||||
QString password;
|
||||
};
|
||||
@ -74,10 +72,6 @@ namespace Net
|
||||
|
||||
ProxyConfiguration proxyConfiguration() const;
|
||||
void setProxyConfiguration(const ProxyConfiguration &config);
|
||||
bool isProxyOnlyForTorrents() const;
|
||||
void setProxyOnlyForTorrents(bool onlyForTorrents);
|
||||
|
||||
bool isAuthenticationRequired() const;
|
||||
|
||||
signals:
|
||||
void proxyConfigurationChanged();
|
||||
@ -85,10 +79,10 @@ namespace Net
|
||||
private:
|
||||
static ProxyConfigurationManager *m_instance;
|
||||
ProxyConfiguration m_config;
|
||||
SettingValue<bool> m_storeProxyOnlyForTorrents;
|
||||
SettingValue<ProxyType> m_storeProxyType;
|
||||
SettingValue<QString> m_storeProxyIP;
|
||||
SettingValue<ushort> m_storeProxyPort;
|
||||
SettingValue<bool> m_storeProxyAuthEnabled;
|
||||
SettingValue<QString> m_storeProxyUsername;
|
||||
SettingValue<QString> m_storeProxyPassword;
|
||||
};
|
||||
|
@ -1619,6 +1619,37 @@ void Preferences::setNetworkCookies(const QList<QNetworkCookie> &cookies)
|
||||
setValue(u"Network/Cookies"_qs, rawCookies);
|
||||
}
|
||||
|
||||
bool Preferences::useProxyForBT() const
|
||||
{
|
||||
return value<bool>(u"Network/Proxy/Profiles/BitTorrent"_qs);
|
||||
}
|
||||
|
||||
void Preferences::setUseProxyForBT(const bool value)
|
||||
{
|
||||
setValue(u"Network/Proxy/Profiles/BitTorrent"_qs, value);
|
||||
}
|
||||
|
||||
bool Preferences::useProxyForRSS() const
|
||||
{
|
||||
return value<bool>(u"Network/Proxy/Profiles/RSS"_qs);
|
||||
}
|
||||
|
||||
void Preferences::setUseProxyForRSS(const bool value)
|
||||
{
|
||||
setValue(u"Network/Proxy/Profiles/RSS"_qs, value);
|
||||
}
|
||||
|
||||
bool Preferences::useProxyForGeneralPurposes() const
|
||||
{
|
||||
return value<bool>(u"Network/Proxy/Profiles/Misc"_qs);
|
||||
}
|
||||
|
||||
|
||||
void Preferences::setUseProxyForGeneralPurposes(const bool value)
|
||||
{
|
||||
setValue(u"Network/Proxy/Profiles/Misc"_qs, value);
|
||||
}
|
||||
|
||||
bool Preferences::isSpeedWidgetEnabled() const
|
||||
{
|
||||
return value(u"SpeedWidget/Enabled"_qs, true);
|
||||
|
@ -397,6 +397,13 @@ public:
|
||||
QList<QNetworkCookie> getNetworkCookies() const;
|
||||
void setNetworkCookies(const QList<QNetworkCookie> &cookies);
|
||||
|
||||
bool useProxyForBT() const;
|
||||
void setUseProxyForBT(bool value);
|
||||
bool useProxyForRSS() const;
|
||||
void setUseProxyForRSS(bool value);
|
||||
bool useProxyForGeneralPurposes() const;
|
||||
void setUseProxyForGeneralPurposes(bool value);
|
||||
|
||||
// SpeedWidget
|
||||
bool isSpeedWidgetEnabled() const;
|
||||
void setSpeedWidgetEnabled(bool enabled);
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/profile.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "feed_serializer.h"
|
||||
@ -148,7 +149,7 @@ void Feed::refresh()
|
||||
|
||||
// NOTE: Should we allow manually refreshing for disabled session?
|
||||
|
||||
m_downloadHandler = Net::DownloadManager::instance()->download(m_url, true);
|
||||
m_downloadHandler = Net::DownloadManager::instance()->download(m_url, Preferences::instance()->useProxyForRSS());
|
||||
connect(m_downloadHandler, &Net::DownloadHandler::finished, this, &Feed::handleDownloadFinished);
|
||||
|
||||
if (!m_iconPath.exists())
|
||||
@ -378,7 +379,7 @@ void Feed::downloadIcon()
|
||||
const auto iconUrl = u"%1://%2/favicon.ico"_qs.arg(url.scheme(), url.host());
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(iconUrl).saveToFile(true).destFileName(m_iconPath)
|
||||
, true, this, &Feed::handleIconDownloadFinished);
|
||||
, Preferences::instance()->useProxyForRSS(), this, &Feed::handleIconDownloadFinished);
|
||||
}
|
||||
|
||||
int Feed::updateArticles(const QList<QVariantHash> &loadedArticles)
|
||||
|
@ -94,6 +94,8 @@ SearchPluginManager::SearchPluginManager()
|
||||
|
||||
connect(Net::ProxyConfigurationManager::instance(), &Net::ProxyConfigurationManager::proxyConfigurationChanged
|
||||
, this, &SearchPluginManager::applyProxySettings);
|
||||
connect(Preferences::instance(), &Preferences::changed
|
||||
, this, &SearchPluginManager::applyProxySettings);
|
||||
applyProxySettings();
|
||||
|
||||
updateNova();
|
||||
@ -213,7 +215,8 @@ void SearchPluginManager::installPlugin(const QString &source)
|
||||
{
|
||||
using namespace Net;
|
||||
DownloadManager::instance()->download(DownloadRequest(source).saveToFile(true)
|
||||
, true, this, &SearchPluginManager::pluginDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &SearchPluginManager::pluginDownloadFinished);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -329,7 +332,8 @@ void SearchPluginManager::checkForUpdates()
|
||||
// Download version file from update server
|
||||
using namespace Net;
|
||||
DownloadManager::instance()->download({m_updateUrl + u"versions.txt"}
|
||||
, true, this, &SearchPluginManager::versionInfoDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &SearchPluginManager::versionInfoDownloadFinished);
|
||||
}
|
||||
|
||||
SearchDownloadHandler *SearchPluginManager::downloadTorrent(const QString &siteUrl, const QString &url)
|
||||
@ -391,31 +395,40 @@ void SearchPluginManager::applyProxySettings()
|
||||
|
||||
// Define environment variables for urllib in search engine plugins
|
||||
QString proxyStrHTTP, proxyStrSOCK;
|
||||
if (!proxyManager->isProxyOnlyForTorrents())
|
||||
if (Preferences::instance()->useProxyForGeneralPurposes())
|
||||
{
|
||||
switch (proxyConfig.type)
|
||||
{
|
||||
case Net::ProxyType::HTTP_PW:
|
||||
proxyStrHTTP = u"http://%1:%2@%3:%4"_qs.arg(proxyConfig.username
|
||||
, proxyConfig.password, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
break;
|
||||
case Net::ProxyType::HTTP:
|
||||
proxyStrHTTP = u"http://%1:%2"_qs.arg(proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
proxyStrHTTP = u"http://%1:%2@%3:%4"_qs.arg(proxyConfig.username
|
||||
, proxyConfig.password, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyStrHTTP = u"http://%1:%2"_qs.arg(proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
break;
|
||||
|
||||
case Net::ProxyType::SOCKS5:
|
||||
proxyStrSOCK = u"%1:%2"_qs.arg(proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
break;
|
||||
case Net::ProxyType::SOCKS5_PW:
|
||||
proxyStrSOCK = u"%1:%2@%3:%4"_qs.arg(proxyConfig.username
|
||||
, proxyConfig.password, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
proxyStrSOCK = u"%1:%2@%3:%4"_qs.arg(proxyConfig.username
|
||||
, proxyConfig.password, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyStrSOCK = u"%1:%2"_qs.arg(proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
qDebug("Disabling HTTP communications proxy");
|
||||
}
|
||||
|
||||
qDebug("HTTP communications proxy string: %s"
|
||||
, qUtf8Printable((proxyConfig.type == Net::ProxyType::SOCKS5) || (proxyConfig.type == Net::ProxyType::SOCKS5_PW)
|
||||
? proxyStrSOCK : proxyStrHTTP));
|
||||
, qUtf8Printable((proxyConfig.type == Net::ProxyType::SOCKS5) ? proxyStrSOCK : proxyStrHTTP));
|
||||
}
|
||||
|
||||
qputenv("http_proxy", proxyStrHTTP.toLocal8Bit());
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "base/bittorrent/torrentcontentlayout.h"
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/settingsstorage.h"
|
||||
#include "base/torrentfileguard.h"
|
||||
#include "base/utils/compare.h"
|
||||
@ -481,7 +482,8 @@ void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorre
|
||||
// Launch downloader
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(source).limit(MAX_TORRENT_SIZE)
|
||||
, true, dlg, &AddNewTorrentDialog::handleDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, dlg, &AddNewTorrentDialog::handleDownloadFinished);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1949,7 +1949,8 @@ void MainWindow::installPython()
|
||||
#endif
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(installerURL).saveToFile(true)
|
||||
, true, this, &MainWindow::pythonDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &MainWindow::pythonDownloadFinished);
|
||||
}
|
||||
|
||||
void MainWindow::pythonDownloadFinished(const Net::DownloadResult &result)
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "base/rss/rss_session.h"
|
||||
#include "base/torrentfileguard.h"
|
||||
#include "base/torrentfileswatcher.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "base/utils/password.h"
|
||||
@ -770,42 +769,25 @@ void OptionsDialog::loadConnectionTabOptions()
|
||||
}
|
||||
|
||||
const auto *proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||||
Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
|
||||
using Net::ProxyType;
|
||||
bool useProxyAuth = false;
|
||||
switch (proxyConf.type)
|
||||
{
|
||||
case ProxyType::SOCKS4:
|
||||
m_ui->comboProxyType->setCurrentIndex(1);
|
||||
break;
|
||||
const Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
|
||||
|
||||
case ProxyType::SOCKS5_PW:
|
||||
useProxyAuth = true;
|
||||
// fallthrough
|
||||
case ProxyType::SOCKS5:
|
||||
m_ui->comboProxyType->setCurrentIndex(2);
|
||||
break;
|
||||
m_ui->comboProxyType->addItem(tr("SOCKS4"), QVariant::fromValue(Net::ProxyType::SOCKS4));
|
||||
m_ui->comboProxyType->addItem(tr("SOCKS5"), QVariant::fromValue(Net::ProxyType::SOCKS5));
|
||||
m_ui->comboProxyType->addItem(tr("HTTP"), QVariant::fromValue(Net::ProxyType::HTTP));
|
||||
m_ui->comboProxyType->setCurrentIndex(m_ui->comboProxyType->findData(QVariant::fromValue(proxyConf.type)));
|
||||
adjustProxyOptions();
|
||||
|
||||
case ProxyType::HTTP_PW:
|
||||
useProxyAuth = true;
|
||||
// fallthrough
|
||||
case ProxyType::HTTP:
|
||||
m_ui->comboProxyType->setCurrentIndex(3);
|
||||
break;
|
||||
|
||||
default:
|
||||
m_ui->comboProxyType->setCurrentIndex(0);
|
||||
}
|
||||
m_ui->textProxyIP->setText(proxyConf.ip);
|
||||
m_ui->spinProxyPort->setValue(proxyConf.port);
|
||||
m_ui->checkProxyAuth->setChecked(useProxyAuth);
|
||||
m_ui->checkProxyAuth->setChecked(proxyConf.authEnabled);
|
||||
m_ui->textProxyUsername->setText(proxyConf.username);
|
||||
m_ui->textProxyPassword->setText(proxyConf.password);
|
||||
|
||||
m_ui->checkProxyBitTorrent->setChecked(Preferences::instance()->useProxyForBT());
|
||||
m_ui->checkProxyPeerConnections->setChecked(session->isProxyPeerConnectionsEnabled());
|
||||
m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyOnlyForTorrents());
|
||||
m_ui->checkProxyHostnameLookup->setChecked(session->isProxyHostnameLookupEnabled());
|
||||
enableProxy(m_ui->comboProxyType->currentIndex());
|
||||
m_ui->checkProxyRSS->setChecked(Preferences::instance()->useProxyForRSS());
|
||||
m_ui->checkProxyMisc->setChecked(Preferences::instance()->useProxyForGeneralPurposes());
|
||||
|
||||
m_ui->checkIPFilter->setChecked(session->isIPFilteringEnabled());
|
||||
m_ui->textFilterPath->setDialogCaption(tr("Choose an IP filter file"));
|
||||
@ -830,14 +812,17 @@ void OptionsDialog::loadConnectionTabOptions()
|
||||
connect(m_ui->spinMaxUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinMaxUploadsPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableProxy);
|
||||
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::adjustProxyOptions);
|
||||
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->textProxyIP, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinProxyPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
connect(m_ui->checkProxyBitTorrent, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkProxyBitTorrent, &QGroupBox::toggled, this, &ThisType::adjustProxyOptions);
|
||||
connect(m_ui->checkProxyPeerConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->isProxyOnlyForTorrents, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkProxyHostnameLookup, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkProxyRSS, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkProxyMisc, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
|
||||
connect(m_ui->checkProxyAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->textProxyUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||
@ -868,11 +853,15 @@ void OptionsDialog::saveConnectionTabOptions() const
|
||||
proxyConf.type = getProxyType();
|
||||
proxyConf.ip = getProxyIp();
|
||||
proxyConf.port = getProxyPort();
|
||||
proxyConf.authEnabled = m_ui->checkProxyAuth->isChecked();
|
||||
proxyConf.username = getProxyUsername();
|
||||
proxyConf.password = getProxyPassword();
|
||||
proxyConfigManager->setProxyOnlyForTorrents(m_ui->isProxyOnlyForTorrents->isChecked());
|
||||
proxyConfigManager->setProxyConfiguration(proxyConf);
|
||||
|
||||
Preferences::instance()->setUseProxyForBT(m_ui->checkProxyBitTorrent->isChecked());
|
||||
Preferences::instance()->setUseProxyForRSS(m_ui->checkProxyRSS->isChecked());
|
||||
Preferences::instance()->setUseProxyForGeneralPurposes(m_ui->checkProxyMisc->isChecked());
|
||||
|
||||
session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnections->isChecked());
|
||||
session->setProxyHostnameLookupEnabled(m_ui->checkProxyHostnameLookup->isChecked());
|
||||
|
||||
@ -1321,21 +1310,7 @@ bool OptionsDialog::isIPFilteringEnabled() const
|
||||
|
||||
Net::ProxyType OptionsDialog::getProxyType() const
|
||||
{
|
||||
switch (m_ui->comboProxyType->currentIndex())
|
||||
{
|
||||
case 1:
|
||||
return Net::ProxyType::SOCKS4;
|
||||
case 2:
|
||||
if (isProxyAuthEnabled())
|
||||
return Net::ProxyType::SOCKS5_PW;
|
||||
return Net::ProxyType::SOCKS5;
|
||||
case 3:
|
||||
if (isProxyAuthEnabled())
|
||||
return Net::ProxyType::HTTP_PW;
|
||||
return Net::ProxyType::HTTP;
|
||||
default:
|
||||
return Net::ProxyType::None;
|
||||
}
|
||||
return m_ui->comboProxyType->currentData().value<Net::ProxyType>();
|
||||
}
|
||||
|
||||
int OptionsDialog::getPort() const
|
||||
@ -1512,41 +1487,29 @@ void OptionsDialog::toggleComboRatioLimitAct()
|
||||
m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked());
|
||||
}
|
||||
|
||||
void OptionsDialog::enableProxy(const int index)
|
||||
void OptionsDialog::adjustProxyOptions()
|
||||
{
|
||||
if (index >= 1)
|
||||
{ // Any proxy type is used
|
||||
//enable
|
||||
m_ui->lblProxyIP->setEnabled(true);
|
||||
m_ui->textProxyIP->setEnabled(true);
|
||||
m_ui->lblProxyPort->setEnabled(true);
|
||||
m_ui->spinProxyPort->setEnabled(true);
|
||||
m_ui->checkProxyPeerConnections->setEnabled(true);
|
||||
if (index >= 2)
|
||||
{ // SOCKS5 or HTTP
|
||||
m_ui->checkProxyAuth->setEnabled(true);
|
||||
m_ui->isProxyOnlyForTorrents->setEnabled(true);
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->checkProxyAuth->setEnabled(false);
|
||||
m_ui->isProxyOnlyForTorrents->setEnabled(false);
|
||||
m_ui->isProxyOnlyForTorrents->setChecked(true);
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(false);
|
||||
}
|
||||
const auto currentProxyType = m_ui->comboProxyType->currentData().value<Net::ProxyType>();
|
||||
const bool isAuthSupported = (currentProxyType != Net::ProxyType::SOCKS4);
|
||||
|
||||
m_ui->checkProxyAuth->setEnabled(isAuthSupported);
|
||||
|
||||
if (currentProxyType == Net::ProxyType::SOCKS4)
|
||||
{
|
||||
m_ui->labelProxyTypeIncompatible->setVisible(true);
|
||||
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(false);
|
||||
m_ui->checkProxyRSS->setEnabled(false);
|
||||
m_ui->checkProxyMisc->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{ // No proxy
|
||||
// disable
|
||||
m_ui->lblProxyIP->setEnabled(false);
|
||||
m_ui->textProxyIP->setEnabled(false);
|
||||
m_ui->lblProxyPort->setEnabled(false);
|
||||
m_ui->spinProxyPort->setEnabled(false);
|
||||
m_ui->checkProxyPeerConnections->setEnabled(false);
|
||||
m_ui->isProxyOnlyForTorrents->setEnabled(false);
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(false);
|
||||
m_ui->checkProxyAuth->setEnabled(false);
|
||||
{
|
||||
// SOCKS5 or HTTP
|
||||
m_ui->labelProxyTypeIncompatible->setVisible(false);
|
||||
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(m_ui->checkProxyBitTorrent->isChecked());
|
||||
m_ui->checkProxyRSS->setEnabled(true);
|
||||
m_ui->checkProxyMisc->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1578,11 +1541,6 @@ bool OptionsDialog::isProxyEnabled() const
|
||||
return m_ui->comboProxyType->currentIndex();
|
||||
}
|
||||
|
||||
bool OptionsDialog::isProxyAuthEnabled() const
|
||||
{
|
||||
return m_ui->checkProxyAuth->isChecked();
|
||||
}
|
||||
|
||||
QString OptionsDialog::getProxyIp() const
|
||||
{
|
||||
return m_ui->textProxyIP->text().trimmed();
|
||||
|
@ -85,7 +85,7 @@ public slots:
|
||||
void showConnectionTab();
|
||||
|
||||
private slots:
|
||||
void enableProxy(int index);
|
||||
void adjustProxyOptions();
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
void applySettings();
|
||||
@ -168,7 +168,6 @@ private:
|
||||
int getMaxSeedingMinutes() const;
|
||||
// Proxy options
|
||||
bool isProxyEnabled() const;
|
||||
bool isProxyAuthEnabled() const;
|
||||
QString getProxyIp() const;
|
||||
unsigned short getProxyPort() const;
|
||||
QString getProxyUsername() const;
|
||||
|
@ -1800,51 +1800,20 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboProxyType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>(None)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SOCKS4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SOCKS5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>HTTP</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboProxyType" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblProxyIP">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="textProxyIP">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="textProxyIP" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblProxyPort">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
@ -1852,9 +1821,6 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinProxyPort">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@ -1869,44 +1835,17 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProxyPeerConnections">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Otherwise, the proxy server is only used for tracker connections</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for peer connections</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="isProxyOnlyForTorrents">
|
||||
<property name="toolTip">
|
||||
<string>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</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy only for torrents</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProxyHostnameLookup">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>If checked, hostname lookups are done via the proxy.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for hostname lookups</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<widget class="QLabel" name="labelProxyTypeIncompatible">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Some options are incompatible with the chosen proxy type!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="checkProxyAuth">
|
||||
<property name="enabled">
|
||||
@ -1960,6 +1899,67 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="checkProxyBitTorrent">
|
||||
<property name="title">
|
||||
<string>Use proxy for BitTorrent purposes</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayoutProxyBitTorrent">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProxyPeerConnections">
|
||||
<property name="toolTip">
|
||||
<string>Otherwise, the proxy server is only used for tracker connections</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for peer connections</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProxyHostnameLookup">
|
||||
<property name="toolTip">
|
||||
<string>If checked, hostname lookups are done via the proxy</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for hostname lookups</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProxyRSS">
|
||||
<property name="toolTip">
|
||||
<string>RSS feeds will use proxy</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for RSS purposes</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProxyMisc">
|
||||
<property name="toolTip">
|
||||
<string>Search engine, software updates or anything else will use proxy</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for general purposes</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -3716,12 +3716,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
|
||||
<tabstop>comboProxyType</tabstop>
|
||||
<tabstop>textProxyIP</tabstop>
|
||||
<tabstop>spinProxyPort</tabstop>
|
||||
<tabstop>checkProxyPeerConnections</tabstop>
|
||||
<tabstop>isProxyOnlyForTorrents</tabstop>
|
||||
<tabstop>checkProxyHostnameLookup</tabstop>
|
||||
<tabstop>checkProxyAuth</tabstop>
|
||||
<tabstop>textProxyUsername</tabstop>
|
||||
<tabstop>textProxyPassword</tabstop>
|
||||
<tabstop>checkProxyBitTorrent</tabstop>
|
||||
<tabstop>checkProxyPeerConnections</tabstop>
|
||||
<tabstop>checkProxyHostnameLookup</tabstop>
|
||||
<tabstop>checkProxyRSS</tabstop>
|
||||
<tabstop>checkProxyMisc</tabstop>
|
||||
<tabstop>checkIPFilter</tabstop>
|
||||
<tabstop>textFilterPath</tabstop>
|
||||
<tabstop>IpFilterRefreshBtn</tabstop>
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/version.h"
|
||||
#include "base/version.h"
|
||||
|
||||
@ -77,7 +78,7 @@ void ProgramUpdater::checkForUpdates() const
|
||||
// the filehost can identify it and contact us.
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(RSS_URL).userAgent(QStringLiteral("qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)"))
|
||||
, true, this, &ProgramUpdater::rssDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes(), this, &ProgramUpdater::rssDownloadFinished);
|
||||
}
|
||||
|
||||
QString ProgramUpdater::getNewVersion() const
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "base/bittorrent/trackerentry.h"
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "gui/uithememanager.h"
|
||||
#include "ui_trackersadditiondialog.h"
|
||||
|
||||
@ -87,7 +88,8 @@ void TrackersAdditionDialog::onDownloadButtonClicked()
|
||||
m_ui->downloadButton->setEnabled(false);
|
||||
setCursor(Qt::WaitCursor);
|
||||
|
||||
Net::DownloadManager::instance()->download(url, true, this, &TrackersAdditionDialog::onTorrentListDownloadFinished);
|
||||
Net::DownloadManager::instance()->download(url, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &TrackersAdditionDialog::onTorrentListDownloadFinished);
|
||||
}
|
||||
|
||||
void TrackersAdditionDialog::onTorrentListDownloadFinished(const Net::DownloadResult &result)
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "gui/autoexpandabledialog.h"
|
||||
#include "gui/uithememanager.h"
|
||||
@ -312,7 +313,7 @@ void PluginSelectDialog::addNewPlugin(const QString &pluginName)
|
||||
using namespace Net;
|
||||
DownloadManager::instance()->download(
|
||||
DownloadRequest(plugin->url + u"/favicon.ico").saveToFile(true)
|
||||
, true, this, &PluginSelectDialog::iconDownloadFinished);
|
||||
, Preferences::instance()->useProxyForGeneralPurposes(), this, &PluginSelectDialog::iconDownloadFinished);
|
||||
}
|
||||
item->setText(PLUGIN_VERSION, plugin->version.toString());
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ void TrackerFiltersList::downloadFavicon(const QString &url)
|
||||
{
|
||||
if (!m_downloadTrackerFavicon) return;
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(url).saveToFile(true), true
|
||||
Net::DownloadRequest(url).saveToFile(true), Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &TrackerFiltersList::handleFavicoDownloadFinished);
|
||||
}
|
||||
|
||||
|
@ -194,16 +194,18 @@ void AppController::preferencesAction()
|
||||
// Proxy Server
|
||||
const auto *proxyManager = Net::ProxyConfigurationManager::instance();
|
||||
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();
|
||||
data[u"proxy_type"_qs] = static_cast<int>(proxyConf.type);
|
||||
data[u"proxy_type"_qs] = Utils::String::fromEnum(proxyConf.type);
|
||||
data[u"proxy_ip"_qs] = proxyConf.ip;
|
||||
data[u"proxy_port"_qs] = proxyConf.port;
|
||||
data[u"proxy_auth_enabled"_qs] = proxyManager->isAuthenticationRequired(); // deprecated
|
||||
data[u"proxy_auth_enabled"_qs] = proxyConf.authEnabled;
|
||||
data[u"proxy_username"_qs] = proxyConf.username;
|
||||
data[u"proxy_password"_qs] = proxyConf.password;
|
||||
|
||||
data[u"proxy_bittorrent"_qs] = pref->useProxyForBT();
|
||||
data[u"proxy_peer_connections"_qs] = session->isProxyPeerConnectionsEnabled();
|
||||
data[u"proxy_torrents_only"_qs] = proxyManager->isProxyOnlyForTorrents();
|
||||
data[u"proxy_hostname_lookup"_qs] = session->isProxyHostnameLookupEnabled();
|
||||
data[u"proxy_rss"_qs] = pref->useProxyForRSS();
|
||||
data[u"proxy_misc"_qs] = pref->useProxyForGeneralPurposes();
|
||||
|
||||
// IP Filtering
|
||||
data[u"ip_filter_enabled"_qs] = session->isIPFilteringEnabled();
|
||||
@ -610,23 +612,29 @@ void AppController::setPreferencesAction()
|
||||
auto proxyManager = Net::ProxyConfigurationManager::instance();
|
||||
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();
|
||||
if (hasKey(u"proxy_type"_qs))
|
||||
proxyConf.type = static_cast<Net::ProxyType>(it.value().toInt());
|
||||
proxyConf.type = Utils::String::toEnum(it.value().toString(), Net::ProxyType::HTTP);
|
||||
if (hasKey(u"proxy_ip"_qs))
|
||||
proxyConf.ip = it.value().toString();
|
||||
if (hasKey(u"proxy_port"_qs))
|
||||
proxyConf.port = it.value().toUInt();
|
||||
if (hasKey(u"proxy_auth_enabled"_qs))
|
||||
proxyConf.authEnabled = it.value().toBool();
|
||||
if (hasKey(u"proxy_username"_qs))
|
||||
proxyConf.username = it.value().toString();
|
||||
if (hasKey(u"proxy_password"_qs))
|
||||
proxyConf.password = it.value().toString();
|
||||
proxyManager->setProxyConfiguration(proxyConf);
|
||||
|
||||
if (hasKey(u"proxy_bittorrent"_qs))
|
||||
pref->setUseProxyForBT(it.value().toBool());
|
||||
if (hasKey(u"proxy_peer_connections"_qs))
|
||||
session->setProxyPeerConnectionsEnabled(it.value().toBool());
|
||||
if (hasKey(u"proxy_torrents_only"_qs))
|
||||
proxyManager->setProxyOnlyForTorrents(it.value().toBool());
|
||||
if (hasKey(u"proxy_hostname_lookup"_qs))
|
||||
session->setProxyHostnameLookupEnabled(it.value().toBool());
|
||||
if (hasKey(u"proxy_rss"_qs))
|
||||
pref->setUseProxyForRSS(it.value().toBool());
|
||||
if (hasKey(u"proxy_misc"_qs))
|
||||
pref->setUseProxyForGeneralPurposes(it.value().toBool());
|
||||
|
||||
// IP Filtering
|
||||
if (hasKey(u"ip_filter_enabled"_qs))
|
||||
|
@ -52,7 +52,7 @@
|
||||
#include "base/utils/version.h"
|
||||
#include "api/isessionmanager.h"
|
||||
|
||||
inline const Utils::Version<3, 2> API_VERSION {2, 8, 20};
|
||||
inline const Utils::Version<3, 2> API_VERSION {2, 9, 0};
|
||||
|
||||
class APIController;
|
||||
class AuthController;
|
||||
|
@ -350,10 +350,9 @@
|
||||
</td>
|
||||
<td>
|
||||
<select id="peer_proxy_type_select" onchange="qBittorrent.Preferences.updatePeerProxySettings();">
|
||||
<option value="none">QBT_TR((None))QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
<option value="socks4">QBT_TR(SOCKS4)QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
<option value="socks5">QBT_TR(SOCKS5)QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
<option value="http">QBT_TR(HTTP)QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
<option value="SOCKS4">QBT_TR(SOCKS4)QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
<option value="SOCKS5">QBT_TR(SOCKS5)QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
<option value="HTTP">QBT_TR(HTTP)QBT_TR[CONTEXT=OptionsDialog]</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
@ -370,18 +369,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="use_peer_proxy_checkbox" />
|
||||
<label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="proxy_only_for_torrents_checkbox" />
|
||||
<label for="proxy_only_for_torrents_checkbox">QBT_TR(Use proxy only for torrents)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="proxyHostnameLookupCheckbox" title="QBT_TR(If checked, hostname lookups are done via the proxy.)QBT_TR[CONTEXT=OptionsDialog]" />
|
||||
<label for="proxyHostnameLookupCheckbox">QBT_TR(Use proxy for hostname lookup)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
|
||||
<fieldset class="settings">
|
||||
<legend>
|
||||
<input type="checkbox" id="peer_proxy_auth_checkbox" onclick="qBittorrent.Preferences.updatePeerProxyAuthSettings();" />
|
||||
@ -409,6 +397,29 @@
|
||||
<span>QBT_TR(Info: The password is saved unencrypted)QBT_TR[CONTEXT=OptionsDialog]</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="settings">
|
||||
<legend>
|
||||
<input type="checkbox" id="proxy_bittorrent_checkbox" onclick="qBittorrent.Preferences.updatePeerProxySettings();" />
|
||||
<label for="proxy_bittorrent_checkbox">QBT_TR(Use proxy for BitTorrent purposes)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</legend>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="use_peer_proxy_checkbox" />
|
||||
<label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="proxyHostnameLookupCheckbox" title="QBT_TR(If checked, hostname lookups are done via the proxy.)QBT_TR[CONTEXT=OptionsDialog]" />
|
||||
<label for="proxyHostnameLookupCheckbox">QBT_TR(Use proxy for hostname lookup)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="proxy_rss_checkbox" />
|
||||
<label for="proxy_rss_checkbox">QBT_TR(Use proxy for RSS purposes)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<input type="checkbox" id="proxy_misc_checkbox" />
|
||||
<label for="proxy_misc_checkbox">QBT_TR(Use proxy for general purposes)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="settings">
|
||||
@ -1575,21 +1586,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||
};
|
||||
|
||||
const updatePeerProxySettings = function() {
|
||||
const isPeerProxyTypeSelected = $('peer_proxy_type_select').getProperty('value') != "none";
|
||||
$('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected);
|
||||
$('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected);
|
||||
$('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
|
||||
const proxyType = $('peer_proxy_type_select').getProperty('value');
|
||||
const isPeerProxyAuthenticatable = (proxyType === "socks5") || (proxyType === "http");
|
||||
$('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyAuthenticatable);
|
||||
const isProxySocks4 = (proxyType === "SOCKS4");
|
||||
|
||||
if ($('peer_proxy_type_select').getProperty('value') === "socks4")
|
||||
$('proxy_only_for_torrents_checkbox').setProperty('checked', true);
|
||||
|
||||
const canPeerProxyResolveHostnames = (proxyType === "socks5") || (proxyType === "http");
|
||||
$('proxyHostnameLookupCheckbox').setProperty('disabled', !canPeerProxyResolveHostnames);
|
||||
|
||||
$('peer_proxy_auth_checkbox').setProperty('disabled', !isPeerProxyAuthenticatable);
|
||||
$('peer_proxy_auth_checkbox').setProperty('disabled', isProxySocks4);
|
||||
$('use_peer_proxy_checkbox').setProperty('disabled', !$('proxy_bittorrent_checkbox').getProperty('checked'));
|
||||
$('proxyHostnameLookupCheckbox').setProperty('disabled', isProxySocks4 || !$('proxy_bittorrent_checkbox').getProperty('checked'));
|
||||
$('proxy_rss_checkbox').setProperty('disabled', isProxySocks4);
|
||||
$('proxy_misc_checkbox').setProperty('disabled', isProxySocks4);
|
||||
|
||||
updatePeerProxyAuthSettings();
|
||||
};
|
||||
@ -1945,31 +1949,18 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||
updateMaxUploadsPerTorrentEnabled();
|
||||
|
||||
// Proxy Server
|
||||
switch (pref.proxy_type.toInt()) {
|
||||
case 5: //SOCKS4
|
||||
$('peer_proxy_type_select').setProperty('value', 'socks4');
|
||||
break;
|
||||
case 2: // SOCKS5
|
||||
case 4: // SOCKS5_PW
|
||||
$('peer_proxy_type_select').setProperty('value', 'socks5');
|
||||
break;
|
||||
case 1: // HTTP
|
||||
case 3: // HTTP_PW
|
||||
$('peer_proxy_type_select').setProperty('value', 'http');
|
||||
break;
|
||||
default: // NONE
|
||||
$('peer_proxy_type_select').setProperty('value', 'none');
|
||||
}
|
||||
updatePeerProxySettings();
|
||||
$('peer_proxy_type_select').setProperty('value', pref.proxy_type);
|
||||
$('peer_proxy_host_text').setProperty('value', pref.proxy_ip);
|
||||
$('peer_proxy_port_value').setProperty('value', pref.proxy_port);
|
||||
$('use_peer_proxy_checkbox').setProperty('checked', pref.proxy_peer_connections);
|
||||
$('proxy_only_for_torrents_checkbox').setProperty('checked', pref.proxy_torrents_only);
|
||||
$('proxyHostnameLookupCheckbox').setProperty('checked', pref.proxy_hostname_lookup);
|
||||
$('proxy_bittorrent_checkbox').setProperty('checked', pref.proxy_bittorrent);
|
||||
$('proxy_rss_checkbox').setProperty('checked', pref.proxy_rss);
|
||||
$('proxy_misc_checkbox').setProperty('checked', pref.proxy_misc);
|
||||
$('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled);
|
||||
updatePeerProxyAuthSettings();
|
||||
$('peer_proxy_username_text').setProperty('value', pref.proxy_username);
|
||||
$('peer_proxy_password_text').setProperty('value', pref.proxy_password);
|
||||
updatePeerProxySettings();
|
||||
|
||||
// IP Filtering
|
||||
$('ipfilter_text_checkbox').setProperty('checked', pref.ip_filter_enabled);
|
||||
@ -2286,43 +2277,17 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||
settings.set('max_uploads_per_torrent', max_uploads_per_torrent);
|
||||
|
||||
// Proxy Server
|
||||
const proxy_type_str = $('peer_proxy_type_select').getProperty('value');
|
||||
let proxy_type = 0;
|
||||
let proxy_auth_enabled = false;
|
||||
if (proxy_type_str == "socks5") {
|
||||
if ($('peer_proxy_auth_checkbox').getProperty('checked')) {
|
||||
proxy_type = 4;
|
||||
proxy_auth_enabled = true;
|
||||
}
|
||||
else {
|
||||
proxy_type = 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (proxy_type_str == "socks4") {
|
||||
proxy_type = 5;
|
||||
}
|
||||
else {
|
||||
if (proxy_type_str == "http") {
|
||||
if ($('peer_proxy_auth_checkbox').getProperty('checked')) {
|
||||
proxy_type = 3;
|
||||
proxy_auth_enabled = true;
|
||||
}
|
||||
else {
|
||||
proxy_type = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
settings.set('proxy_type', proxy_type);
|
||||
settings.set('proxy_auth_enabled', proxy_auth_enabled);
|
||||
settings.set('proxy_type', $('peer_proxy_type_select').getProperty('value'));
|
||||
settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value'));
|
||||
settings.set('proxy_port', $('peer_proxy_port_value').getProperty('value').toInt());
|
||||
settings.set('proxy_peer_connections', $('use_peer_proxy_checkbox').getProperty('checked'));
|
||||
settings.set('proxy_torrents_only', $('proxy_only_for_torrents_checkbox').getProperty('checked'));
|
||||
settings.set('proxy_hostname_lookup', $('proxyHostnameLookupCheckbox').getProperty('checked'));
|
||||
settings.set('proxy_auth_enabled', $('peer_proxy_auth_checkbox').getProperty('checked'));
|
||||
settings.set('proxy_username', $('peer_proxy_username_text').getProperty('value'));
|
||||
settings.set('proxy_password', $('peer_proxy_password_text').getProperty('value'));
|
||||
settings.set('proxy_bittorrent', $('proxy_bittorrent_checkbox').getProperty('checked'));
|
||||
settings.set('proxy_peer_connections', $('use_peer_proxy_checkbox').getProperty('checked'));
|
||||
settings.set('proxy_hostname_lookup', $('proxyHostnameLookupCheckbox').getProperty('checked'));
|
||||
settings.set('proxy_rss', $('proxy_rss_checkbox').getProperty('checked'));
|
||||
settings.set('proxy_misc', $('proxy_misc_checkbox').getProperty('checked'));
|
||||
|
||||
// IP Filtering
|
||||
settings.set('ip_filter_enabled', $('ipfilter_text_checkbox').getProperty('checked'));
|
||||
|
Loading…
Reference in New Issue
Block a user