Add a "Use proxy for hostname lookup" option

Add a UI option for "Use proxy for hostname lookup" option and plumb
it into libtorrent's settings_pack.proxy_hostnames option.  This is
available for SOCKS5 and HTTP proxies, and defaults to true, which
is the previous functionality.  Hostname lookups can be forced to be
local by unchecking this option, which can aid compatibility with
certain non-compliant proxy servers.

Closes #17902.
PR #17904.

Co-authored-by: Nathan Lewis <saturn@saturn49.dyndns.org>
This commit is contained in:
Nathan Lewis
2022-10-23 02:31:02 -05:00
committed by GitHub
parent 155e73df16
commit f2dd1e6456
8 changed files with 59 additions and 2 deletions

View File

@@ -189,6 +189,7 @@ void AppController::preferencesAction()
data[u"proxy_peer_connections"_qs] = session->isProxyPeerConnectionsEnabled();
data[u"proxy_torrents_only"_qs] = proxyManager->isProxyOnlyForTorrents();
data[u"proxy_hostname_lookup"_qs] = session->isProxyHostnameLookupEnabled();
// IP Filtering
data[u"ip_filter_enabled"_qs] = session->isIPFilteringEnabled();
@@ -569,6 +570,8 @@ void AppController::setPreferencesAction()
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());
// IP Filtering
if (hasKey(u"ip_filter_enabled"_qs))

View File

@@ -52,7 +52,7 @@
#include "base/utils/version.h"
#include "api/isessionmanager.h"
inline const Utils::Version<3, 2> API_VERSION {2, 8, 15};
inline const Utils::Version<3, 2> API_VERSION {2, 8, 16};
class APIController;
class AuthController;

View File

@@ -333,6 +333,10 @@
<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();" />
@@ -1541,12 +1545,16 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected);
$('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected);
$('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
const isPeerProxyAuthenticatable = ($('peer_proxy_type_select').getProperty('value') === "socks5" || $('peer_proxy_type_select').getProperty('value') === "http");
const proxyType = $('peer_proxy_type_select').getProperty('value');
const isPeerProxyAuthenticatable = (proxyType === "socks5") || (proxyType === "http");
$('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyAuthenticatable);
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);
updatePeerProxyAuthSettings();
@@ -1901,6 +1909,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('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);
$('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled);
updatePeerProxyAuthSettings();
$('peer_proxy_username_text').setProperty('value', pref.proxy_username);
@@ -2243,6 +2252,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
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_username', $('peer_proxy_username_text').getProperty('value'));
settings.set('proxy_password', $('peer_proxy_password_text').getProperty('value'));