aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/init.cpp10
-rwxr-xr-xtest/functional/feature_proxy.py10
2 files changed, 20 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 20cb483a3a..606adb09a1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1284,6 +1284,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
if (!args.IsArgSet("-cjdnsreachable")) {
+ if (args.IsArgSet("-onlynet") && IsReachable(NET_CJDNS)) {
+ return InitError(
+ _("Outbound connections restricted to CJDNS (-onlynet=cjdns) but "
+ "-cjdnsreachable is not provided"));
+ }
SetReachable(NET_CJDNS, false);
}
// Now IsReachable(NET_CJDNS) is true if:
@@ -1756,6 +1761,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
SetProxy(NET_I2P, Proxy{addr});
} else {
+ if (args.IsArgSet("-onlynet") && IsReachable(NET_I2P)) {
+ return InitError(
+ _("Outbound connections restricted to i2p (-onlynet=i2p) but "
+ "-i2psam is not provided"));
+ }
SetReachable(NET_I2P, false);
}
diff --git a/test/functional/feature_proxy.py b/test/functional/feature_proxy.py
index d02d56d068..c90852562e 100755
--- a/test/functional/feature_proxy.py
+++ b/test/functional/feature_proxy.py
@@ -332,6 +332,16 @@ class ProxyTest(BitcoinTestFramework):
msg = "Error: Invalid -i2psam address or hostname: 'def:xyz'"
self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
+ self.log.info("Test passing invalid -onlynet=i2p without -i2psam raises expected init error")
+ self.nodes[1].extra_args = ["-onlynet=i2p"]
+ msg = "Error: Outbound connections restricted to i2p (-onlynet=i2p) but -i2psam is not provided"
+ self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
+
+ self.log.info("Test passing invalid -onlynet=cjdns without -cjdnsreachable raises expected init error")
+ self.nodes[1].extra_args = ["-onlynet=cjdns"]
+ msg = "Error: Outbound connections restricted to CJDNS (-onlynet=cjdns) but -cjdnsreachable is not provided"
+ self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
+
self.log.info("Test passing -onlynet=onion with -onion=0/-noonion raises expected init error")
msg = (
"Error: Outbound connections restricted to Tor (-onlynet=onion) but "