mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: limit tuicv5's maxUdpRelayPacketSize up to 1200-PacketOverHead
This commit is contained in:
parent
7f49c91267
commit
4fe7a463c5
|
@ -323,6 +323,10 @@ func NewTuic(option TuicOption) (*Tuic, error) {
|
|||
|
||||
t.client = tuic.NewPoolClientV4(clientOption)
|
||||
} else {
|
||||
maxUdpRelayPacketSize := option.MaxUdpRelayPacketSize
|
||||
if maxUdpRelayPacketSize > tuic.MaxFragSizeV5 {
|
||||
maxUdpRelayPacketSize = tuic.MaxFragSizeV5
|
||||
}
|
||||
clientOption := &tuic.ClientOptionV5{
|
||||
TlsConfig: tlsConfig,
|
||||
QuicConfig: quicConfig,
|
||||
|
@ -331,7 +335,7 @@ func NewTuic(option TuicOption) (*Tuic, error) {
|
|||
UdpRelayMode: udpRelayMode,
|
||||
CongestionController: option.CongestionController,
|
||||
ReduceRtt: option.ReduceRtt,
|
||||
MaxUdpRelayPacketSize: option.MaxUdpRelayPacketSize,
|
||||
MaxUdpRelayPacketSize: maxUdpRelayPacketSize,
|
||||
MaxOpenStreams: clientMaxOpenStreams,
|
||||
CWND: option.CWND,
|
||||
}
|
||||
|
|
|
@ -223,6 +223,10 @@ func NewServer(option *ServerOption, pc net.PacketConn) (*Server, error) {
|
|||
}
|
||||
}
|
||||
if len(option.Users) > 0 {
|
||||
maxUdpRelayPacketSize := option.MaxUdpRelayPacketSize
|
||||
if maxUdpRelayPacketSize > MaxFragSizeV5 {
|
||||
maxUdpRelayPacketSize = MaxFragSizeV5
|
||||
}
|
||||
server.optionV5 = &v5.ServerOption{
|
||||
HandleTcpFn: option.HandleTcpFn,
|
||||
HandleUdpFn: option.HandleUdpFn,
|
||||
|
|
|
@ -30,6 +30,7 @@ const DefaultConnectionReceiveWindow = common.DefaultConnectionReceiveWindow
|
|||
var GenTKN = v4.GenTKN
|
||||
var PacketOverHeadV4 = v4.PacketOverHead
|
||||
var PacketOverHeadV5 = v5.PacketOverHead
|
||||
var MaxFragSizeV5 = v5.MaxFragSize
|
||||
|
||||
type UdpRelayMode = common.UdpRelayMode
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ import (
|
|||
"github.com/metacubex/quic-go"
|
||||
)
|
||||
|
||||
// MaxFragSize is a safe udp relay packet size
|
||||
// because tuicv5 support udp fragment so we unneeded to do a magic modify for quic-go to increase MaxDatagramFrameSize
|
||||
// it may not work fine in some platform
|
||||
var MaxFragSize = 1200 - PacketOverHead
|
||||
|
||||
func fragWriteNative(quicConn quic.Connection, packet Packet, buf *bytes.Buffer, fragSize int) (err error) {
|
||||
fullPayload := packet.DATA
|
||||
off := 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user