Skip to content

Commit c47f81e

Browse files
committed
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.
1 parent 1a6fc04 commit c47f81e

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,14 +1578,14 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15781578
if (proxyArg != "" && proxyArg != "0") {
15791579
Proxy addrProxy;
15801580
if (IsUnixSocketPath(proxyArg)) {
1581-
addrProxy = Proxy(proxyArg, proxyRandomize);
1581+
addrProxy = Proxy(proxyArg, /*tor_stream_isolation=*/proxyRandomize);
15821582
} else {
15831583
const std::optional<CService> proxyAddr{Lookup(proxyArg, 9050, fNameLookup)};
15841584
if (!proxyAddr.has_value()) {
15851585
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
15861586
}
15871587

1588-
addrProxy = Proxy(proxyAddr.value(), proxyRandomize);
1588+
addrProxy = Proxy(proxyAddr.value(), /*tor_stream_isolation=*/proxyRandomize);
15891589
}
15901590

15911591
if (!addrProxy.IsValid())
@@ -1614,14 +1614,14 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16141614
}
16151615
} else {
16161616
if (IsUnixSocketPath(onionArg)) {
1617-
onion_proxy = Proxy(onionArg, proxyRandomize);
1617+
onion_proxy = Proxy(onionArg, /*tor_stream_isolation=*/proxyRandomize);
16181618
} else {
16191619
const std::optional<CService> addr{Lookup(onionArg, 9050, fNameLookup)};
16201620
if (!addr.has_value() || !addr->IsValid()) {
16211621
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
16221622
}
16231623

1624-
onion_proxy = Proxy(addr.value(), proxyRandomize);
1624+
onion_proxy = Proxy(addr.value(), /*tor_stream_isolation=*/proxyRandomize);
16251625
}
16261626
}
16271627
}

src/netbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ std::unique_ptr<Sock> ConnectThroughProxy(const Proxy& proxy,
738738
}
739739

740740
// do socks negotiation
741-
if (proxy.m_randomize_credentials) {
741+
if (proxy.m_tor_stream_isolation) {
742742
ProxyCredentials random_auth;
743743
static std::atomic_int counter(0);
744744
random_auth.username = random_auth.password = strprintf("%i", counter++);

src/netbase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ bool IsUnixSocketPath(const std::string& name);
5858
class Proxy
5959
{
6060
public:
61-
Proxy() : m_is_unix_socket(false), m_randomize_credentials(false) {}
62-
explicit Proxy(const CService& _proxy, bool _randomize_credentials = false) : proxy(_proxy), m_is_unix_socket(false), m_randomize_credentials(_randomize_credentials) {}
63-
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) {}
61+
Proxy() : m_is_unix_socket(false), m_tor_stream_isolation(false) {}
62+
explicit Proxy(const CService& _proxy, bool tor_stream_isolation = false) : proxy(_proxy), m_is_unix_socket(false), m_tor_stream_isolation(tor_stream_isolation) {}
63+
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) {}
6464

6565
CService proxy;
6666
std::string m_unix_socket_path;
6767
bool m_is_unix_socket;
68-
bool m_randomize_credentials;
68+
bool m_tor_stream_isolation;
6969

7070
bool IsValid() const
7171
{

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) cons
486486
if (!SplitHostPort(input.toStdString(), port, hostname) || port != 0) return QValidator::Invalid;
487487

488488
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
489-
Proxy addrProxy = Proxy(serv, true);
489+
Proxy addrProxy = Proxy(serv, /*tor_stream_isolation=*/true);
490490
if (addrProxy.IsValid())
491491
return QValidator::Acceptable;
492492

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ static UniValue GetNetworksInfo()
609609
obj.pushKV("limited", !g_reachable_nets.Contains(network));
610610
obj.pushKV("reachable", g_reachable_nets.Contains(network));
611611
obj.pushKV("proxy", proxy.IsValid() ? proxy.ToString() : std::string());
612-
obj.pushKV("proxy_randomize_credentials", proxy.m_randomize_credentials);
612+
obj.pushKV("proxy_randomize_credentials", proxy.m_tor_stream_isolation);
613613
networks.push_back(std::move(obj));
614614
}
615615
return networks;

src/torcontrol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void TorController::get_socks_cb(TorControlConnection& _conn, const TorControlRe
407407
// With m_randomize_credentials = true, generates unique SOCKS credentials per proxy connection (e.g., Tor).
408408
// Prevents connection correlation and enhances privacy by forcing different Tor circuits.
409409
// Requires Tor's IsolateSOCKSAuth (default enabled) for effective isolation (see IsolateSOCKSAuth section in https://2019.www.torproject.org/docs/tor-manual.html.en).
410-
Proxy addrOnion = Proxy(resolved, /*_randomize_credentials=*/ true);
410+
Proxy addrOnion = Proxy(resolved, /*tor_stream_isolation=*/ true);
411411
SetProxy(NET_ONION, addrOnion);
412412

413413
const auto onlynets = gArgs.GetArgs("-onlynet");

0 commit comments

Comments
 (0)