Changeset View
Changeset View
Standalone View
Standalone View
src/netbase.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | static bool LookupIntern(const char *pszName, std::vector<CNetAddr> &vIP, | ||||
struct addrinfo aiHint; | struct addrinfo aiHint; | ||||
memset(&aiHint, 0, sizeof(struct addrinfo)); | memset(&aiHint, 0, sizeof(struct addrinfo)); | ||||
// We want a TCP port, which is a streaming socket type | // We want a TCP port, which is a streaming socket type | ||||
aiHint.ai_socktype = SOCK_STREAM; | aiHint.ai_socktype = SOCK_STREAM; | ||||
aiHint.ai_protocol = IPPROTO_TCP; | aiHint.ai_protocol = IPPROTO_TCP; | ||||
// We don't care which address family (IPv4 or IPv6) is returned | // We don't care which address family (IPv4 or IPv6) is returned | ||||
aiHint.ai_family = AF_UNSPEC; | aiHint.ai_family = AF_UNSPEC; | ||||
#ifdef WIN32 | |||||
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST; | |||||
#else | |||||
// If we allow lookups of hostnames, use the AI_ADDRCONFIG flag to only | // If we allow lookups of hostnames, use the AI_ADDRCONFIG flag to only | ||||
// return addresses whose family we have an address configured for. | // return addresses whose family we have an address configured for. | ||||
// | // | ||||
// If we don't allow lookups, then use the AI_NUMERICHOST flag for | // If we don't allow lookups, then use the AI_NUMERICHOST flag for | ||||
// getaddrinfo to only decode numerical network addresses and suppress | // getaddrinfo to only decode numerical network addresses and suppress | ||||
// hostname lookups. | // hostname lookups. | ||||
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; | aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; | ||||
#endif | |||||
struct addrinfo *aiRes = nullptr; | struct addrinfo *aiRes = nullptr; | ||||
int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes); | int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes); | ||||
if (nErr) { | if (nErr) { | ||||
return false; | return false; | ||||
} | } | ||||
// Traverse the linked list starting with aiTrav, add all non-internal | // Traverse the linked list starting with aiTrav, add all non-internal | ||||
// IPv4,v6 addresses to vIP while respecting nMaxSolutions. | // IPv4,v6 addresses to vIP while respecting nMaxSolutions. | ||||
▲ Show 20 Lines • Show All 887 Lines • Show Last 20 Lines |