test: ipv4 in v6 address checking (#1271)
* test: ipv4 in v6 address checking * fix(lib/policy): unmap 4in6 addresses in RemoteAddrChecker Signed-off-by: Xe Iaso <me@xeiaso.net> * docs: update CHANGELOG Signed-off-by: Xe Iaso <me@xeiaso.net> * docs: perfect CHANGELOG Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net> Co-authored-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
1e298f5d0e
commit
a5bb6d2751
3 changed files with 22 additions and 2 deletions
|
|
@ -15,8 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Allow more OCI registry clients [based on feedback](https://github.com/TecharoHQ/anubis/pull/1253#issuecomment-3506744184).
|
||||
- Expose services directory in the embedded `(data)` filesystem.
|
||||
- Add Ukrainian locale ([#1044](https://github.com/TecharoHQ/anubis/pull/1044))
|
||||
- Allow Renovate as an OCI registry client
|
||||
- Add Ukrainian locale ([#1044](https://github.com/TecharoHQ/anubis/pull/1044)).
|
||||
- Allow Renovate as an OCI registry client.
|
||||
- Properly handle 4in6 addresses so that IP matching works with those addresses.
|
||||
|
||||
## v1.23.1: Lyse Hext - Echo 1
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ func (rac *RemoteAddrChecker) Check(r *http.Request) (bool, error) {
|
|||
return false, fmt.Errorf("%w: %s is not an IP address: %w", ErrMisconfiguration, host, err)
|
||||
}
|
||||
|
||||
// Convert IPv4-mapped IPv6 addresses to IPv4
|
||||
if addr.Is6() && addr.Is4In6() {
|
||||
addr = addr.Unmap()
|
||||
}
|
||||
|
||||
return rac.prefixTable.Contains(addr), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,20 @@ func TestRemoteAddrChecker(t *testing.T) {
|
|||
ok: true,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "match_ipv4_in_ipv6",
|
||||
cidrs: []string{"0.0.0.0/0"},
|
||||
ip: "::ffff:1.1.1.1",
|
||||
ok: true,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "match_ipv4_in_ipv6_hex",
|
||||
cidrs: []string{"0.0.0.0/0"},
|
||||
ip: "::ffff:101:101",
|
||||
ok: true,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "match_ipv6",
|
||||
cidrs: []string{"::/0"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue