Skip to content

Commit

Permalink
Merge pull request #2744 from jamescowens/fix_tor_parameter_handling
Browse files Browse the repository at this point in the history
net: Correct -tor argument handling
  • Loading branch information
jamescowens authored Feb 27, 2024
2 parents 7a6e722 + 076362d commit 695cb6a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,15 +1144,22 @@ bool AppInit2(ThreadHandlerPtr threads)
}

// -tor can override normal proxy, -notor disables Tor entirely
if (gArgs.IsArgSet("-tor") && (fProxy || gArgs.IsArgSet("-tor"))) {
proxyType addrOnion;
if (!gArgs.IsArgSet("-tor")) {
addrOnion = addrProxy;
if (gArgs.IsArgSet("-tor")) {
CService addrOnion;

// If -tor is specified without any argument, and proxy was specified, then override proxy with tor
// at same address and port.
if (gArgs.GetArg("-tor", "") == "") {
if (fProxy) {
addrOnion = addrProxy;
}
} else {
CService addrProxy(LookupNumeric(gArgs.GetArg("-tor", "").c_str(), 9050));
addrOnion = CService(LookupNumeric(gArgs.GetArg("-tor", "").c_str(), 9050));
}

if (!addrOnion.IsValid()) {
return InitError(strprintf(_("Invalid -tor address: '%s'"), gArgs.GetArg("-tor", gArgs.GetArg("-proxy", ""))));
}
if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -tor address: '%s'"), gArgs.GetArg("-tor", "")));
SetProxy(NET_TOR, addrOnion);
SetReachable(NET_TOR, true);
}
Expand Down

0 comments on commit 695cb6a

Please sign in to comment.