From 66e5136ba0f62d4c4c8263ad0a8e045e1e1482ae Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Sun, 9 Oct 2022 13:16:13 +0800 Subject: [PATCH] fix: correct sing-tun's rAddr --- listener/sing/sing.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/listener/sing/sing.go b/listener/sing/sing.go index d22fa44a..f53844dc 100644 --- a/listener/sing/sing.go +++ b/listener/sing/sing.go @@ -29,6 +29,7 @@ type waitCloseConn struct { net.Conn wg *sync.WaitGroup close sync.Once + rAddr net.Addr } func (c *waitCloseConn) Close() error { // call from handleTCPConn(connCtx C.ConnContext) @@ -38,6 +39,10 @@ func (c *waitCloseConn) Close() error { // call from handleTCPConn(connCtx C.Con return c.Conn.Close() } +func (c *waitCloseConn) RemoteAddr() net.Addr { + return c.rAddr +} + func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error { switch metadata.Destination.Fqdn { case vmess.MuxDestination.Fqdn: @@ -50,7 +55,7 @@ func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, meta wg := &sync.WaitGroup{} defer wg.Wait() // this goroutine must exit after conn.Close() wg.Add(1) - h.TcpIn <- inbound.NewSocket(target, &waitCloseConn{Conn: conn, wg: wg}, h.Type) + h.TcpIn <- inbound.NewSocket(target, &waitCloseConn{Conn: conn, wg: wg, rAddr: metadata.Source.TCPAddr()}, h.Type) return nil }