plugin/proxyproto: expose PPv2 TLVs to downstream plugins as metadata (#8641)

The proxyproto plugin parsed PROXY protocol v2 headers only to recover the real
client address; the TLV vector was discarded, so downstream plugins had no way to
read values such as the AWS VPC endpoint ID, SSL client CN, or vendor-specific
custom TLVs.

Add an opt-in `tlv_metadata` option. When set, the connection's raw PPv2 TLV
vector is captured and the plugin, acting as a metadata.Provider, publishes it
under the `proxyproto/tlv` label as a hex-encoded string. Consumers decode and
split it with proxyproto.SplitTLVs. The option is off by default, so existing
deployments skip the extra per-connection processing and behave exactly as before.
PROXY protocol v1 connections, which carry no TLVs, are unaffected.

Capture spans all transports: dns:// (UDP and TCP), tls:// (DoT), https:// (DoH),
grpc://, quic:// (DoQ), and https3:// (DoH3). QUIC-based transports require
udp_session_tracking, since the PPv2 header arrives as a standalone first datagram
ahead of the QUIC handshake.

Includes unit tests for capture, the metadata provider (direct and through the
real metadata chain), v1 compatibility, and option parsing, plus README and man
page updates.

Fixes #8633

Signed-off-by: Mekias Yohannes <mekias@amazon.com>
Co-authored-by: Mekias Yohannes <mekias@amazon.com>
This commit is contained in:
myohannes
2026-10-15 22:28:43 -04:00
committed by GitHub
parent 21660a66b5
commit 3909cc187c
18 changed files with 1209 additions and 20 deletions

View File

@@ -28,6 +28,7 @@ func setup(c *caddy.Controller) error {
defaultSet bool
sessionTrackingTTL time.Duration
sessionTrackingMaxSessions int
tlvMetadata bool
)
for c.Next() {
args := c.RemainingArgs()
@@ -79,6 +80,11 @@ func setup(c *caddy.Controller) error {
}
sessionTrackingMaxSessions = n
}
case "tlv_metadata":
if len(c.RemainingArgs()) != 0 {
return plugin.Error("proxyproto", c.ArgErr())
}
tlvMetadata = true
default:
return c.Errf("unknown option '%s'", c.Val())
}
@@ -105,5 +111,13 @@ func setup(c *caddy.Controller) error {
}
config.ProxyProtoUDPSessionTrackingTTL = sessionTrackingTTL
config.ProxyProtoUDPSessionTrackingMaxSessions = sessionTrackingMaxSessions
config.ProxyProtoTLVMetadata = tlvMetadata
if tlvMetadata {
// Add a pass-through handler that implements metadata.Provider so the
// captured PPv2 TLVs are exposed as the "proxyproto/tlv" label.
config.AddPlugin(func(next plugin.Handler) plugin.Handler {
return handler{Next: next}
})
}
return nil
}