| 133 | } |
| 134 | |
| 135 | static 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 | |
| 170 | bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function) |
| 171 | { |
no test coverage detected