Skip to content

Commit

Permalink
Add GetNetworkName function
Browse files Browse the repository at this point in the history
Returns the network name for an Network enum.
  • Loading branch information
laanwj committed Jul 30, 2014
1 parent c91a947 commit 075cf49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ enum Network ParseNetwork(std::string net) {
return NET_UNROUTABLE;
}

std::string GetNetworkName(enum Network net) {
switch(net)
{
case NET_IPV4: return "ipv4";
case NET_IPV6: return "ipv6";
case NET_TOR: return "onion";
default: return "";
}
}

void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
size_t colon = in.find_last_of(':');
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
Expand Down
3 changes: 2 additions & 1 deletion src/netbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern bool fNameLookup;

enum Network
{
NET_UNROUTABLE,
NET_UNROUTABLE = 0,
NET_IPV4,
NET_IPV6,
NET_TOR,
Expand Down Expand Up @@ -164,6 +164,7 @@ class CService : public CNetAddr
typedef CService proxyType;

enum Network ParseNetwork(std::string net);
std::string GetNetworkName(enum Network net);
void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
bool SetProxy(enum Network net, CService addrProxy);
bool GetProxy(enum Network net, proxyType &proxyInfoOut);
Expand Down

0 comments on commit 075cf49

Please sign in to comment.