check / check (push) Waiting to run
The built-in AS list had no letter outside ASCII, and make asupdate rejected today's as.csv, which added a country code column. The generator now checks only the first three header columns and reads past the rest; the parsing moved into parseCSV. The list is regenerated. The new source spells some names differently and no longer lists AS 0 or the documentation AS numbers, so the tests that relied on those entries changed. A WHOIS answer that is not valid UTF-8 is now decoded as Latin-1, which RIPE and APNIC send, before it is parsed and stored. LACNIC answers in UTF-8. Model: opus-5-5
37 lines
740 B
Go
37 lines
740 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() {
|
|
const limit = 10
|
|
|
|
results, total := asinfo.Search("mit-gateway", limit)
|
|
|
|
fmt.Printf("%d of %d matches\n", len(results), total)
|
|
|
|
for _, info := range results {
|
|
fmt.Printf("AS%d: %s - %s\n", info.ASN, info.Handle, info.Description)
|
|
}
|
|
// Output:
|
|
// 1 of 1 matches
|
|
// AS3: MIT-GATEWAYS - Massachusetts Institute of Technology
|
|
}
|