aboutsummaryrefslogtreecommitdiff
path: root/src/torcontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/torcontrol.cpp')
-rw-r--r--src/torcontrol.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 1bbced8cb6..7ae384ceb3 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -382,9 +382,24 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
// if -onion isn't set to something else.
if (gArgs.GetArg("-onion", "") == "") {
CService resolved(LookupNumeric("127.0.0.1", 9050));
- proxyType addrOnion = proxyType(resolved, true);
+ Proxy addrOnion = Proxy(resolved, true);
SetProxy(NET_ONION, addrOnion);
- SetReachable(NET_ONION, true);
+
+ const auto onlynets = gArgs.GetArgs("-onlynet");
+
+ const bool onion_allowed_by_onlynet{
+ !gArgs.IsArgSet("-onlynet") ||
+ std::any_of(onlynets.begin(), onlynets.end(), [](const auto& n) {
+ return ParseNetwork(n) == NET_ONION;
+ })};
+
+ if (onion_allowed_by_onlynet) {
+ // If NET_ONION is reachable, then the below is a noop.
+ //
+ // If NET_ONION is not reachable, then none of -proxy or -onion was given.
+ // Since we are here, then -torcontrol and -torpassword were given.
+ SetReachable(NET_ONION, true);
+ }
}
// Finally - now create the service