Skip to content

Commit a8a9ed6

Browse files
committed
init: Abort if i2p/cjdns are chosen via -onlynet but unreachable
...because -i2psam or -cjdnsreachable are not provided. This mimics existing behavior for -onlynet=onion and non-specified proxy.
1 parent 55e1deb commit a8a9ed6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/init.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
12841284
}
12851285

12861286
if (!args.IsArgSet("-cjdnsreachable")) {
1287+
if (args.IsArgSet("-onlynet") && IsReachable(NET_CJDNS)) {
1288+
return InitError(
1289+
_("Outbound connections restricted to CJDNS (-onlynet=cjdns) but "
1290+
"-cjdnsreachable is not provided"));
1291+
}
12871292
SetReachable(NET_CJDNS, false);
12881293
}
12891294
// Now IsReachable(NET_CJDNS) is true if:
@@ -1756,6 +1761,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17561761
}
17571762
SetProxy(NET_I2P, Proxy{addr});
17581763
} else {
1764+
if (args.IsArgSet("-onlynet") && IsReachable(NET_I2P)) {
1765+
return InitError(
1766+
_("Outbound connections restricted to i2p (-onlynet=i2p) but "
1767+
"-i2psam is not provided"));
1768+
}
17591769
SetReachable(NET_I2P, false);
17601770
}
17611771

test/functional/feature_proxy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,16 @@ def networks_dict(d):
332332
msg = "Error: Invalid -i2psam address or hostname: 'def:xyz'"
333333
self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
334334

335+
self.log.info("Test passing invalid -onlynet=i2p without -i2psam raises expected init error")
336+
self.nodes[1].extra_args = ["-onlynet=i2p"]
337+
msg = "Error: Outbound connections restricted to i2p (-onlynet=i2p) but -i2psam is not provided"
338+
self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
339+
340+
self.log.info("Test passing invalid -onlynet=cjdns without -cjdnsreachable raises expected init error")
341+
self.nodes[1].extra_args = ["-onlynet=cjdns"]
342+
msg = "Error: Outbound connections restricted to CJDNS (-onlynet=cjdns) but -cjdnsreachable is not provided"
343+
self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
344+
335345
self.log.info("Test passing -onlynet=onion with -onion=0/-noonion raises expected init error")
336346
msg = (
337347
"Error: Outbound connections restricted to Tor (-onlynet=onion) but "

0 commit comments

Comments
 (0)