diff --git a/admission/wrapper/conn.go b/admission/wrapper/conn.go index b9097453..a77e95a6 100644 --- a/admission/wrapper/conn.go +++ b/admission/wrapper/conn.go @@ -44,6 +44,12 @@ func WrapConn(admission admission.Admission, c net.Conn) net.Conn { } } +// UnwrapConn returns the underlying connection, allowing type assertions +// through wrapper layers. +func (c *serverConn) UnwrapConn() net.Conn { + return c.Conn +} + // Read checks the remote address against the admission controller // before delegating to the underlying connection. If denied, it returns // io.EOF to signal end-of-stream. diff --git a/internal/net/proxyproto/conn.go b/internal/net/proxyproto/conn.go index 9c57919b..b99895b9 100644 --- a/internal/net/proxyproto/conn.go +++ b/internal/net/proxyproto/conn.go @@ -14,6 +14,12 @@ type serverConn struct { ctx context.Context } +// UnwrapConn returns the underlying connection, allowing type assertions +// through wrapper layers. +func (c *serverConn) UnwrapConn() net.Conn { + return c.Conn +} + func (c *serverConn) Context() context.Context { return c.ctx } diff --git a/limiter/conn/wrapper/conn.go b/limiter/conn/wrapper/conn.go index 9cfe089d..81a0bc05 100644 --- a/limiter/conn/wrapper/conn.go +++ b/limiter/conn/wrapper/conn.go @@ -36,6 +36,12 @@ func WrapConn(limiter limiter.Limiter, c net.Conn) net.Conn { } } +// UnwrapConn returns the underlying connection, allowing type assertions +// through wrapper layers. +func (c *serverConn) UnwrapConn() net.Conn { + return c.Conn +} + func (c *serverConn) SyscallConn() (rc syscall.RawConn, err error) { if sc, ok := c.Conn.(syscall.Conn); ok { rc, err = sc.SyscallConn() diff --git a/metrics/wrapper/conn.go b/metrics/wrapper/conn.go index 7bd19451..8a4d2871 100644 --- a/metrics/wrapper/conn.go +++ b/metrics/wrapper/conn.go @@ -42,6 +42,12 @@ func WrapConn(service string, c net.Conn) net.Conn { } } +// UnwrapConn returns the underlying connection, allowing type assertions +// through wrapper layers. +func (c *serverConn) UnwrapConn() net.Conn { + return c.Conn +} + func (c *serverConn) Read(b []byte) (n int, err error) { n, err = c.Conn.Read(b) if counter := xmetrics.GetCounter( diff --git a/observer/stats/wrapper/conn.go b/observer/stats/wrapper/conn.go index 9d3bf31d..3ccd88e9 100644 --- a/observer/stats/wrapper/conn.go +++ b/observer/stats/wrapper/conn.go @@ -45,6 +45,12 @@ func WrapConn(c net.Conn, pStats stats.Stats) net.Conn { } } +// UnwrapConn returns the underlying connection, allowing type assertions +// through wrapper layers. +func (c *conn) UnwrapConn() net.Conn { + return c.Conn +} + func (c *conn) Read(b []byte) (n int, err error) { n, err = c.Conn.Read(b) c.stats.Add(stats.KindInputBytes, int64(n))