Documentation ¶
Overview ¶
Package asndb implement asn lookup and data handling. This library will handle tsv data sourced from https://iptoasn.com.
The data can be downloaded via DownloadFromURL(DownloadViaIpToAsn), which then parsed using LoadFromTSV(), that can be used to initiate a ASList or ASNMap.
Index ¶
Constants ¶
const DownloadViaIpToAsn = "https://iptoasn.com/data/ip2asn-combined.tsv.gz"
Variables ¶
This section is empty.
Functions ¶
func DownloadFromURL ¶
func DownloadFromURL(url string) (io.ReadCloser, error)
Types ¶
type AS ¶
type AS struct { StartIP netip.Addr EndIP netip.Addr ASNumber int CountryCode string ASDescription string }
AS contains information about an AS zone belonging to an ASNumber. the StartIP and EndIP denotes a range that belongs to the AS.
type ASList ¶
type ASList struct {
// contains filtered or unexported fields
}
ASList holds a list of AS zones.
func NewASList ¶
NewASList creates a new registry from the given list of AS zones. The given slice will be cloned and sorted by StartIP.
func (*ASList) Find ¶
Find finds and returns the AS zone for a given IP address. Bool indicates if AS is valid and found Notice: if multiple zones claims an IP, the closest AS zone gets returned.
func (*ASList) FindList ¶
FindList attempts to find and return neighbouring AS that contain given ip address. search dictate how many invalid AS zones to skip before returning. This method is only useful when an IP has been claimed by multiple AS zones.
func (*ASList) FromIndex ¶
FromIndex returns an AS zone at a given index. Returns false if the index is out of bounds.