Expand the scope of "Proxy hostname lookup" option

This commit is contained in:
Vladimir Golovnev (Glassez)
2023-02-13 11:23:52 +03:00
parent 6ac14d0c57
commit 96da685e5d
11 changed files with 57 additions and 61 deletions

View File

@@ -250,6 +250,11 @@ void Net::DownloadManager::applyProxySettings()
m_proxy.setUser(proxyConfig.username);
m_proxy.setPassword(proxyConfig.password);
}
if (proxyConfig.hostnameLookupEnabled)
m_proxy.setCapabilities(m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability);
else
m_proxy.setCapabilities(m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability);
}
}

View File

@@ -37,7 +37,8 @@ bool Net::operator==(const ProxyConfiguration &left, const ProxyConfiguration &r
&& (left.port == right.port)
&& (left.authEnabled == right.authEnabled)
&& (left.username == right.username)
&& (left.password == right.password);
&& (left.password == right.password)
&& (left.hostnameLookupEnabled == right.hostnameLookupEnabled);
}
bool Net::operator!=(const ProxyConfiguration &left, const ProxyConfiguration &right)
@@ -57,6 +58,7 @@ ProxyConfigurationManager::ProxyConfigurationManager(QObject *parent)
, m_storeProxyAuthEnabled {SETTINGS_KEY(u"AuthEnabled"_qs)}
, m_storeProxyUsername {SETTINGS_KEY(u"Username"_qs)}
, m_storeProxyPassword {SETTINGS_KEY(u"Password"_qs)}
, m_storeProxyHostnameLookupEnabled {SETTINGS_KEY(u"HostnameLookupEnabled"_qs)}
{
m_config.type = m_storeProxyType.get(ProxyType::HTTP);
if ((m_config.type < ProxyType::HTTP) || (m_config.type > ProxyType::SOCKS4))
@@ -66,6 +68,7 @@ ProxyConfigurationManager::ProxyConfigurationManager(QObject *parent)
m_config.authEnabled = m_storeProxyAuthEnabled;
m_config.username = m_storeProxyUsername;
m_config.password = m_storeProxyPassword;
m_config.hostnameLookupEnabled = m_storeProxyHostnameLookupEnabled.get(true);
}
void ProxyConfigurationManager::initInstance()
@@ -101,6 +104,7 @@ void ProxyConfigurationManager::setProxyConfiguration(const ProxyConfiguration &
m_storeProxyAuthEnabled = config.authEnabled;
m_storeProxyUsername = config.username;
m_storeProxyPassword = config.password;
m_storeProxyHostnameLookupEnabled = config.hostnameLookupEnabled;
emit proxyConfigurationChanged();
}

View File

@@ -53,6 +53,7 @@ namespace Net
bool authEnabled = false;
QString username;
QString password;
bool hostnameLookupEnabled = true;
};
bool operator==(const ProxyConfiguration &left, const ProxyConfiguration &right);
bool operator!=(const ProxyConfiguration &left, const ProxyConfiguration &right);
@@ -85,5 +86,6 @@ namespace Net
SettingValue<bool> m_storeProxyAuthEnabled;
SettingValue<QString> m_storeProxyUsername;
SettingValue<QString> m_storeProxyPassword;
SettingValue<bool> m_storeProxyHostnameLookupEnabled;
};
}