Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,11 @@ func (c *TLSCertConfig) Build() (*tls.Certificate, error) {
return certificate, nil
}

type QuicParamsConfig struct {
Congestion string `json:"congestion"`
Up Bandwidth `json:"up"`
}

type TLSConfig struct {
AllowInsecure bool `json:"allowInsecure"`
Certs []*TLSCertConfig `json:"certificates"`
Expand Down Expand Up @@ -1422,8 +1427,9 @@ func (c *Mask) Build(tcp bool) (proto.Message, error) {
}

type FinalMask struct {
Tcp []Mask `json:"tcp"`
Udp []Mask `json:"udp"`
Tcp []Mask `json:"tcp"`
Udp []Mask `json:"udp"`
QuicParams *QuicParamsConfig `json:"quicParams"`
}

type StreamConfig struct {
Expand Down Expand Up @@ -1596,6 +1602,28 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
}
config.Udpmasks = append(config.Udpmasks, serial.ToTypedMessage(u))
}
if c.FinalMask.QuicParams != nil {
up, err := c.FinalMask.QuicParams.Up.Bps()
if err != nil {
return nil, err
}
if up > 0 && up < 65536 {
return nil, errors.New("Up must be at least 65536 bytes per second")
}
switch c.FinalMask.QuicParams.Congestion {
case "", "bbr", "reno":
case "force-brutal":
if up == 0 {
return nil, errors.New("force-brutal requires up")
}
default:
return nil, errors.New("unknown congestion control: ", c.FinalMask.QuicParams.Congestion, ", valid values: bbr, reno, force-brutal")
}
config.QuicParams = &internet.QuicParams{
Congestion: c.FinalMask.QuicParams.Congestion,
Up: up,
}
}
}

return config, nil
Expand Down
150 changes: 110 additions & 40 deletions transport/internet/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions transport/internet/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ message StreamConfig {
repeated xray.common.serial.TypedMessage udpmasks = 10;
repeated xray.common.serial.TypedMessage tcpmasks = 11;

QuicParams quic_params = 12;

SocketConfig socket_settings = 6;
}

message QuicParams {
string congestion = 1;
uint64 up = 2;
}

message ProxyConfig {
string tag = 1;
bool transportLayerProxy = 2;
Expand Down
5 changes: 5 additions & 0 deletions transport/internet/memory_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type MemoryStreamConfig struct {
SecuritySettings interface{}
TcpmaskManager *finalmask.TcpmaskManager
UdpmaskManager *finalmask.UdpmaskManager
QuicParams *QuicParams
SocketSettings *SocketConfig
DownloadSettings *MemoryStreamConfig
}
Expand Down Expand Up @@ -62,6 +63,10 @@ func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) {
mss.TcpmaskManager = finalmask.NewTcpmaskManager(masks)
}

if s != nil && s.QuicParams != nil {
mss.QuicParams = s.QuicParams
}

if s != nil && len(s.Udpmasks) > 0 {
var masks []finalmask.Udpmask
for _, msg := range s.Udpmasks {
Expand Down
Loading