Read a trusted_proxies entry in the IPv4-mapped form as its IPv4 range (closes #303) #305

Merged
clawbot merged 2 commits from issue-303-mapped-trusted-proxies into next 2026-10-19 05:29:06 +02:00
Collaborator

An entry such as ::ffff:10.0.0.0/104 in trusted_proxies was accepted but trusted nothing, because the client address is matched as the IPv4 address an IPv4-mapped address holds (#303). Such an entry is now read as the IPv4 range it covers (10.0.0.0/8), and one shorter than /96 stops startup with an error naming trusted_proxies.

blocked_networks has done this since #302, in a separate parseBlockedNetworks. I moved that conversion into parseCIDRList, which reads both settings, and removed parseBlockedNetworks; the error names whichever setting is being read. The trusted_proxies default list and how internal/clientip matches are unchanged.

README.md describes the mapped form under trusted_proxies in the words it uses for blocked_networks.

The first commit adds the two new tests, which fail on next; the second is the fix. The blocked_networks tests are unchanged.

Judgement call: the too-short error now quotes the entry as the operator wrote it (::ffff:0:0/95) rather than as Go prints it (::ffff:0.0.0.0/95), like the invalid-CIDR error next to it. This also changes the blocked_networks message for such an entry.

Model: opus-5-5

An entry such as `::ffff:10.0.0.0/104` in `trusted_proxies` was accepted but trusted nothing, because the client address is matched as the IPv4 address an IPv4-mapped address holds (https://git.eeqj.de/sneak/pixa/issues/303). Such an entry is now read as the IPv4 range it covers (`10.0.0.0/8`), and one shorter than `/96` stops startup with an error naming `trusted_proxies`. `blocked_networks` has done this since https://git.eeqj.de/sneak/pixa/pulls/302, in a separate `parseBlockedNetworks`. I moved that conversion into `parseCIDRList`, which reads both settings, and removed `parseBlockedNetworks`; the error names whichever setting is being read. The `trusted_proxies` default list and how `internal/clientip` matches are unchanged. `README.md` describes the mapped form under `trusted_proxies` in the words it uses for `blocked_networks`. The first commit adds the two new tests, which fail on `next`; the second is the fix. The `blocked_networks` tests are unchanged. Judgement call: the too-short error now quotes the entry as the operator wrote it (`::ffff:0:0/95`) rather than as Go prints it (`::ffff:0.0.0.0/95`), like the invalid-CIDR error next to it. This also changes the `blocked_networks` message for such an entry. Model: opus-5-5
clawbot added the needs-review label 2026-10-19 04:39:52 +02:00
clawbot self-assigned this 2026-10-19 04:39:52 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot removed the needs-review label 2026-10-19 05:00:13 +02:00
clawbot added 2 commits 2026-10-19 05:11:49 +02:00
These tests fail on next: ::ffff:10.0.0.0/104 is kept as written and so
never matches, and ::ffff:0:0/95 loads without an error. The fix follows
in the next commit.

Model: opus-5-5
The client address is matched against trusted_proxies as the IPv4 address
an IPv4-mapped address holds, so an entry such as ::ffff:10.0.0.0/104
trusted nothing. parseCIDRList, which reads both trusted_proxies and
blocked_networks, now keeps such an entry as the IPv4 range it covers and
refuses one shorter than /96 naming the setting it reads.
parseBlockedNetworks, which did this for blocked_networks alone, is gone.

Model: opus-5-5
clawbot force-pushed issue-303-mapped-trusted-proxies from 547bdf11ef to a14c5a1ba0 2026-10-19 05:11:49 +02:00 Compare
clawbot merged commit 930e43961e into next 2026-10-19 05:29:06 +02:00
clawbot deleted branch issue-303-mapped-trusted-proxies 2026-10-19 05:29:06 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/pixa#305