Fix reset UDP MTU

This commit is contained in:
世界 2024-04-08 11:11:04 +08:00
parent 01f8ce81ac
commit 5eccd25e3c
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 6 additions and 6 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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 {