diff --git a/src/init.cpp b/src/init.cpp index 286d5d11eb..5cb0bff00c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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); }