MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / LookupIntern

Function LookupIntern

src/netbase.cpp:144–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144static std::vector<CNetAddr> LookupIntern(const std::string& name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
145{
146 if (!ContainsNoNUL(name)) return {};
147 {
148 CNetAddr addr;
149 // From our perspective, onion addresses are not hostnames but rather
150 // direct encodings of CNetAddr much like IPv4 dotted-decimal notation
151 // or IPv6 colon-separated hextet notation. Since we can't use
152 // getaddrinfo to decode them and it wouldn't make sense to resolve
153 // them, we return a network address representing it instead. See
154 // CNetAddr::SetSpecial(const std::string&) for more details.
155 if (addr.SetSpecial(name)) return {addr};
156 }
157
158 std::vector<CNetAddr> addresses;
159
160 for (const CNetAddr& resolved : dns_lookup_function(name, fAllowLookup)) {
161 if (nMaxSolutions > 0 && addresses.size() >= nMaxSolutions) {
162 break;
163 }
164 /* Never allow resolving to an internal address. Consider any such result invalid */
165 if (!resolved.IsInternal()) {
166 addresses.push_back(resolved);
167 }
168 }
169
170 return addresses;
171}
172
173std::vector<CNetAddr> LookupHost(const std::string& name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
174{

Callers 2

LookupHostFunction · 0.85
LookupFunction · 0.85

Calls 5

ContainsNoNULFunction · 0.85
SetSpecialMethod · 0.80
IsInternalMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected