check / check (push) Waiting to run
The AS Name Search card on the home page said the search was coming soon.
It now asks the new GET /api/v1/search/as?q=<text> and lists the matches
as links to their AS pages. asinfo.Search ignores case, returns the first
matches up to a limit in AS number order, and counts all matches. An
empty q answers 400.
When the database has no record of an AS, its page and /api/v1/as/{asn}
take its handle and description from asinfo and still list its prefixes.
They answer 404 only for an AS with no record, no asinfo entry and no
prefix. AS 0 means no known origin: it always answers 404, and the search
never lists it.
Model: opus-5-5
31 lines
994 B
Go
31 lines
994 B
Go
/*
|
|
Package asinfo provides information about Autonomous Systems (AS).
|
|
|
|
The package embeds a comprehensive database of AS numbers, handles, and descriptions
|
|
sourced from https://github.com/ipverse/asn-info. The data is embedded at compile
|
|
time and provides fast, offline lookups.
|
|
|
|
Basic usage:
|
|
|
|
// Get information about an AS
|
|
info, ok := asinfo.Get(15169)
|
|
if ok {
|
|
fmt.Printf("AS%d: %s - %s\n", info.ASN, info.Handle, info.Description)
|
|
}
|
|
|
|
// Get just the description
|
|
desc := asinfo.GetDescription(15169) // "Google LLC"
|
|
|
|
// Search the handles and descriptions, ignoring case, for the first 10
|
|
// matches in AS number order and the number of all matches
|
|
results, total := asinfo.Search("university", 10)
|
|
fmt.Printf("%d matches\n", total)
|
|
for _, as := range results {
|
|
fmt.Printf("AS%d: %s\n", as.ASN, as.Description)
|
|
}
|
|
|
|
The data is loaded lazily on first access and cached in memory for the lifetime
|
|
of the program. All getter methods are safe for concurrent use.
|
|
*/
|
|
package asinfo
|