From 1d94546902a1b2ac35b016422838c09eb5b1ebfd Mon Sep 17 00:00:00 2001 From: Larvan2 <78135608+Larvan2@users.noreply.github.com> Date: Wed, 21 Jun 2023 00:40:33 +0800 Subject: [PATCH] chore: fix TUIC cwnd parsing --- listener/config/tuic.go | 1 + listener/tuic/server.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/listener/config/tuic.go b/listener/config/tuic.go index 30c99054..191cb59c 100644 --- a/listener/config/tuic.go +++ b/listener/config/tuic.go @@ -17,6 +17,7 @@ type TuicServer struct { ALPN []string `yaml:"alpn" json:"alpn,omitempty"` MaxUdpRelayPacketSize int `yaml:"max-udp-relay-packet-size" json:"max-udp-relay-packet-size,omitempty"` MaxDatagramFrameSize int `yaml:"max-datagram-frame-size" json:"max-datagram-frame-size,omitempty"` + CWND int `yaml:"cwnd" json:"cwnd,omitempty"` } func (t TuicServer) String() string { diff --git a/listener/tuic/server.go b/listener/tuic/server.go index e1d8175c..742d8ac9 100644 --- a/listener/tuic/server.go +++ b/listener/tuic/server.go @@ -66,6 +66,10 @@ func New(config LC.TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<- C.Packet packetOverHead = tuic.PacketOverHeadV5 } + if config.CWND == 0 { + config.CWND = 32 + } + if config.MaxUdpRelayPacketSize == 0 { config.MaxUdpRelayPacketSize = 1500 } @@ -115,6 +119,7 @@ func New(config LC.TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<- C.Packet CongestionController: config.CongestionController, AuthenticationTimeout: time.Duration(config.AuthenticationTimeout) * time.Millisecond, MaxUdpRelayPacketSize: config.MaxUdpRelayPacketSize, + CWND: config.CWND, } } else { users := make(map[[16]byte]string) @@ -131,6 +136,7 @@ func New(config LC.TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<- C.Packet CongestionController: config.CongestionController, AuthenticationTimeout: time.Duration(config.AuthenticationTimeout) * time.Millisecond, MaxUdpRelayPacketSize: config.MaxUdpRelayPacketSize, + CWND: config.CWND, } }