| 142 | } |
| 143 | |
| 144 | static 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 | |
| 173 | std::vector<CNetAddr> LookupHost(const std::string& name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function) |
| 174 | { |
no test coverage detected