From 5eccd25e3ca863d78323f69a1ecb759b157d7570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 8 Apr 2024 11:11:04 +0800 Subject: [PATCH] Fix reset UDP MTU --- hysteria/packet.go | 4 ++-- hysteria2/packet.go | 4 ++-- tuic/packet.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hysteria/packet.go b/hysteria/packet.go index 18110e1..18f7a97 100644 --- a/hysteria/packet.go +++ b/hysteria/packet.go @@ -208,7 +208,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) if !errors.As(err, &tooLargeErr) { return err } - return c.writePackets(fragUDPMessage(message, int(tooLargeErr))) + return c.writePackets(fragUDPMessage(message, int(tooLargeErr)-3)) } func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { @@ -246,7 +246,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { if !errors.As(err, &tooLargeErr) { return } - err = c.writePackets(fragUDPMessage(message, int(tooLargeErr))) + err = c.writePackets(fragUDPMessage(message, int(tooLargeErr)-3)) if err == nil { return len(p), nil } diff --git a/hysteria2/packet.go b/hysteria2/packet.go index 07887b0..ffe42cd 100644 --- a/hysteria2/packet.go +++ b/hysteria2/packet.go @@ -203,7 +203,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) if !errors.As(err, &tooLargeErr) { return err } - return c.writePackets(fragUDPMessage(message, int(tooLargeErr))) + return c.writePackets(fragUDPMessage(message, int(tooLargeErr)-3)) } func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { @@ -239,7 +239,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { if !errors.As(err, &tooLargeErr) { return } - err = c.writePackets(fragUDPMessage(message, int(tooLargeErr))) + err = c.writePackets(fragUDPMessage(message, int(tooLargeErr)-3)) if err == nil { return len(p), nil } diff --git a/tuic/packet.go b/tuic/packet.go index 1a358fa..fdc5192 100644 --- a/tuic/packet.go +++ b/tuic/packet.go @@ -227,7 +227,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) if !errors.As(err, &tooLargeErr) { return err } - c.udpMTU = int(tooLargeErr) + c.udpMTU = int(tooLargeErr) - 3 c.udpMTUTime = time.Now() return c.writePackets(fragUDPMessage(message, c.udpMTU)) } @@ -269,7 +269,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { if !errors.As(err, &tooLargeErr) { return } - c.udpMTU = int(tooLargeErr) + c.udpMTU = int(tooLargeErr) - 3 c.udpMTUTime = time.Now() err = c.writePackets(fragUDPMessage(message, c.udpMTU)) if err == nil {