@@ -3,6 +3,7 @@ package conf
33import (
44 "context"
55 "encoding/base64"
6+ "encoding/binary"
67 "encoding/hex"
78 "encoding/json"
89 "math"
@@ -22,6 +23,7 @@ import (
2223 "github.com/xtls/xray-core/common/platform/filesystem"
2324 "github.com/xtls/xray-core/common/serial"
2425 "github.com/xtls/xray-core/transport/internet"
26+ "github.com/xtls/xray-core/transport/internet/finalmask/brutal"
2527 "github.com/xtls/xray-core/transport/internet/finalmask/fragment"
2628 "github.com/xtls/xray-core/transport/internet/finalmask/header/custom"
2729 "github.com/xtls/xray-core/transport/internet/finalmask/mkcp/aes128gcm"
@@ -1230,6 +1232,7 @@ var (
12301232 customVarNamePattern = regexp .MustCompile (`^[A-Za-z_][A-Za-z0-9_]*$` )
12311233
12321234 tcpmaskLoader = NewJSONConfigLoader (ConfigCreatorCache {
1235+ "brutal" : func () interface {} { return new (Brutal ) },
12331236 "header-custom" : func () interface {} { return new (HeaderCustomTCP ) },
12341237 "fragment" : func () interface {} { return new (FragmentMask ) },
12351238 "sudoku" : func () interface {} { return new (Sudoku ) },
@@ -1247,6 +1250,34 @@ var (
12471250 }, "type" , "settings" )
12481251)
12491252
1253+ type Brutal struct {
1254+ Rate uint64 `json:"rate"`
1255+ Cwnd uint64 `json:"cwnd"`
1256+ }
1257+
1258+ func (c * Brutal ) Build () (proto.Message , error ) {
1259+ rate := c .Rate
1260+ cwnd := c .Cwnd
1261+ if rate == 0 {
1262+ rate = 125000
1263+ }
1264+ if cwnd == 0 {
1265+ cwnd = 20
1266+ }
1267+ if rate < 62500 {
1268+ return nil , errors .New ("invalid rate " , rate )
1269+ }
1270+ if cwnd < 5 || cwnd > 80 {
1271+ return nil , errors .New ("invalid cwnd " , cwnd )
1272+ }
1273+ params := make ([]byte , 16 )
1274+ binary .NativeEndian .PutUint64 (params , rate )
1275+ binary .NativeEndian .PutUint64 (params [8 :], cwnd )
1276+ return & brutal.Config {
1277+ Params : params ,
1278+ }, nil
1279+ }
1280+
12501281type TCPItem struct {
12511282 Delay Int32Range `json:"delay"`
12521283 Rand int32 `json:"rand"`
0 commit comments