mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
net: Rename _randomize_credentials
Proxy parameter to tor_stream_isolation
Rename the `_randomize_credentials` parameter to Proxy's constructor to `tor_stream_isolation` to make it more clear, and more specific what its purpose is. Also change all call sites to use a named parameter.
This commit is contained in:
parent
1a6fc04d81
commit
c47f81e8ac
6 changed files with 12 additions and 12 deletions
|
@ -1578,14 +1578,14 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
if (proxyArg != "" && proxyArg != "0") {
|
if (proxyArg != "" && proxyArg != "0") {
|
||||||
Proxy addrProxy;
|
Proxy addrProxy;
|
||||||
if (IsUnixSocketPath(proxyArg)) {
|
if (IsUnixSocketPath(proxyArg)) {
|
||||||
addrProxy = Proxy(proxyArg, proxyRandomize);
|
addrProxy = Proxy(proxyArg, /*tor_stream_isolation=*/proxyRandomize);
|
||||||
} else {
|
} else {
|
||||||
const std::optional<CService> proxyAddr{Lookup(proxyArg, 9050, fNameLookup)};
|
const std::optional<CService> proxyAddr{Lookup(proxyArg, 9050, fNameLookup)};
|
||||||
if (!proxyAddr.has_value()) {
|
if (!proxyAddr.has_value()) {
|
||||||
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
|
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
addrProxy = Proxy(proxyAddr.value(), proxyRandomize);
|
addrProxy = Proxy(proxyAddr.value(), /*tor_stream_isolation=*/proxyRandomize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addrProxy.IsValid())
|
if (!addrProxy.IsValid())
|
||||||
|
@ -1614,14 +1614,14 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IsUnixSocketPath(onionArg)) {
|
if (IsUnixSocketPath(onionArg)) {
|
||||||
onion_proxy = Proxy(onionArg, proxyRandomize);
|
onion_proxy = Proxy(onionArg, /*tor_stream_isolation=*/proxyRandomize);
|
||||||
} else {
|
} else {
|
||||||
const std::optional<CService> addr{Lookup(onionArg, 9050, fNameLookup)};
|
const std::optional<CService> addr{Lookup(onionArg, 9050, fNameLookup)};
|
||||||
if (!addr.has_value() || !addr->IsValid()) {
|
if (!addr.has_value() || !addr->IsValid()) {
|
||||||
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
|
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
onion_proxy = Proxy(addr.value(), proxyRandomize);
|
onion_proxy = Proxy(addr.value(), /*tor_stream_isolation=*/proxyRandomize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -738,7 +738,7 @@ std::unique_ptr<Sock> ConnectThroughProxy(const Proxy& proxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
// do socks negotiation
|
// do socks negotiation
|
||||||
if (proxy.m_randomize_credentials) {
|
if (proxy.m_tor_stream_isolation) {
|
||||||
ProxyCredentials random_auth;
|
ProxyCredentials random_auth;
|
||||||
static std::atomic_int counter(0);
|
static std::atomic_int counter(0);
|
||||||
random_auth.username = random_auth.password = strprintf("%i", counter++);
|
random_auth.username = random_auth.password = strprintf("%i", counter++);
|
||||||
|
|
|
@ -58,14 +58,14 @@ bool IsUnixSocketPath(const std::string& name);
|
||||||
class Proxy
|
class Proxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Proxy() : m_is_unix_socket(false), m_randomize_credentials(false) {}
|
Proxy() : m_is_unix_socket(false), m_tor_stream_isolation(false) {}
|
||||||
explicit Proxy(const CService& _proxy, bool _randomize_credentials = false) : proxy(_proxy), m_is_unix_socket(false), m_randomize_credentials(_randomize_credentials) {}
|
explicit Proxy(const CService& _proxy, bool tor_stream_isolation = false) : proxy(_proxy), m_is_unix_socket(false), m_tor_stream_isolation(tor_stream_isolation) {}
|
||||||
explicit Proxy(const std::string path, bool _randomize_credentials = false) : m_unix_socket_path(path), m_is_unix_socket(true), m_randomize_credentials(_randomize_credentials) {}
|
explicit Proxy(const std::string path, bool tor_stream_isolation = false) : m_unix_socket_path(path), m_is_unix_socket(true), m_tor_stream_isolation(tor_stream_isolation) {}
|
||||||
|
|
||||||
CService proxy;
|
CService proxy;
|
||||||
std::string m_unix_socket_path;
|
std::string m_unix_socket_path;
|
||||||
bool m_is_unix_socket;
|
bool m_is_unix_socket;
|
||||||
bool m_randomize_credentials;
|
bool m_tor_stream_isolation;
|
||||||
|
|
||||||
bool IsValid() const
|
bool IsValid() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -486,7 +486,7 @@ QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) cons
|
||||||
if (!SplitHostPort(input.toStdString(), port, hostname) || port != 0) return QValidator::Invalid;
|
if (!SplitHostPort(input.toStdString(), port, hostname) || port != 0) return QValidator::Invalid;
|
||||||
|
|
||||||
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
|
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
|
||||||
Proxy addrProxy = Proxy(serv, true);
|
Proxy addrProxy = Proxy(serv, /*tor_stream_isolation=*/true);
|
||||||
if (addrProxy.IsValid())
|
if (addrProxy.IsValid())
|
||||||
return QValidator::Acceptable;
|
return QValidator::Acceptable;
|
||||||
|
|
||||||
|
|
|
@ -609,7 +609,7 @@ static UniValue GetNetworksInfo()
|
||||||
obj.pushKV("limited", !g_reachable_nets.Contains(network));
|
obj.pushKV("limited", !g_reachable_nets.Contains(network));
|
||||||
obj.pushKV("reachable", g_reachable_nets.Contains(network));
|
obj.pushKV("reachable", g_reachable_nets.Contains(network));
|
||||||
obj.pushKV("proxy", proxy.IsValid() ? proxy.ToString() : std::string());
|
obj.pushKV("proxy", proxy.IsValid() ? proxy.ToString() : std::string());
|
||||||
obj.pushKV("proxy_randomize_credentials", proxy.m_randomize_credentials);
|
obj.pushKV("proxy_randomize_credentials", proxy.m_tor_stream_isolation);
|
||||||
networks.push_back(std::move(obj));
|
networks.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
return networks;
|
return networks;
|
||||||
|
|
|
@ -407,7 +407,7 @@ void TorController::get_socks_cb(TorControlConnection& _conn, const TorControlRe
|
||||||
// With m_randomize_credentials = true, generates unique SOCKS credentials per proxy connection (e.g., Tor).
|
// With m_randomize_credentials = true, generates unique SOCKS credentials per proxy connection (e.g., Tor).
|
||||||
// Prevents connection correlation and enhances privacy by forcing different Tor circuits.
|
// Prevents connection correlation and enhances privacy by forcing different Tor circuits.
|
||||||
// Requires Tor's IsolateSOCKSAuth (default enabled) for effective isolation (see IsolateSOCKSAuth section in https://2019.www.torproject.org/docs/tor-manual.html.en).
|
// Requires Tor's IsolateSOCKSAuth (default enabled) for effective isolation (see IsolateSOCKSAuth section in https://2019.www.torproject.org/docs/tor-manual.html.en).
|
||||||
Proxy addrOnion = Proxy(resolved, /*_randomize_credentials=*/ true);
|
Proxy addrOnion = Proxy(resolved, /*tor_stream_isolation=*/ true);
|
||||||
SetProxy(NET_ONION, addrOnion);
|
SetProxy(NET_ONION, addrOnion);
|
||||||
|
|
||||||
const auto onlynets = gArgs.GetArgs("-onlynet");
|
const auto onlynets = gArgs.GetArgs("-onlynet");
|
||||||
|
|
Loading…
Add table
Reference in a new issue