diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2016-05-31 13:05:52 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2016-07-31 13:24:07 -0400 |
commit | 31d6b1d5f0414d8b356d8cb9c99961d8a04d6c0a (patch) | |
tree | e1044a96d479c66c639528276d54f674b5103ae8 /src/netbase.cpp | |
parent | 6caf3ee061a86d89b965dc8a61a95d1f34015805 (diff) |
net: Split resolving out of CNetAddr
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index e2a516986c..bb16dd0439 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -195,6 +195,16 @@ bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nM return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup); } +bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup) +{ + std::vector<CNetAddr> vIP; + LookupHost(pszName, vIP, 1, fAllowLookup); + if(vIP.empty()) + return false; + addr = vIP.front(); + return true; +} + bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions) { if (pszName[0] == 0) @@ -695,22 +705,6 @@ CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope) scopeId = scope; } -CNetAddr::CNetAddr(const char *pszIp) -{ - Init(); - std::vector<CNetAddr> vIP; - if (LookupHost(pszIp, vIP, 1, false)) - *this = vIP[0]; -} - -CNetAddr::CNetAddr(const std::string &strIp) -{ - Init(); - std::vector<CNetAddr> vIP; - if (LookupHost(strIp.c_str(), vIP, 1, false)) - *this = vIP[0]; -} - unsigned int CNetAddr::GetByte(int n) const { return ip[15-n]; |