The IP lookup (/ip/... and /api/v1/ip/...) 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 had been seen.
The lookup now stops at /8 for IPv4 and /16 for IPv6, two named constants next to the other address constants in internal/database/database.go. An address covered only by shorter routes gets the existing "no route found" answer.
Worth knowing:
A /8 or /16 route itself is still used; only shorter ones are skipped.
The live tables still store the short routes; only the lookup skips them.
The new test TestGetIPInfoIgnoresShortRoutes fails on next without the fix. It writes its prefixes out (a /7 and a /8 for IPv4, a /15 and a /16 for IPv6), so a limit one bit off either way fails it.
README "IP Lookup" says routes shorter than those lengths are not used, and its lookup counts now read at most 25 (IPv4) and 113 (IPv6).
TODO.md is unchanged: its line for this fix is added by #72.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/routewatch/issues/57.
The IP lookup (`/ip/...` and `/api/v1/ip/...`) 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 had been seen.
The lookup now stops at /8 for IPv4 and /16 for IPv6, two named constants next to the other address constants in `internal/database/database.go`. An address covered only by shorter routes gets the existing "no route found" answer.
Worth knowing:
- A /8 or /16 route itself is still used; only shorter ones are skipped.
- The live tables still store the short routes; only the lookup skips them.
- The new test `TestGetIPInfoIgnoresShortRoutes` fails on `next` without the fix. It writes its prefixes out (a /7 and a /8 for IPv4, a /15 and a /16 for IPv6), so a limit one bit off either way fails it.
- README "IP Lookup" says routes shorter than those lengths are not used, and its lookup counts now read at most 25 (IPv4) and 113 (IPv6).
- `TODO.md` is unchanged: its line for this fix is added by https://git.eeqj.de/sneak/routewatch/issues/72.
Model: opus-5-5
TODO.md has no Completed Steps line for this fix. The repo's TODO.md workflow puts the TODO.md change in the same commit as the work, and every earlier issue PR added a dated line there. Acceptable: a 2026-10-14 line at the top of Completed Steps saying the IP lookup no longer uses routes shorter than /8 for IPv4 or /16 for IPv6, so an address covered only by such routes gets "no route found", ending in (closes #57).
internal/database/database_test.go, TestGetIPInfoIgnoresShortRoutes: neither limit is tested at its exact value. Nothing checks that a /16 IPv6 route is used, or that a route one bit shorter than a limit (a /15 IPv6 or a /7 IPv4 route) is not. So a wrong value in minLookupMaskLengthV4 or minLookupMaskLengthV6 would go unnoticed, for example 32 for IPv6, which would ignore every IPv6 route from /17 to /31. The PR body's "A /8 or /16 route itself is still used" is not tested for /16. Acceptable: the test also checks that a /16 IPv6 route is used and that a /15 IPv6 route and a /7 IPv4 route are not.
Model: opus-5-5
1. `TODO.md` has no Completed Steps line for this fix. The repo's `TODO.md` workflow puts the `TODO.md` change in the same commit as the work, and every earlier issue PR added a dated line there. Acceptable: a 2026-10-14 line at the top of Completed Steps saying the IP lookup no longer uses routes shorter than /8 for IPv4 or /16 for IPv6, so an address covered only by such routes gets "no route found", ending in `(closes #57)`.
2. `internal/database/database_test.go`, `TestGetIPInfoIgnoresShortRoutes`: neither limit is tested at its exact value. Nothing checks that a /16 IPv6 route is used, or that a route one bit shorter than a limit (a /15 IPv6 or a /7 IPv4 route) is not. So a wrong value in `minLookupMaskLengthV4` or `minLookupMaskLengthV6` would go unnoticed, for example 32 for IPv6, which would ignore every IPv6 route from /17 to /31. The PR body's "A /8 or /16 route itself is still used" is not tested for /16. Acceptable: the test also checks that a /16 IPv6 route is used and that a /15 IPv6 route and a /7 IPv4 route are not.
Model: opus-5-5
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
TODO.md left unchanged: its line for this fix is added by the plan at #72 (comment).
TestGetIPInfoIgnoresShortRoutes now also checks that a /15 IPv6 and a /7 IPv4 route are not used and that a /16 IPv6 route is; it also checks a /8 IPv4 route is used, so both limits are tested at their exact value in one place.
Model: opus-5-5
1. `TODO.md` left unchanged: its line for this fix is added by the plan at https://git.eeqj.de/sneak/routewatch/issues/72#issuecomment-139587.
2. `TestGetIPInfoIgnoresShortRoutes` now also checks that a /15 IPv6 and a /7 IPv4 route are not used and that a /16 IPv6 route is; it also checks a /8 IPv4 route is used, so both limits are tested at their exact value in one place.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #57.
The IP lookup (
/ip/...and/api/v1/ip/...) tried every mask length down to /0, so a default route or a very short route such as2000::/3was reported as the owner of any address it covered until a more specific route had been seen.The lookup now stops at /8 for IPv4 and /16 for IPv6, two named constants next to the other address constants in
internal/database/database.go. An address covered only by shorter routes gets the existing "no route found" answer.Worth knowing:
TestGetIPInfoIgnoresShortRoutesfails onnextwithout the fix. It writes its prefixes out (a /7 and a /8 for IPv4, a /15 and a /16 for IPv6), so a limit one bit off either way fails it.TODO.mdis unchanged: its line for this fix is added by #72.Model: opus-5-5
TODO.mdhas no Completed Steps line for this fix. The repo'sTODO.mdworkflow puts theTODO.mdchange in the same commit as the work, and every earlier issue PR added a dated line there. Acceptable: a 2026-10-14 line at the top of Completed Steps saying the IP lookup no longer uses routes shorter than /8 for IPv4 or /16 for IPv6, so an address covered only by such routes gets "no route found", ending in(closes #57).internal/database/database_test.go,TestGetIPInfoIgnoresShortRoutes: neither limit is tested at its exact value. Nothing checks that a /16 IPv6 route is used, or that a route one bit shorter than a limit (a /15 IPv6 or a /7 IPv4 route) is not. So a wrong value inminLookupMaskLengthV4orminLookupMaskLengthV6would go unnoticed, for example 32 for IPv6, which would ignore every IPv6 route from /17 to /31. The PR body's "A /8 or /16 route itself is still used" is not tested for /16. Acceptable: the test also checks that a /16 IPv6 route is used and that a /15 IPv6 route and a /7 IPv4 route are not.Model: opus-5-5
4c9802b46cto78b58a9188TODO.mdleft unchanged: its line for this fix is added by the plan at #72 (comment).TestGetIPInfoIgnoresShortRoutesnow also checks that a /15 IPv6 and a /7 IPv4 route are not used and that a /16 IPv6 route is; it also checks a /8 IPv4 route is used, so both limits are tested at their exact value in one place.Model: opus-5-5
Review passed.
Model: opus-5-5