Add GetNetworkName function
Returns the network name for an Network enum.
This commit is contained in:
parent
c91a9471be
commit
075cf49e59
2 changed files with 12 additions and 1 deletions
|
@ -51,6 +51,16 @@ enum Network ParseNetwork(std::string net) {
|
||||||
return NET_UNROUTABLE;
|
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) {
|
void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
|
||||||
size_t colon = in.find_last_of(':');
|
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
|
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern bool fNameLookup;
|
||||||
|
|
||||||
enum Network
|
enum Network
|
||||||
{
|
{
|
||||||
NET_UNROUTABLE,
|
NET_UNROUTABLE = 0,
|
||||||
NET_IPV4,
|
NET_IPV4,
|
||||||
NET_IPV6,
|
NET_IPV6,
|
||||||
NET_TOR,
|
NET_TOR,
|
||||||
|
@ -164,6 +164,7 @@ class CService : public CNetAddr
|
||||||
typedef CService proxyType;
|
typedef CService proxyType;
|
||||||
|
|
||||||
enum Network ParseNetwork(std::string net);
|
enum Network ParseNetwork(std::string net);
|
||||||
|
std::string GetNetworkName(enum Network net);
|
||||||
void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
|
void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
|
||||||
bool SetProxy(enum Network net, CService addrProxy);
|
bool SetProxy(enum Network net, CService addrProxy);
|
||||||
bool GetProxy(enum Network net, proxyType &proxyInfoOut);
|
bool GetProxy(enum Network net, proxyType &proxyInfoOut);
|
||||||
|
|
Loading…
Reference in a new issue