Skip to content

Commit 075cf49

Browse files
committed
Add GetNetworkName function
Returns the network name for an Network enum.
1 parent c91a947 commit 075cf49

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/netbase.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ enum Network ParseNetwork(std::string net) {
5151
return NET_UNROUTABLE;
5252
}
5353

54+
std::string GetNetworkName(enum Network net) {
55+
switch(net)
56+
{
57+
case NET_IPV4: return "ipv4";
58+
case NET_IPV6: return "ipv6";
59+
case NET_TOR: return "onion";
60+
default: return "";
61+
}
62+
}
63+
5464
void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
5565
size_t colon = in.find_last_of(':');
5666
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator

src/netbase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern bool fNameLookup;
2626

2727
enum Network
2828
{
29-
NET_UNROUTABLE,
29+
NET_UNROUTABLE = 0,
3030
NET_IPV4,
3131
NET_IPV6,
3232
NET_TOR,
@@ -164,6 +164,7 @@ class CService : public CNetAddr
164164
typedef CService proxyType;
165165

166166
enum Network ParseNetwork(std::string net);
167+
std::string GetNetworkName(enum Network net);
167168
void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
168169
bool SetProxy(enum Network net, CService addrProxy);
169170
bool GetProxy(enum Network net, proxyType &proxyInfoOut);

0 commit comments

Comments
 (0)