Look up IP addresses by prefix at each mask length (closes #48)
check / check (push) Successful in 2m55s

Looking up an address read every IPv6 live route and, for IPv4, about
half of the range index. Both families now look the address's prefix up
at each mask length, longest first, on the prefix index: at most 33 or
129 indexed lookups, however many routes are live.

The feed sends IPv6 withdrawals uncompressed but announcements
compressed, so the prefix handler now stores every prefix in the text
form net/netip prints, the form the lookup builds. IPv6 withdrawals now
remove their routes.

The IPv4 range columns, their index and the code that fills them are
removed, and so are the unused GetASInfoForIP lookups.

Model: opus-5-5
This commit is contained in:
2026-10-03 12:53:16 +00:00
parent 7322f936e4
commit b93cd29ab0
11 changed files with 247 additions and 705 deletions
-13
View File
@@ -77,9 +77,6 @@ type LiveRoute struct {
ASPath []int `json:"as_path"`
NextHop string `json:"next_hop"`
LastUpdated time.Time `json:"last_updated"`
// IPv4 range fields for fast lookups (nil for IPv6)
V4IPStart *uint32 `json:"v4_ip_start,omitempty"`
V4IPEnd *uint32 `json:"v4_ip_end,omitempty"`
}
// PrefixDistribution represents the distribution of prefixes by mask length
@@ -88,16 +85,6 @@ type PrefixDistribution struct {
Count int `json:"count"`
}
// ASInfo represents AS information for an IP lookup (legacy format)
type ASInfo struct {
ASN int `json:"asn"`
Handle string `json:"handle"`
Description string `json:"description"`
Prefix string `json:"prefix"`
LastUpdated time.Time `json:"last_updated"`
Age string `json:"age"`
}
// IPInfo represents comprehensive IP information for the /ip endpoint
type IPInfo struct {
IP string `json:"ip"`