- 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
29 lines
627 B
Go
29 lines
627 B
Go
package asinfo_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.eeqj.de/sneak/routewatch/pkg/asinfo"
|
|
)
|
|
|
|
func ExampleGet() {
|
|
info, ok := asinfo.Get(15169)
|
|
if ok {
|
|
fmt.Printf("AS%d: %s - %s\n", info.ASN, info.Handle, info.Description)
|
|
}
|
|
// Output: AS15169: GOOGLE - Google LLC
|
|
}
|
|
|
|
func ExampleGetDescription() {
|
|
desc := asinfo.GetDescription(13335)
|
|
fmt.Println(desc)
|
|
// Output: Cloudflare, Inc.
|
|
}
|
|
|
|
func ExampleSearch() {
|
|
results := asinfo.Search("MIT-GATEWAY")
|
|
for _, info := range results {
|
|
fmt.Printf("AS%d: %s - %s\n", info.ASN, info.Handle, info.Description)
|
|
}
|
|
// Output: AS3: MIT-GATEWAYS - Massachusetts Institute of Technology
|
|
} |