MCPcopy Create free account
hub / github.com/LUX-Core/lux / LookupIntern

Function LookupIntern

src/netbase.cpp:99–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99bool static LookupIntern(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
100{
101 vIP.clear();
102
103 {
104 CNetAddr addr;
105 if (addr.SetSpecial(std::string(pszName))) {
106 vIP.push_back(addr);
107 return true;
108 }
109 }
110
111/*#ifdef HAVE_GETADDRINFO_A
112 struct in_addr ipv4_addr;
113#ifdef HAVE_INET_PTON
114 if (inet_pton(AF_INET, pszName, &ipv4_addr) > 0) {
115 vIP.push_back(CNetAddr(ipv4_addr));
116 return true;
117 }
118
119 struct in6_addr ipv6_addr;
120 if (inet_pton(AF_INET6, pszName, &ipv6_addr) > 0) {
121 vIP.push_back(CNetAddr(ipv6_addr));
122 return true;
123 }
124#else
125 ipv4_addr.s_addr = inet_addr(pszName);
126 if (ipv4_addr.s_addr != INADDR_NONE) {
127 vIP.push_back(CNetAddr(ipv4_addr));
128 return true;
129 }
130#endif
131#endif*/
132
133 struct addrinfo aiHint;
134 memset(&aiHint, 0, sizeof(struct addrinfo));
135 aiHint.ai_socktype = SOCK_STREAM;
136 aiHint.ai_protocol = IPPROTO_TCP;
137 aiHint.ai_family = AF_UNSPEC;
138#ifdef WIN32
139 aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
140#else
141 aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
142#endif
143
144 struct addrinfo* aiRes = NULL;
145/*#ifdef HAVE_GETADDRINFO_A
146 struct gaicb gcb, *query = &gcb;
147 memset(query, 0, sizeof(struct gaicb));
148 gcb.ar_name = pszName;
149 gcb.ar_request = &aiHint;
150 int nErr = getaddrinfo_a(GAI_NOWAIT, &query, 1, NULL);
151 if (nErr)
152 return false;
153
154 do {
155 // Should set the timeout limit to a resonable value to avoid
156 // generating unnecessary checking call during the polling loop,

Callers 2

LookupHostFunction · 0.85
LookupFunction · 0.85

Calls 5

SetSpecialMethod · 0.80
CNetAddrClass · 0.70
clearMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected