Browse Source

Expand the scope of "Proxy hostname lookup" option

adaptive-webui-19844
Vladimir Golovnev (Glassez) 2 years ago
parent
commit
96da685e5d
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 4
      src/app/upgrade.cpp
  2. 2
      src/base/bittorrent/session.h
  3. 17
      src/base/bittorrent/sessionimpl.cpp
  4. 3
      src/base/bittorrent/sessionimpl.h
  5. 5
      src/base/net/downloadmanager.cpp
  6. 6
      src/base/net/proxyconfigurationmanager.cpp
  7. 2
      src/base/net/proxyconfigurationmanager.h
  8. 6
      src/gui/optionsdialog.cpp
  9. 22
      src/gui/optionsdialog.ui
  10. 6
      src/webui/api/appcontroller.cpp
  11. 21
      src/webui/www/private/views/preferences.html

4
src/app/upgrade.cpp

@ -403,6 +403,10 @@ namespace @@ -403,6 +403,10 @@ namespace
}
settingsStorage->removeValue(u"Network/Proxy/OnlyForTorrents"_qs);
const auto proxyHostnameLookup = settingsStorage->loadValue<bool>(u"BitTorrent/Session/ProxyHostnameLookup"_qs);
settingsStorage->storeValue(u"Network/Proxy/HostnameLookupEnabled"_qs, proxyHostnameLookup);
settingsStorage->removeValue(u"BitTorrent/Session/ProxyHostnameLookup"_qs);
}
#ifdef Q_OS_WIN

2
src/base/bittorrent/session.h

@ -262,8 +262,6 @@ namespace BitTorrent @@ -262,8 +262,6 @@ namespace BitTorrent
virtual void setMaxActiveCheckingTorrents(int val) = 0;
virtual bool isProxyPeerConnectionsEnabled() const = 0;
virtual void setProxyPeerConnectionsEnabled(bool enabled) = 0;
virtual bool isProxyHostnameLookupEnabled() const = 0;
virtual void setProxyHostnameLookupEnabled(bool enabled) = 0;
virtual ChokingAlgorithm chokingAlgorithm() const = 0;
virtual void setChokingAlgorithm(ChokingAlgorithm mode) = 0;
virtual SeedChokingAlgorithm seedChokingAlgorithm() const = 0;

17
src/base/bittorrent/sessionimpl.cpp

@ -495,7 +495,6 @@ SessionImpl::SessionImpl(QObject *parent) @@ -495,7 +495,6 @@ SessionImpl::SessionImpl(QObject *parent)
, m_encryption(BITTORRENT_SESSION_KEY(u"Encryption"_qs), 0)
, m_maxActiveCheckingTorrents(BITTORRENT_SESSION_KEY(u"MaxActiveCheckingTorrents"_qs), 1)
, m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY(u"ProxyPeerConnections"_qs), false)
, m_isProxyHostnameLookupEnabled(BITTORRENT_SESSION_KEY(u"ProxyHostnameLookup"_qs), true)
, m_chokingAlgorithm(BITTORRENT_SESSION_KEY(u"ChokingAlgorithm"_qs), ChokingAlgorithm::FixedSlots
, clampValue(ChokingAlgorithm::FixedSlots, ChokingAlgorithm::RateBased))
, m_seedChokingAlgorithm(BITTORRENT_SESSION_KEY(u"SeedChokingAlgorithm"_qs), SeedChokingAlgorithm::FastestUpload
@ -1669,7 +1668,7 @@ lt::settings_pack SessionImpl::loadLTSettings() const @@ -1669,7 +1668,7 @@ lt::settings_pack SessionImpl::loadLTSettings() const
}
settingsPack.set_bool(lt::settings_pack::proxy_peer_connections, isProxyPeerConnectionsEnabled());
settingsPack.set_bool(lt::settings_pack::proxy_hostnames, isProxyHostnameLookupEnabled());
settingsPack.set_bool(lt::settings_pack::proxy_hostnames, proxyConfig.hostnameLookupEnabled);
}
settingsPack.set_bool(lt::settings_pack::announce_to_all_trackers, announceToAllTrackers());
@ -3545,20 +3544,6 @@ void SessionImpl::setProxyPeerConnectionsEnabled(const bool enabled) @@ -3545,20 +3544,6 @@ void SessionImpl::setProxyPeerConnectionsEnabled(const bool enabled)
}
}
bool SessionImpl::isProxyHostnameLookupEnabled() const
{
return m_isProxyHostnameLookupEnabled;
}
void SessionImpl::setProxyHostnameLookupEnabled(const bool enabled)
{
if (enabled != isProxyHostnameLookupEnabled())
{
m_isProxyHostnameLookupEnabled = enabled;
configureDeferred();
}
}
ChokingAlgorithm SessionImpl::chokingAlgorithm() const
{
return m_chokingAlgorithm;

3
src/base/bittorrent/sessionimpl.h

@ -239,8 +239,6 @@ namespace BitTorrent @@ -239,8 +239,6 @@ namespace BitTorrent
void setMaxActiveCheckingTorrents(int val) override;
bool isProxyPeerConnectionsEnabled() const override;
void setProxyPeerConnectionsEnabled(bool enabled) override;
bool isProxyHostnameLookupEnabled() const override;
void setProxyHostnameLookupEnabled(bool enabled) override;
ChokingAlgorithm chokingAlgorithm() const override;
void setChokingAlgorithm(ChokingAlgorithm mode) override;
SeedChokingAlgorithm seedChokingAlgorithm() const override;
@ -655,7 +653,6 @@ namespace BitTorrent @@ -655,7 +653,6 @@ namespace BitTorrent
CachedSettingValue<int> m_encryption;
CachedSettingValue<int> m_maxActiveCheckingTorrents;
CachedSettingValue<bool> m_isProxyPeerConnectionsEnabled;
CachedSettingValue<bool> m_isProxyHostnameLookupEnabled;
CachedSettingValue<ChokingAlgorithm> m_chokingAlgorithm;
CachedSettingValue<SeedChokingAlgorithm> m_seedChokingAlgorithm;
CachedSettingValue<QStringList> m_storedTags;

5
src/base/net/downloadmanager.cpp

@ -250,6 +250,11 @@ void Net::DownloadManager::applyProxySettings() @@ -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);
}
}

6
src/base/net/proxyconfigurationmanager.cpp

@ -37,7 +37,8 @@ bool Net::operator==(const ProxyConfiguration &left, const ProxyConfiguration &r @@ -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) @@ -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) @@ -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 & @@ -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();
}

2
src/base/net/proxyconfigurationmanager.h

@ -53,6 +53,7 @@ namespace Net @@ -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 @@ -85,5 +86,6 @@ namespace Net
SettingValue<bool> m_storeProxyAuthEnabled;
SettingValue<QString> m_storeProxyUsername;
SettingValue<QString> m_storeProxyPassword;
SettingValue<bool> m_storeProxyHostnameLookupEnabled;
};
}

6
src/gui/optionsdialog.cpp

@ -782,10 +782,10 @@ void OptionsDialog::loadConnectionTabOptions() @@ -782,10 +782,10 @@ void OptionsDialog::loadConnectionTabOptions()
m_ui->checkProxyAuth->setChecked(proxyConf.authEnabled);
m_ui->textProxyUsername->setText(proxyConf.username);
m_ui->textProxyPassword->setText(proxyConf.password);
m_ui->checkProxyHostnameLookup->setChecked(proxyConf.hostnameLookupEnabled);
m_ui->checkProxyBitTorrent->setChecked(Preferences::instance()->useProxyForBT());
m_ui->checkProxyPeerConnections->setChecked(session->isProxyPeerConnectionsEnabled());
m_ui->checkProxyHostnameLookup->setChecked(session->isProxyHostnameLookupEnabled());
m_ui->checkProxyRSS->setChecked(Preferences::instance()->useProxyForRSS());
m_ui->checkProxyMisc->setChecked(Preferences::instance()->useProxyForGeneralPurposes());
@ -856,6 +856,7 @@ void OptionsDialog::saveConnectionTabOptions() const @@ -856,6 +856,7 @@ void OptionsDialog::saveConnectionTabOptions() const
proxyConf.authEnabled = m_ui->checkProxyAuth->isChecked();
proxyConf.username = getProxyUsername();
proxyConf.password = getProxyPassword();
proxyConf.hostnameLookupEnabled = m_ui->checkProxyHostnameLookup->isChecked();
proxyConfigManager->setProxyConfiguration(proxyConf);
Preferences::instance()->setUseProxyForBT(m_ui->checkProxyBitTorrent->isChecked());
@ -863,7 +864,6 @@ void OptionsDialog::saveConnectionTabOptions() const @@ -863,7 +864,6 @@ void OptionsDialog::saveConnectionTabOptions() const
Preferences::instance()->setUseProxyForGeneralPurposes(m_ui->checkProxyMisc->isChecked());
session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnections->isChecked());
session->setProxyHostnameLookupEnabled(m_ui->checkProxyHostnameLookup->isChecked());
// IPFilter
session->setIPFilteringEnabled(isIPFilteringEnabled());
@ -1507,7 +1507,7 @@ void OptionsDialog::adjustProxyOptions() @@ -1507,7 +1507,7 @@ void OptionsDialog::adjustProxyOptions()
// SOCKS5 or HTTP
m_ui->labelProxyTypeIncompatible->setVisible(false);
m_ui->checkProxyHostnameLookup->setEnabled(m_ui->checkProxyBitTorrent->isChecked());
m_ui->checkProxyHostnameLookup->setEnabled(true);
m_ui->checkProxyRSS->setEnabled(true);
m_ui->checkProxyMisc->setEnabled(true);
}

22
src/gui/optionsdialog.ui

@ -1846,6 +1846,16 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st @@ -1846,6 +1846,16 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
</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>
<item>
<widget class="QGroupBox" name="checkProxyAuth">
<property name="enabled">
@ -1921,16 +1931,6 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st @@ -1921,16 +1931,6 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
</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>
@ -3716,12 +3716,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -3716,12 +3716,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>comboProxyType</tabstop>
<tabstop>textProxyIP</tabstop>
<tabstop>spinProxyPort</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>

6
src/webui/api/appcontroller.cpp

@ -200,10 +200,10 @@ void AppController::preferencesAction() @@ -200,10 +200,10 @@ void AppController::preferencesAction()
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_hostname_lookup"_qs] = proxyConf.hostnameLookupEnabled;
data[u"proxy_bittorrent"_qs] = pref->useProxyForBT();
data[u"proxy_peer_connections"_qs] = session->isProxyPeerConnectionsEnabled();
data[u"proxy_hostname_lookup"_qs] = session->isProxyHostnameLookupEnabled();
data[u"proxy_rss"_qs] = pref->useProxyForRSS();
data[u"proxy_misc"_qs] = pref->useProxyForGeneralPurposes();
@ -623,14 +623,14 @@ void AppController::setPreferencesAction() @@ -623,14 +623,14 @@ void AppController::setPreferencesAction()
proxyConf.username = it.value().toString();
if (hasKey(u"proxy_password"_qs))
proxyConf.password = it.value().toString();
if (hasKey(u"proxy_hostname_lookup"_qs))
proxyConf.hostnameLookupEnabled = it.value().toBool();
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_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))

21
src/webui/www/private/views/preferences.html

@ -370,6 +370,11 @@ @@ -370,6 +370,11 @@
</tr>
</table>
<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();" />
@ -407,10 +412,6 @@ @@ -407,10 +412,6 @@
<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" />
@ -1591,7 +1592,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1591,7 +1592,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('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'));
$('proxyHostnameLookupCheckbox').setProperty('disabled', isProxySocks4);
$('proxy_rss_checkbox').setProperty('disabled', isProxySocks4);
$('proxy_misc_checkbox').setProperty('disabled', isProxySocks4);
@ -1952,14 +1953,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1952,14 +1953,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('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);
$('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled);
$('peer_proxy_username_text').setProperty('value', pref.proxy_username);
$('peer_proxy_password_text').setProperty('value', pref.proxy_password);
$('proxyHostnameLookupCheckbox').setProperty('checked', pref.proxy_hostname_lookup);
$('proxy_bittorrent_checkbox').setProperty('checked', pref.proxy_bittorrent);
$('use_peer_proxy_checkbox').setProperty('checked', pref.proxy_peer_connections);
$('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);
$('peer_proxy_username_text').setProperty('value', pref.proxy_username);
$('peer_proxy_password_text').setProperty('value', pref.proxy_password);
updatePeerProxySettings();
// IP Filtering
@ -2283,9 +2284,9 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -2283,9 +2284,9 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
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_hostname_lookup', $('proxyHostnameLookupCheckbox').getProperty('checked'));
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'));

Loading…
Cancel
Save