Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Correct -tor argument handling #2744

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 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())

if (!addrOnion.IsValid()) {
return InitError(strprintf(_("Invalid -tor address: '%s'"), gArgs.GetArg("-tor", "")));
jamescowens marked this conversation as resolved.
Show resolved Hide resolved
}
SetProxy(NET_TOR, addrOnion);
SetReachable(NET_TOR, true);
}
Expand Down
Loading