Skip to content

Commit

Permalink
net: recognize I2P from ParseNetwork() so that -onlynet=i2p works, do…
Browse files Browse the repository at this point in the history
… not skip I2P in GetNetworkNames()

Summary:
> net: recognize I2P from ParseNetwork() so that -onlynet=i2p works
bitcoin/bitcoin@0181e24

> net: Do not skip the I2P network from GetNetworkNames()
>
> So that help texts include "i2p" in:
> * `./bitcoind -help` (in `-onlynet` description)
> * `getpeerinfo` RPC
> * `getnetworkinfo` RPC
>
> Co-authored-by: Jon Atack <jon@atack.com>
bitcoin/bitcoin@a701fcf

This concludes backport of [[bitcoin/bitcoin#20685 | core#20685]] [19,20/20]
Depends on D11029 and D11036

Test Plan:
`ninja all check-all`

`src/bitcoind -regtest -i2psam=127.0.0.1:7656 -onlynet=i2p -debug=i2p`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11037
  • Loading branch information
vasild authored and PiRK committed Feb 15, 2022
1 parent e9e01ca commit 795cafd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ void SetupServerArgs(NodeContext &node) {
Join(GetNetworkNames(), ", ") +
"). Incoming connections are not affected by this option. This "
"option can be specified multiple times to allow multiple "
"networks. Warning: if it is used with ipv4 or ipv6 but not onion "
"networks. Warning: if it is used with non-onion networks "
"and the -onion or -proxy option is set, then outbound onion "
"connections will still be made; use -noonion or -onion=0 to "
"disable outbound onion connections in this case",
Expand Down
7 changes: 5 additions & 2 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ enum Network ParseNetwork(const std::string &net_in) {
"in the future. You should use 'onion' instead.\n");
return NET_ONION;
}
if (net == "i2p") {
return NET_I2P;
}
return NET_UNROUTABLE;
}

Expand Down Expand Up @@ -88,8 +91,8 @@ std::vector<std::string> GetNetworkNames(bool append_unroutable) {
std::vector<std::string> names;
for (int n = 0; n < NET_MAX; ++n) {
const enum Network network { static_cast<Network>(n) };
if (network == NET_UNROUTABLE || network == NET_I2P ||
network == NET_CJDNS || network == NET_INTERNAL) {
if (network == NET_UNROUTABLE || network == NET_CJDNS ||
network == NET_INTERNAL) {
continue;
}
names.emplace_back(GetNetworkName(network));
Expand Down
6 changes: 4 additions & 2 deletions test/functional/rpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def test_getnetworkinfo(self):

# Check dynamically generated networks list in getnetworkinfo help
# output.
assert "(ipv4, ipv6, onion)" in self.nodes[0].help("getnetworkinfo")
assert (
"(ipv4, ipv6, onion, i2p)" in self.nodes[0].help("getnetworkinfo")
)

def test_getaddednodeinfo(self):
self.log.info("Test getaddednodeinfo")
Expand Down Expand Up @@ -219,7 +221,7 @@ def test_getpeerinfo(self):

# Check dynamically generated networks list in getpeerinfo help output.
assert (
"(ipv4, ipv6, onion, not_publicly_routable)" in
"(ipv4, ipv6, onion, i2p, not_publicly_routable)" in
self.nodes[0].help("getpeerinfo")
)

Expand Down

0 comments on commit 795cafd

Please sign in to comment.