mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
net: Split resolving out of CNetAddr
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user