mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
Simplify proxy related code
This commit is contained in:
parent
943e403241
commit
5a716a40fb
1 changed files with 28 additions and 29 deletions
|
@ -265,38 +265,37 @@ void Net::DownloadManager::applyProxySettings()
|
||||||
const auto *proxyManager = ProxyConfigurationManager::instance();
|
const auto *proxyManager = ProxyConfigurationManager::instance();
|
||||||
const ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
const ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||||
|
|
||||||
m_proxy = QNetworkProxy(QNetworkProxy::NoProxy);
|
switch (proxyConfig.type)
|
||||||
|
|
||||||
if ((proxyConfig.type == Net::ProxyType::None) || (proxyConfig.type == ProxyType::SOCKS4))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Proxy enabled
|
|
||||||
if (proxyConfig.type == ProxyType::SOCKS5)
|
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "using SOCKS proxy";
|
case Net::ProxyType::None:
|
||||||
m_proxy.setType(QNetworkProxy::Socks5Proxy);
|
case Net::ProxyType::SOCKS4:
|
||||||
}
|
m_proxy = QNetworkProxy(QNetworkProxy::NoProxy);
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << "using HTTP proxy";
|
|
||||||
m_proxy.setType(QNetworkProxy::HttpProxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_proxy.setHostName(proxyConfig.ip);
|
case Net::ProxyType::HTTP:
|
||||||
m_proxy.setPort(proxyConfig.port);
|
m_proxy = QNetworkProxy(
|
||||||
|
QNetworkProxy::HttpProxy
|
||||||
|
, proxyConfig.ip
|
||||||
|
, proxyConfig.port
|
||||||
|
, (proxyConfig.authEnabled ? proxyConfig.username : QString())
|
||||||
|
, (proxyConfig.authEnabled ? proxyConfig.password : QString()));
|
||||||
|
m_proxy.setCapabilities(proxyConfig.hostnameLookupEnabled
|
||||||
|
? (m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability)
|
||||||
|
: (m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability));
|
||||||
|
break;
|
||||||
|
|
||||||
// Authentication?
|
case Net::ProxyType::SOCKS5:
|
||||||
if (proxyConfig.authEnabled)
|
m_proxy = QNetworkProxy(
|
||||||
{
|
QNetworkProxy::Socks5Proxy
|
||||||
qDebug("Proxy requires authentication, authenticating...");
|
, proxyConfig.ip
|
||||||
m_proxy.setUser(proxyConfig.username);
|
, proxyConfig.port
|
||||||
m_proxy.setPassword(proxyConfig.password);
|
, (proxyConfig.authEnabled ? proxyConfig.username : QString())
|
||||||
}
|
, (proxyConfig.authEnabled ? proxyConfig.password : QString()));
|
||||||
|
m_proxy.setCapabilities(proxyConfig.hostnameLookupEnabled
|
||||||
if (proxyConfig.hostnameLookupEnabled)
|
? (m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability)
|
||||||
m_proxy.setCapabilities(m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability);
|
: (m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability));
|
||||||
else
|
break;
|
||||||
m_proxy.setCapabilities(m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability);
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Net::DownloadManager::processWaitingJobs(const ServiceID &serviceID)
|
void Net::DownloadManager::processWaitingJobs(const ServiceID &serviceID)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue