|
|
@ -614,11 +614,13 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest |
|
|
|
proxyType nameProxy; |
|
|
|
proxyType nameProxy; |
|
|
|
GetNameProxy(nameProxy); |
|
|
|
GetNameProxy(nameProxy); |
|
|
|
|
|
|
|
|
|
|
|
CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port); |
|
|
|
CService addrResolved; |
|
|
|
|
|
|
|
if (Lookup(strDest.c_str(), addrResolved, port, fNameLookup && !HaveNameProxy())) { |
|
|
|
if (addrResolved.IsValid()) { |
|
|
|
if (addrResolved.IsValid()) { |
|
|
|
addr = addrResolved; |
|
|
|
addr = addrResolved; |
|
|
|
return ConnectSocket(addr, hSocketRet, nTimeout); |
|
|
|
return ConnectSocket(addr, hSocketRet, nTimeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addr = CService("0.0.0.0:0"); |
|
|
|
addr = CService("0.0.0.0:0"); |
|
|
|
|
|
|
|
|
|
|
@ -686,19 +688,19 @@ CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope) |
|
|
|
scopeId = scope; |
|
|
|
scopeId = scope; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CNetAddr::CNetAddr(const char *pszIp, bool fAllowLookup) |
|
|
|
CNetAddr::CNetAddr(const char *pszIp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Init(); |
|
|
|
Init(); |
|
|
|
std::vector<CNetAddr> vIP; |
|
|
|
std::vector<CNetAddr> vIP; |
|
|
|
if (LookupHost(pszIp, vIP, 1, fAllowLookup)) |
|
|
|
if (LookupHost(pszIp, vIP, 1, false)) |
|
|
|
*this = vIP[0]; |
|
|
|
*this = vIP[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup) |
|
|
|
CNetAddr::CNetAddr(const std::string &strIp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Init(); |
|
|
|
Init(); |
|
|
|
std::vector<CNetAddr> vIP; |
|
|
|
std::vector<CNetAddr> vIP; |
|
|
|
if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup)) |
|
|
|
if (LookupHost(strIp.c_str(), vIP, 1, false)) |
|
|
|
*this = vIP[0]; |
|
|
|
*this = vIP[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1121,35 +1123,35 @@ bool CService::SetSockAddr(const struct sockaddr *paddr) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CService::CService(const char *pszIpPort, bool fAllowLookup) |
|
|
|
CService::CService(const char *pszIpPort) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Init(); |
|
|
|
Init(); |
|
|
|
CService ip; |
|
|
|
CService ip; |
|
|
|
if (Lookup(pszIpPort, ip, 0, fAllowLookup)) |
|
|
|
if (Lookup(pszIpPort, ip, 0, false)) |
|
|
|
*this = ip; |
|
|
|
*this = ip; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup) |
|
|
|
CService::CService(const char *pszIpPort, int portDefault) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Init(); |
|
|
|
Init(); |
|
|
|
CService ip; |
|
|
|
CService ip; |
|
|
|
if (Lookup(pszIpPort, ip, portDefault, fAllowLookup)) |
|
|
|
if (Lookup(pszIpPort, ip, portDefault, false)) |
|
|
|
*this = ip; |
|
|
|
*this = ip; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CService::CService(const std::string &strIpPort, bool fAllowLookup) |
|
|
|
CService::CService(const std::string &strIpPort) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Init(); |
|
|
|
Init(); |
|
|
|
CService ip; |
|
|
|
CService ip; |
|
|
|
if (Lookup(strIpPort.c_str(), ip, 0, fAllowLookup)) |
|
|
|
if (Lookup(strIpPort.c_str(), ip, 0, false)) |
|
|
|
*this = ip; |
|
|
|
*this = ip; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup) |
|
|
|
CService::CService(const std::string &strIpPort, int portDefault) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Init(); |
|
|
|
Init(); |
|
|
|
CService ip; |
|
|
|
CService ip; |
|
|
|
if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup)) |
|
|
|
if (Lookup(strIpPort.c_str(), ip, portDefault, false)) |
|
|
|
*this = ip; |
|
|
|
*this = ip; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1243,7 +1245,7 @@ CSubNet::CSubNet(): |
|
|
|
memset(netmask, 0, sizeof(netmask)); |
|
|
|
memset(netmask, 0, sizeof(netmask)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CSubNet::CSubNet(const std::string &strSubnet, bool fAllowLookup) |
|
|
|
CSubNet::CSubNet(const std::string &strSubnet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
size_t slash = strSubnet.find_last_of('/'); |
|
|
|
size_t slash = strSubnet.find_last_of('/'); |
|
|
|
std::vector<CNetAddr> vIP; |
|
|
|
std::vector<CNetAddr> vIP; |
|
|
@ -1253,7 +1255,7 @@ CSubNet::CSubNet(const std::string &strSubnet, bool fAllowLookup) |
|
|
|
memset(netmask, 255, sizeof(netmask)); |
|
|
|
memset(netmask, 255, sizeof(netmask)); |
|
|
|
|
|
|
|
|
|
|
|
std::string strAddress = strSubnet.substr(0, slash); |
|
|
|
std::string strAddress = strSubnet.substr(0, slash); |
|
|
|
if (LookupHost(strAddress.c_str(), vIP, 1, fAllowLookup)) |
|
|
|
if (LookupHost(strAddress.c_str(), vIP, 1, false)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
network = vIP[0]; |
|
|
|
network = vIP[0]; |
|
|
|
if (slash != strSubnet.npos) |
|
|
|
if (slash != strSubnet.npos) |
|
|
|