mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 19:47:30 -03:00
Merge bitcoin/bitcoin#26145: [24.x] init: abort if i2p/cjdns are chosen via -onlynet but are unreachable
68209a7b5c
rpc: make addpeeraddress work with cjdns addresses (Martin Zumsande)a8a9ed67cc
init: Abort if i2p/cjdns are chosen via -onlynet but unreachable (Martin Zumsande) Pull request description: Identical commit from https://github.com/bitcoin/bitcoin/pull/25989 ACKs for top commit: fanquake: ACK68209a7b5c
Tree-SHA512: eec335df06b4c209cfe3473cb623828effd00c45a5dd605bb920edd265de1c789627482b005a51e89b8fc79cc4c5d26ff1fc306f2e4573897c5c7f083aa22861
This commit is contained in:
commit
05f7937810
4 changed files with 23 additions and 1 deletions
10
src/init.cpp
10
src/init.cpp
|
@ -1285,6 +1285,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:
|
||||
|
@ -1757,6 +1762,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ bool SeenLocal(const CService& addr);
|
|||
bool IsLocal(const CService& addr);
|
||||
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = nullptr);
|
||||
CService GetLocalAddress(const CNetAddr& addrPeer);
|
||||
CService MaybeFlipIPv6toCJDNS(const CService& service);
|
||||
|
||||
|
||||
extern bool fDiscover;
|
||||
|
|
|
@ -947,7 +947,8 @@ static RPCHelpMan addpeeraddress()
|
|||
bool success{false};
|
||||
|
||||
if (LookupHost(addr_string, net_addr, false)) {
|
||||
CAddress address{{net_addr, port}, ServiceFlags{NODE_NETWORK | NODE_WITNESS}};
|
||||
CService service{net_addr, port};
|
||||
CAddress address{MaybeFlipIPv6toCJDNS(service), ServiceFlags{NODE_NETWORK | NODE_WITNESS}};
|
||||
address.nTime = Now<NodeSeconds>();
|
||||
// The source address is set equal to the address. This is equivalent to the peer
|
||||
// announcing itself.
|
||||
|
|
|
@ -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 "
|
||||
|
|
Loading…
Add table
Reference in a new issue