Documentation
¶
Overview ¶
Package network provides IP address and network utilities for MMDB processing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IPv4ToUint32 ¶
IPv4ToUint32 converts an IPv4 address to uint32.
func IPv6BucketToInt64 ¶ added in v0.2.0
IPv6BucketToInt64 converts the first 60 bits of an IPv6 address to int64.
NOTE: The address must already be masked to the appropriate bucket (i.e., if you have a bucket size of /16, you must provide 2001:: as opposed to something like 2001:abcd::).
We use 60 bits (not 64) because 60-bit values always fit in a positive int64, which simplifies queries (no two's complement handling needed).
We use 60 bits in particular as that is what 15 hex characters provides. This is already more bits than we'd typically need.
In BigQuery, you can compute the same value using:
CAST(CONCAT('0x', SUBSTR(
TO_HEX(NET.IP_TRUNC(NET.IP_FROM_STRING(ip), bucket_size)), 1, 15
)) AS INT64)
where bucket_size is the prefix length used for bucketing.
func IsAdjacent ¶
IsAdjacent checks if two IP addresses are consecutive (no gap between them).
func SmallestNetwork ¶
SmallestNetwork returns the smaller (more specific) of two overlapping network prefixes.
Types ¶
This section is empty.