From 9308de4e7410c8efd67eafd3ca277e0b13285c57 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sun, 19 Mar 2023 23:23:02 +0000 Subject: [PATCH] Fix incorrect UDP length in Torjan packet addr --- proxy/trojan/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index 4b5d788d898..dd74345d5ed 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -92,7 +92,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly) var buffer [2048]byte - _, addr, err := packetConn.ReadFrom(buffer[:]) + n, addr, err := packetConn.ReadFrom(buffer[:]) if err != nil { return newError("failed to read a packet").Base(err) } @@ -103,7 +103,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter packetWriter := &PacketWriter{Writer: connWriter, Target: dest} // write some request payload to buffer - if _, err := packetWriter.WriteTo(buffer[:], addr); err != nil { + if _, err := packetWriter.WriteTo(buffer[:n], addr); err != nil { return newError("failed to write a request payload").Base(err) }