mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-27 12:35:39 +08:00
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package common
|
|
|
|
import (
|
|
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
|
|
|
"github.com/metacubex/quic-go"
|
|
)
|
|
|
|
const (
|
|
DefaultStreamReceiveWindow = 15728640 // 15 MB/s
|
|
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
|
)
|
|
|
|
func SetCongestionController(quicConn quic.Connection, cc string) {
|
|
switch cc {
|
|
case "cubic":
|
|
quicConn.SetCongestionControl(
|
|
congestion.NewCubicSender(
|
|
congestion.DefaultClock{},
|
|
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
|
|
false,
|
|
nil,
|
|
),
|
|
)
|
|
case "new_reno":
|
|
quicConn.SetCongestionControl(
|
|
congestion.NewCubicSender(
|
|
congestion.DefaultClock{},
|
|
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
|
|
true,
|
|
nil,
|
|
),
|
|
)
|
|
case "bbr":
|
|
quicConn.SetCongestionControl(
|
|
congestion.NewBBRSender(
|
|
congestion.DefaultClock{},
|
|
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
|
|
congestion.InitialCongestionWindow*congestion.InitialMaxDatagramSize,
|
|
congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize,
|
|
),
|
|
)
|
|
}
|
|
}
|