diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 255102650..2c5650b0d 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -220,8 +220,10 @@ type SplitHTTPConfig struct { XPaddingPlacement string `json:"xPaddingPlacement"` XPaddingMethod string `json:"xPaddingMethod"` UplinkHTTPMethod string `json:"uplinkHTTPMethod"` - SessionPlacement string `json:"sessionPlacement"` - SessionKey string `json:"sessionKey"` + SessionIDPlacement string `json:"sessionIDPlacement"` + SessionIDKey string `json:"sessionIDKey"` + SessionIDTable string `json:"sessionIDTable"` + SessionIDLength Int32Range `json:"sessionIDLength"` SeqPlacement string `json:"seqPlacement"` SeqKey string `json:"seqKey"` UplinkDataPlacement string `json:"uplinkDataPlacement"` @@ -234,8 +236,6 @@ type SplitHTTPConfig struct { ScMaxBufferedPosts int64 `json:"scMaxBufferedPosts"` ScStreamUpServerSecs Int32Range `json:"scStreamUpServerSecs"` ServerMaxHeaderBytes int32 `json:"serverMaxHeaderBytes"` - SessionIDTable string `json:"sessionIDTable"` - SessionIDLength Int32Range `json:"sessionIDLength"` Xmux XmuxConfig `json:"xmux"` DownloadSettings *StreamConfig `json:"downloadSettings"` Extra json.RawMessage `json:"extra"` @@ -334,12 +334,12 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { return nil, errors.New("uplinkHTTPMethod can be GET only in packet-up mode") } - switch c.SessionPlacement { + switch c.SessionIDPlacement { case "": - c.SessionPlacement = "path" + c.SessionIDPlacement = "path" case "path", "cookie", "header", "query": default: - return nil, errors.New("unsupported session placement: " + c.SessionPlacement) + return nil, errors.New("unsupported session placement: " + c.SessionIDPlacement) } switch c.SeqPlacement { @@ -350,12 +350,31 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { return nil, errors.New("unsupported seq placement: " + c.SeqPlacement) } - if c.SessionPlacement != "path" && c.SessionKey == "" { - switch c.SessionPlacement { + if c.SessionIDPlacement != "path" && c.SessionIDKey == "" { + switch c.SessionIDPlacement { case "cookie", "query": - c.SessionKey = "x_session" + c.SessionIDKey = "x_session" case "header": - c.SessionKey = "X-Session" + c.SessionIDKey = "X-Session" + } + } + + if c.SessionIDTable != "" { + if predefined, ok := splithttp.PredefinedTable[c.SessionIDTable]; ok { + c.SessionIDTable = predefined + } + room := roomSize(len(c.SessionIDTable), c.SessionIDLength.From, c.SessionIDLength.To) + // 2.1B possiblities should be enough + if room.Cmp(big.NewInt(2<<30)) < 0 { + return nil, errors.New("sessionIDTable or sessionIDLength is too small") + } + if c.SessionIDLength.From <= 0 { + return nil, errors.New("sessionIDLength.from must be greater than 0") + } + for i := 0; i < len(c.SessionIDTable); i++ { + if c.SessionIDTable[i] >= 0x80 { + return nil, errors.New("sessionIDTable must contain only ASCII characters") + } } } @@ -381,25 +400,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { return nil, errors.New("invalid negative value of maxHeaderBytes") } - if c.SessionIDTable != "" { - if predefined, ok := splithttp.PredefinedTable[c.SessionIDTable]; ok { - c.SessionIDTable = predefined - } - room := roomSize(len(c.SessionIDTable), c.SessionIDLength.From, c.SessionIDLength.To) - // 2.1B possiblities should be enough - if room.Cmp(big.NewInt(2<<30)) < 0 { - return nil, errors.New("sessionIDTable or sessionIDLength is too small") - } - if c.SessionIDLength.From <= 0 { - return nil, errors.New("sessionIDLength.from must be greater than 0") - } - for i := 0; i < len(c.SessionIDTable); i++ { - if c.SessionIDTable[i] >= 0x80 { - return nil, errors.New("sessionIDTable must contain only ASCII characters") - } - } - } - if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 { return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") } @@ -424,9 +424,9 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { XPaddingPlacement: c.XPaddingPlacement, XPaddingMethod: c.XPaddingMethod, UplinkHTTPMethod: c.UplinkHTTPMethod, - SessionPlacement: c.SessionPlacement, + SessionIDPlacement: c.SessionIDPlacement, SeqPlacement: c.SeqPlacement, - SessionKey: c.SessionKey, + SessionIDKey: c.SessionIDKey, SeqKey: c.SeqKey, UplinkDataPlacement: c.UplinkDataPlacement, UplinkDataKey: c.UplinkDataKey, diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 114857631..9acf5e4ff 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -209,10 +209,10 @@ func (c *Config) GetNormalizedServerMaxHeaderBytes() int { } func (c *Config) GetNormalizedSessionPlacement() string { - if c.SessionPlacement == "" { + if c.SessionIDPlacement == "" { return PlacementPath } - return c.SessionPlacement + return c.SessionIDPlacement } func (c *Config) GetNormalizedSeqPlacement() string { @@ -230,8 +230,8 @@ func (c *Config) GetNormalizedUplinkDataPlacement() string { } func (c *Config) GetNormalizedSessionKey() string { - if c.SessionKey != "" { - return c.SessionKey + if c.SessionIDKey != "" { + return c.SessionIDKey } switch c.GetNormalizedSessionPlacement() { case PlacementHeader: diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 58dede4fd..c7dfe4ce8 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -179,8 +179,8 @@ type Config struct { XPaddingPlacement string `protobuf:"bytes,17,opt,name=xPaddingPlacement,proto3" json:"xPaddingPlacement,omitempty"` XPaddingMethod string `protobuf:"bytes,18,opt,name=xPaddingMethod,proto3" json:"xPaddingMethod,omitempty"` UplinkHTTPMethod string `protobuf:"bytes,19,opt,name=uplinkHTTPMethod,proto3" json:"uplinkHTTPMethod,omitempty"` - SessionPlacement string `protobuf:"bytes,20,opt,name=sessionPlacement,proto3" json:"sessionPlacement,omitempty"` - SessionKey string `protobuf:"bytes,21,opt,name=sessionKey,proto3" json:"sessionKey,omitempty"` + SessionIDPlacement string `protobuf:"bytes,20,opt,name=sessionIDPlacement,proto3" json:"sessionIDPlacement,omitempty"` + SessionIDKey string `protobuf:"bytes,21,opt,name=sessionIDKey,proto3" json:"sessionIDKey,omitempty"` SeqPlacement string `protobuf:"bytes,22,opt,name=seqPlacement,proto3" json:"seqPlacement,omitempty"` SeqKey string `protobuf:"bytes,23,opt,name=seqKey,proto3" json:"seqKey,omitempty"` UplinkDataPlacement string `protobuf:"bytes,24,opt,name=uplinkDataPlacement,proto3" json:"uplinkDataPlacement,omitempty"` @@ -356,16 +356,16 @@ func (x *Config) GetUplinkHTTPMethod() string { return "" } -func (x *Config) GetSessionPlacement() string { +func (x *Config) GetSessionIDPlacement() string { if x != nil { - return x.SessionPlacement + return x.SessionIDPlacement } return "" } -func (x *Config) GetSessionKey() string { +func (x *Config) GetSessionIDKey() string { if x != nil { - return x.SessionKey + return x.SessionIDKey } return "" } @@ -441,7 +441,7 @@ const file_transport_internet_splithttp_config_proto_rawDesc = "" + "\x0ecMaxReuseTimes\x18\x03 \x01(\v2..xray.transport.internet.splithttp.RangeConfigR\x0ecMaxReuseTimes\x12Z\n" + "\x10hMaxRequestTimes\x18\x04 \x01(\v2..xray.transport.internet.splithttp.RangeConfigR\x10hMaxRequestTimes\x12Z\n" + "\x10hMaxReusableSecs\x18\x05 \x01(\v2..xray.transport.internet.splithttp.RangeConfigR\x10hMaxReusableSecs\x12*\n" + - "\x10hKeepAlivePeriod\x18\x06 \x01(\x03R\x10hKeepAlivePeriod\"\xc4\f\n" + + "\x10hKeepAlivePeriod\x18\x06 \x01(\x03R\x10hKeepAlivePeriod\"\xcc\f\n" + "\x06Config\x12\x12\n" + "\x04host\x18\x01 \x01(\tR\x04host\x12\x12\n" + "\x04path\x18\x02 \x01(\tR\x04path\x12\x12\n" + @@ -462,11 +462,9 @@ const file_transport_internet_splithttp_config_proto_rawDesc = "" + "\x0exPaddingHeader\x18\x10 \x01(\tR\x0exPaddingHeader\x12,\n" + "\x11xPaddingPlacement\x18\x11 \x01(\tR\x11xPaddingPlacement\x12&\n" + "\x0exPaddingMethod\x18\x12 \x01(\tR\x0exPaddingMethod\x12*\n" + - "\x10uplinkHTTPMethod\x18\x13 \x01(\tR\x10uplinkHTTPMethod\x12*\n" + - "\x10sessionPlacement\x18\x14 \x01(\tR\x10sessionPlacement\x12\x1e\n" + - "\n" + - "sessionKey\x18\x15 \x01(\tR\n" + - "sessionKey\x12\"\n" + + "\x10uplinkHTTPMethod\x18\x13 \x01(\tR\x10uplinkHTTPMethod\x12.\n" + + "\x12sessionIDPlacement\x18\x14 \x01(\tR\x12sessionIDPlacement\x12\"\n" + + "\fsessionIDKey\x18\x15 \x01(\tR\fsessionIDKey\x12\"\n" + "\fseqPlacement\x18\x16 \x01(\tR\fseqPlacement\x12\x16\n" + "\x06seqKey\x18\x17 \x01(\tR\x06seqKey\x120\n" + "\x13uplinkDataPlacement\x18\x18 \x01(\tR\x13uplinkDataPlacement\x12$\n" + diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 8ba830e8c..efe6de03f 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -42,8 +42,8 @@ message Config { string xPaddingPlacement = 17; string xPaddingMethod = 18; string uplinkHTTPMethod = 19; - string sessionPlacement = 20; - string sessionKey = 21; + string sessionIDPlacement = 20; + string sessionIDKey = 21; string seqPlacement = 22; string seqKey = 23; string uplinkDataPlacement = 24;