Add asinfo package for AS number information lookups
- Created pkg/asinfo with embedded AS data from ipverse/asn-info - Provides fast lookups by ASN with GetDescription() and GetHandle() - Includes Search() functionality for finding AS by name/handle - Added asinfo-gen tool to fetch and convert CSV data to JSON - Added 'make asupdate' target to refresh AS data - Embedded JSON data contains 130k+ AS entries - Added comprehensive tests and examples
This commit is contained in:
28
pkg/asinfo/doc.go
Normal file
28
pkg/asinfo/doc.go
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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 for AS entries
|
||||
results := asinfo.Search("University")
|
||||
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
|
||||
Reference in New Issue
Block a user