mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-05 23:30:27 +08:00
Two gateway modules each decided whether a resolved address is public, and they disagreed. The provider copy rejected loopback, link-local, private and carrier-grade NAT ranges but accepted 192.0.0.0/16, 198.18.0.0/15, 2001:0::/32 (Teredo), 2001:db8::/32 (documentation) and 2002::/16 (6to4). The brand capture copy rejected all of those. Both are fetch paths that resolve a hostname and then pin the result, and both are reached with a URL that a user or a project supplies, so a looser answer in one of them is exactly where the difference matters. Two copies of the same predicate also drift by construction: the brand copy gained these ranges at some point and the provider copy did not. The stricter predicate is now one exported function in gateway/network.ts, and brand capture imports it instead of keeping a second implementation. Review follow-ups are included: the isIP import stays, because brandWebsite still resolves its own hostname; the IPv6 check reads the parsed hextets instead of matching literal spellings, so 2001::1 is treated as Teredo; and the IPv4 special-use branch is limited to 192.0.0.0/24 and 192.0.2.0/24 rather than all of 192.0.0.0/16, so a legitimate provider on that range keeps working. Validation: the new test asserts providerOrigin rejects 6to4, Teredo (both spellings), documentation, benchmark and link-local literals while accepting global unicast IPv6 and 192.0.78.1, that both entry points agree on the same address list, and that brandWebsite still validates and returns a public website. tests/brand-kits.test.ts passes 13/13 and npm run check passes.