diff options
author | Prakhar Awasthi <[email protected]> | 2024-08-03 22:21:50 +0530 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-03 19:51:50 +0300 |
commit | 840094ac65c2c27dbf0be63478d36969a57ce7e0 (patch) | |
tree | 01ea87b6e9735c05d725320ce2c100e01e9b38e6 | |
parent | 976469ca0dbbbd948dbfd6a4caedb1e7c914ef3d (diff) | |
download | caddy-840094ac65c2c27dbf0be63478d36969a57ce7e0.tar.gz caddy-840094ac65c2c27dbf0be63478d36969a57ce7e0.zip |
proxyprotocol: Update WrapListener to use ConnPolicyFunc for PROXY protocol (#6485)
* proxyprotocol : Update WrapListener to use ConnPolicyFunc for PROXY protocol support
* proxyprotocol : Updated dependency pires/go-proxyproto to pseudo latest version
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | modules/caddyhttp/proxyprotocol/listenerwrapper.go | 11 |
3 files changed, 9 insertions, 6 deletions
@@ -123,7 +123,7 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-ps v1.0.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/pires/go-proxyproto v0.7.0 + github.com/pires/go-proxyproto v0.7.1-0.20240628150027-b718e7ce4964 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.48.0 // indirect @@ -322,6 +322,8 @@ github.com/peterbourgon/diskv/v3 v3.0.1 h1:x06SQA46+PKIUftmEujdwSEpIx8kR+M9eLYsU github.com/peterbourgon/diskv/v3 v3.0.1/go.mod h1:kJ5Ny7vLdARGU3WUuy6uzO6T0nb/2gWcT1JiBvRmb5o= github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs= github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4= +github.com/pires/go-proxyproto v0.7.1-0.20240628150027-b718e7ce4964 h1:ct/vxNBgHpASQ4sT8NaBX9LtsEtluZqaUJydLG50U3E= +github.com/pires/go-proxyproto v0.7.1-0.20240628150027-b718e7ce4964/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/modules/caddyhttp/proxyprotocol/listenerwrapper.go b/modules/caddyhttp/proxyprotocol/listenerwrapper.go index e0d9b86ce..e25fe02a6 100644 --- a/modules/caddyhttp/proxyprotocol/listenerwrapper.go +++ b/modules/caddyhttp/proxyprotocol/listenerwrapper.go @@ -50,7 +50,7 @@ type ListenerWrapper struct { // Policy definitions are here: https://pkg.go.dev/github.com/pires/[email protected]#Policy FallbackPolicy Policy `json:"fallback_policy,omitempty"` - policy goproxy.PolicyFunc + policy goproxy.ConnPolicyFunc } // Provision sets up the listener wrapper. @@ -69,13 +69,14 @@ func (pp *ListenerWrapper) Provision(ctx caddy.Context) error { } pp.deny = append(pp.deny, ipnet) } - pp.policy = func(upstream net.Addr) (goproxy.Policy, error) { + + pp.policy = func(options goproxy.ConnPolicyOptions) (goproxy.Policy, error) { // trust unix sockets - if network := upstream.Network(); caddy.IsUnixNetwork(network) { + if network := options.Upstream.Network(); caddy.IsUnixNetwork(network) { return goproxy.USE, nil } ret := pp.FallbackPolicy - host, _, err := net.SplitHostPort(upstream.String()) + host, _, err := net.SplitHostPort(options.Upstream.String()) if err != nil { return goproxy.REJECT, err } @@ -106,6 +107,6 @@ func (pp *ListenerWrapper) WrapListener(l net.Listener) net.Listener { Listener: l, ReadHeaderTimeout: time.Duration(pp.Timeout), } - pl.Policy = pp.policy + pl.ConnPolicy = pp.policy return pl } |