21 std::vector<unsigned char>
vchRet;
27 for (
int i = 0; i < 4; i++) {
28 vchRet.push_back((
asn >> (8 * i)) & 0xFF);
52 }
else if (address.
IsTor() || address.
IsI2P()) {
94 for (
int i = 0; i < 4; ++i) {
95 ip_bytes[12 + i] = std::byte((
ipv4 >> (24 - i * 8)) & 0xFF);
102 std::copy_n(std::as_bytes(std::span{
addr_bytes}).begin(),
Network GetNetClass() const
std::vector< unsigned char > GetAddrBytes() const
bool HasLinkedIPv4() const
Whether this address has a linked IPv4 address (see GetLinkedIPv4()).
uint32_t GetLinkedIPv4() const
For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv...
uint256 GetAsmapVersion() const
Get the asmap version, a checksum identifying the asmap being used.
bool UsingASMap() const
Indicates whether ASMap is being used for clearnet bucketing.
void ASMapHealthCheck(const std::vector< CNetAddr > &clearnet_addrs) const
Analyze and log current health of ASMap based buckets.
const std::span< const std::byte > m_asmap
Compressed IP->ASN mapping.
std::vector< unsigned char > GetGroup(const CNetAddr &address) const
Get the canonical identifier of the network group for address.
uint32_t GetMappedAS(const CNetAddr &address) const
Get the autonomous system on the BGP path to address.
static constexpr size_t ADDR_INTERNAL_SIZE
Size of "internal" (NET_INTERNAL) address (in bytes).
static const std::array< uint8_t, 6 > INTERNAL_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded "internal" address.
static const std::array< uint8_t, 12 > IPV4_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded IPv4 address.
uint32_t Interpret(const std::span< const std::byte > asmap, const std::span< const std::byte > ip)
Execute the ASMap bytecode to find the ASN for an IP.
uint256 AsmapVersion(const std::span< const std::byte > data)
Computes SHA256 hash of ASMap data for versioning and consistency checks.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.