Ignore routes shorter than /8 or /16 in the IP lookup (closes #57)
check / check (push) Canceled after 0s

The IP lookup tried every mask length down to /0, so a default route or
a very short route such as 2000::/3 was reported as the owner of any
address it covered until a more specific route was seen. Such a route
only says where a peer sends traffic it has no better route for.

The lookup now stops at /8 for IPv4 and /16 for IPv6; an address covered
only by shorter routes gets "no route found". The live tables still
store those routes. README states the limit.

Model: opus-5-5
This commit is contained in:
2026-10-14 13:29:23 +00:00
parent 00e51d284f
commit 78b58a9188
3 changed files with 92 additions and 8 deletions
+3 -2
View File
@@ -144,8 +144,9 @@ routewatch/
- **Reconnection**: Exponential backoff (5s-320s) with reset after 30s of stable connection
- **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
(at most 25 lookups for IPv4, 113 for IPv6); prefixes are stored in the
text form Go's `net/netip` prints. Routes shorter than /8 for IPv4 or /16
for IPv6, such as a default route, are not used.
### Database Schema