MCPcopy Create free account
hub / github.com/ElementsProject/elements / LookupIntern

Function LookupIntern

src/netbase.cpp:135–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

LookupHostFunction · 0.85
LookupFunction · 0.85

Calls 6

ValidAsCStringFunction · 0.85
SetSpecialMethod · 0.80
IsInternalMethod · 0.80
clearMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected