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
+5 -2
View File
@@ -142,7 +142,10 @@ routewatch/
- **Backpressure**: Probabilistic message dropping when queues exceed 50% capacity
- **Graceful Shutdown**: 60-second timeout, flushes all pending batches
- **Reconnection**: Exponential backoff (5s-320s) with reset after 30s of stable connection
- **IPv4 Optimization**: IP ranges stored as uint32 for O(1) lookups
- **IP Lookup**: the most specific live route is found by looking up the
address's prefix at each mask length, longest first, in the prefix index
(at most 33 lookups for IPv4, 129 for IPv6); prefixes are stored in the
text form Go's `net/netip` prints
### Database Schema
@@ -154,7 +157,7 @@ prefixes_v6(id, prefix, mask_length, first_seen, last_seen)
-- Live routing tables (one per IP version)
live_routes_v4(id, prefix, mask_length, origin_asn, peer_ip, as_path,
next_hop, last_updated, v4_ip_start, v4_ip_end)
next_hop, last_updated)
live_routes_v6(id, prefix, mask_length, origin_asn, peer_ip, as_path,
next_hop, last_updated)