From 28579236a99534a35ed73b423f4eb157f7b3085f Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 9 Nov 2021 20:37:48 +0100 Subject: Implement OriginalDestinationAddr --- pkg/tcpip/adapters/gonet/gonet.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/tcpip/adapters/gonet/gonet.go b/pkg/tcpip/adapters/gonet/gonet.go index 1f2bcaf65..16650024f 100644 --- a/pkg/tcpip/adapters/gonet/gonet.go +++ b/pkg/tcpip/adapters/gonet/gonet.go @@ -449,6 +449,15 @@ func (c *TCPConn) RemoteAddr() net.Addr { return fullToTCPAddr(a) } +// Extension +func (c *TCPConn) OriginalDestinationAddr() net.Addr { + var v tcpip.OriginalDestinationOption + if err := c.ep.GetSockOpt(&v); err != nil { + return nil + } + return fullToTCPAddr(tcpip.FullAddress(v)) +} + func (c *TCPConn) newOpError(op string, err error) *net.OpError { return &net.OpError{ Op: op, -- cgit v1.2.3