mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
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.
This commit is contained in:
parent
55e1deb745
commit
a8a9ed67cc
2 changed files with 20 additions and 0 deletions
10
src/init.cpp
10
src/init.cpp
|
@ -1284,6 +1284,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.IsArgSet("-cjdnsreachable")) {
|
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);
|
SetReachable(NET_CJDNS, false);
|
||||||
}
|
}
|
||||||
// Now IsReachable(NET_CJDNS) is true if:
|
// Now IsReachable(NET_CJDNS) is true if:
|
||||||
|
@ -1756,6 +1761,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
}
|
}
|
||||||
SetProxy(NET_I2P, Proxy{addr});
|
SetProxy(NET_I2P, Proxy{addr});
|
||||||
} else {
|
} 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);
|
SetReachable(NET_I2P, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,6 +332,16 @@ class ProxyTest(BitcoinTestFramework):
|
||||||
msg = "Error: Invalid -i2psam address or hostname: 'def:xyz'"
|
msg = "Error: Invalid -i2psam address or hostname: 'def:xyz'"
|
||||||
self.nodes[1].assert_start_raises_init_error(expected_msg=msg)
|
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")
|
self.log.info("Test passing -onlynet=onion with -onion=0/-noonion raises expected init error")
|
||||||
msg = (
|
msg = (
|
||||||
"Error: Outbound connections restricted to Tor (-onlynet=onion) but "
|
"Error: Outbound connections restricted to Tor (-onlynet=onion) but "
|
||||||
|
|
Loading…
Add table
Reference in a new issue