routewatch/pkg/asinfo/example_test.go
sneak 585ff63fae Remove BGP keepalive logging and add peer tracking
- Created bgp_peers table to track all BGP peers
- Added PeerHandler to update peer last seen times for all message types
- Removed verbose BGP keepalive debug logging
- BGP keepalive messages now silently update peer tracking

Refactor HTML templates to use go:embed

- Created internal/templates package with embedded templates
- Moved status.html from inline const to separate file
- Templates are parsed once on startup
- Server now uses parsed template instead of raw string

Optimize AS data embedding with gzip compression

- Changed asinfo package to embed gzipped data (2.4MB vs 12MB)
- Updated Makefile to gzip AS data during update
- Added decompression during initialization
- Raw JSON file excluded from git
2025-07-27 21:54:58 +02:00

30 lines
628 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
}