* Create an "internal" address that represents a name or FQDN. AddrMan uses * these fake addresses to keep track of which DNS seeds were used. * @returns Whether or not the operation was successful. * @see NET_INTERNAL, INTERNAL_IN_IPV6_PREFIX, CNetAddr::IsInternal(), CNetAddr::IsRFC4193() */
| 171 | * @see NET_INTERNAL, INTERNAL_IN_IPV6_PREFIX, CNetAddr::IsInternal(), CNetAddr::IsRFC4193() |
| 172 | */ |
| 173 | bool CNetAddr::SetInternal(const std::string &name) |
| 174 | { |
| 175 | if (name.empty()) { |
| 176 | return false; |
| 177 | } |
| 178 | m_net = NET_INTERNAL; |
| 179 | unsigned char hash[32] = {}; |
| 180 | CSHA256().Write((const unsigned char*)name.data(), name.size()).Finalize(hash); |
| 181 | m_addr.assign(hash, hash + ADDR_INTERNAL_SIZE); |
| 182 | return true; |
| 183 | } |
| 184 | |
| 185 | namespace torv3 { |
| 186 | // https://gitweb.torproject.org/torspec.git/tree/rend-spec-v3.txt#n2135 |