fix proxy protocol policy

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-05-28 19:40:37 +02:00
parent 9c775e2213
commit 68cc1a8e2c
5 changed files with 24 additions and 20 deletions

View File

@@ -810,7 +810,8 @@ func getProxyPolicy(allowed, skipped []func(net.IP) bool, def proxyproto.Policy)
return func(upstream net.Addr) (proxyproto.Policy, error) {
upstreamIP, err := util.GetIPFromNetAddr(upstream)
if err != nil {
// something is wrong with the source IP, better reject the connection
// Something is wrong with the source IP, better reject the
// connection if a proxy header is found.
return proxyproto.REJECT, err
}
@@ -829,6 +830,9 @@ func getProxyPolicy(allowed, skipped []func(net.IP) bool, def proxyproto.Policy)
}
}
if def == proxyproto.REQUIRE {
return proxyproto.REJECT, nil
}
return def, nil
}
}