aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-02-15 15:31:08 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-02-15 15:31:15 +0100
commit489030f2a8f89e7ae5031351fc3d0db83e3911ea (patch)
tree8b168f1aa274bf0c6d9a8eb85c604cc2577a55bf /src/netbase.cpp
parentcb073bed0056d113fede4510ec68c5a6141ca997 (diff)
parent96635e61777add29b6a34d47767a63f43b2919af (diff)
Merge #20965: net, rpc: return NET_UNROUTABLE as not_publicly_routable, automate helps
96635e61777add29b6a34d47767a63f43b2919af init: use GetNetworkNames() in -onlynet help (Jon Atack) 0dbde700a6e9894a8ead20f2eebd0ff6554ef2d9 rpc: use GetNetworkNames() in getnetworkinfo and getpeerinfo helps (Jon Atack) 1c3af37881adbbc37fb9924bcf69c403fcae1ae7 net: create GetNetworkNames() (Jon Atack) b45eae4d5332f1da71ba9ec983fe7818fa4d32e9 net: update NET_UNROUTABLE to not_publicly_routable in GetNetworkName() (Jon Atack) Pull request description: per the IRC discussion today at http://www.erisian.com.au/bitcoin-core-dev/log-2021-01-19.html#l-87 - return a more helpful string name for `Network::NET_UNROUTABLE`: "not_publicly_routable" instead of "unroutable" - update the RPC getpeerinfo "network" help, and automate it and the getnetworkinfo "network#name" and the -onlynet help doc generation ACKs for top commit: theStack: re-ACK 96635e61777add29b6a34d47767a63f43b2919af 🌳 MarcoFalke: review ACK 96635e61777add29b6a34d47767a63f43b2919af 🐗 Tree-SHA512: 511a7d987126b48a7a090739aa7c4964b6186a3ff8f5f7eec9233dd816c6b7a6dc91b3ea6b824aa68f218a8a3ebdc6ffd214e9a88af38f2bf23f3257c4284c3a
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 24188f83c6..0c5b3a220e 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -59,7 +59,7 @@ enum Network ParseNetwork(const std::string& net_in) {
std::string GetNetworkName(enum Network net)
{
switch (net) {
- case NET_UNROUTABLE: return "unroutable";
+ case NET_UNROUTABLE: return "not_publicly_routable";
case NET_IPV4: return "ipv4";
case NET_IPV6: return "ipv6";
case NET_ONION: return "onion";
@@ -72,6 +72,20 @@ std::string GetNetworkName(enum Network net)
assert(false);
}
+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) continue;
+ names.emplace_back(GetNetworkName(network));
+ }
+ if (append_unroutable) {
+ names.emplace_back(GetNetworkName(NET_UNROUTABLE));
+ }
+ return names;
+}
+
bool static LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
{
vIP.clear();