This commit is contained in:
Fangliding
2026-06-09 20:12:54 +08:00
parent 3f4a4004f9
commit bbcf2c4e45
4 changed files with 48 additions and 50 deletions
+32 -32
View File
@@ -220,8 +220,10 @@ type SplitHTTPConfig struct {
XPaddingPlacement string `json:"xPaddingPlacement"` XPaddingPlacement string `json:"xPaddingPlacement"`
XPaddingMethod string `json:"xPaddingMethod"` XPaddingMethod string `json:"xPaddingMethod"`
UplinkHTTPMethod string `json:"uplinkHTTPMethod"` UplinkHTTPMethod string `json:"uplinkHTTPMethod"`
SessionPlacement string `json:"sessionPlacement"` SessionIDPlacement string `json:"sessionIDPlacement"`
SessionKey string `json:"sessionKey"` SessionIDKey string `json:"sessionIDKey"`
SessionIDTable string `json:"sessionIDTable"`
SessionIDLength Int32Range `json:"sessionIDLength"`
SeqPlacement string `json:"seqPlacement"` SeqPlacement string `json:"seqPlacement"`
SeqKey string `json:"seqKey"` SeqKey string `json:"seqKey"`
UplinkDataPlacement string `json:"uplinkDataPlacement"` UplinkDataPlacement string `json:"uplinkDataPlacement"`
@@ -234,8 +236,6 @@ type SplitHTTPConfig struct {
ScMaxBufferedPosts int64 `json:"scMaxBufferedPosts"` ScMaxBufferedPosts int64 `json:"scMaxBufferedPosts"`
ScStreamUpServerSecs Int32Range `json:"scStreamUpServerSecs"` ScStreamUpServerSecs Int32Range `json:"scStreamUpServerSecs"`
ServerMaxHeaderBytes int32 `json:"serverMaxHeaderBytes"` ServerMaxHeaderBytes int32 `json:"serverMaxHeaderBytes"`
SessionIDTable string `json:"sessionIDTable"`
SessionIDLength Int32Range `json:"sessionIDLength"`
Xmux XmuxConfig `json:"xmux"` Xmux XmuxConfig `json:"xmux"`
DownloadSettings *StreamConfig `json:"downloadSettings"` DownloadSettings *StreamConfig `json:"downloadSettings"`
Extra json.RawMessage `json:"extra"` 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") return nil, errors.New("uplinkHTTPMethod can be GET only in packet-up mode")
} }
switch c.SessionPlacement { switch c.SessionIDPlacement {
case "": case "":
c.SessionPlacement = "path" c.SessionIDPlacement = "path"
case "path", "cookie", "header", "query": case "path", "cookie", "header", "query":
default: default:
return nil, errors.New("unsupported session placement: " + c.SessionPlacement) return nil, errors.New("unsupported session placement: " + c.SessionIDPlacement)
} }
switch c.SeqPlacement { switch c.SeqPlacement {
@@ -350,12 +350,31 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
return nil, errors.New("unsupported seq placement: " + c.SeqPlacement) return nil, errors.New("unsupported seq placement: " + c.SeqPlacement)
} }
if c.SessionPlacement != "path" && c.SessionKey == "" { if c.SessionIDPlacement != "path" && c.SessionIDKey == "" {
switch c.SessionPlacement { switch c.SessionIDPlacement {
case "cookie", "query": case "cookie", "query":
c.SessionKey = "x_session" c.SessionIDKey = "x_session"
case "header": 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") 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 { if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 {
return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") 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, XPaddingPlacement: c.XPaddingPlacement,
XPaddingMethod: c.XPaddingMethod, XPaddingMethod: c.XPaddingMethod,
UplinkHTTPMethod: c.UplinkHTTPMethod, UplinkHTTPMethod: c.UplinkHTTPMethod,
SessionPlacement: c.SessionPlacement, SessionIDPlacement: c.SessionIDPlacement,
SeqPlacement: c.SeqPlacement, SeqPlacement: c.SeqPlacement,
SessionKey: c.SessionKey, SessionIDKey: c.SessionIDKey,
SeqKey: c.SeqKey, SeqKey: c.SeqKey,
UplinkDataPlacement: c.UplinkDataPlacement, UplinkDataPlacement: c.UplinkDataPlacement,
UplinkDataKey: c.UplinkDataKey, UplinkDataKey: c.UplinkDataKey,
+4 -4
View File
@@ -209,10 +209,10 @@ func (c *Config) GetNormalizedServerMaxHeaderBytes() int {
} }
func (c *Config) GetNormalizedSessionPlacement() string { func (c *Config) GetNormalizedSessionPlacement() string {
if c.SessionPlacement == "" { if c.SessionIDPlacement == "" {
return PlacementPath return PlacementPath
} }
return c.SessionPlacement return c.SessionIDPlacement
} }
func (c *Config) GetNormalizedSeqPlacement() string { func (c *Config) GetNormalizedSeqPlacement() string {
@@ -230,8 +230,8 @@ func (c *Config) GetNormalizedUplinkDataPlacement() string {
} }
func (c *Config) GetNormalizedSessionKey() string { func (c *Config) GetNormalizedSessionKey() string {
if c.SessionKey != "" { if c.SessionIDKey != "" {
return c.SessionKey return c.SessionIDKey
} }
switch c.GetNormalizedSessionPlacement() { switch c.GetNormalizedSessionPlacement() {
case PlacementHeader: case PlacementHeader:
+10 -12
View File
@@ -179,8 +179,8 @@ type Config struct {
XPaddingPlacement string `protobuf:"bytes,17,opt,name=xPaddingPlacement,proto3" json:"xPaddingPlacement,omitempty"` XPaddingPlacement string `protobuf:"bytes,17,opt,name=xPaddingPlacement,proto3" json:"xPaddingPlacement,omitempty"`
XPaddingMethod string `protobuf:"bytes,18,opt,name=xPaddingMethod,proto3" json:"xPaddingMethod,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"` UplinkHTTPMethod string `protobuf:"bytes,19,opt,name=uplinkHTTPMethod,proto3" json:"uplinkHTTPMethod,omitempty"`
SessionPlacement string `protobuf:"bytes,20,opt,name=sessionPlacement,proto3" json:"sessionPlacement,omitempty"` SessionIDPlacement string `protobuf:"bytes,20,opt,name=sessionIDPlacement,proto3" json:"sessionIDPlacement,omitempty"`
SessionKey string `protobuf:"bytes,21,opt,name=sessionKey,proto3" json:"sessionKey,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"` SeqPlacement string `protobuf:"bytes,22,opt,name=seqPlacement,proto3" json:"seqPlacement,omitempty"`
SeqKey string `protobuf:"bytes,23,opt,name=seqKey,proto3" json:"seqKey,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"` UplinkDataPlacement string `protobuf:"bytes,24,opt,name=uplinkDataPlacement,proto3" json:"uplinkDataPlacement,omitempty"`
@@ -356,16 +356,16 @@ func (x *Config) GetUplinkHTTPMethod() string {
return "" return ""
} }
func (x *Config) GetSessionPlacement() string { func (x *Config) GetSessionIDPlacement() string {
if x != nil { if x != nil {
return x.SessionPlacement return x.SessionIDPlacement
} }
return "" return ""
} }
func (x *Config) GetSessionKey() string { func (x *Config) GetSessionIDKey() string {
if x != nil { if x != nil {
return x.SessionKey return x.SessionIDKey
} }
return "" 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" + "\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" + "\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" + "\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" + "\x06Config\x12\x12\n" +
"\x04host\x18\x01 \x01(\tR\x04host\x12\x12\n" + "\x04host\x18\x01 \x01(\tR\x04host\x12\x12\n" +
"\x04path\x18\x02 \x01(\tR\x04path\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" + "\x0exPaddingHeader\x18\x10 \x01(\tR\x0exPaddingHeader\x12,\n" +
"\x11xPaddingPlacement\x18\x11 \x01(\tR\x11xPaddingPlacement\x12&\n" + "\x11xPaddingPlacement\x18\x11 \x01(\tR\x11xPaddingPlacement\x12&\n" +
"\x0exPaddingMethod\x18\x12 \x01(\tR\x0exPaddingMethod\x12*\n" + "\x0exPaddingMethod\x18\x12 \x01(\tR\x0exPaddingMethod\x12*\n" +
"\x10uplinkHTTPMethod\x18\x13 \x01(\tR\x10uplinkHTTPMethod\x12*\n" + "\x10uplinkHTTPMethod\x18\x13 \x01(\tR\x10uplinkHTTPMethod\x12.\n" +
"\x10sessionPlacement\x18\x14 \x01(\tR\x10sessionPlacement\x12\x1e\n" + "\x12sessionIDPlacement\x18\x14 \x01(\tR\x12sessionIDPlacement\x12\"\n" +
"\n" + "\fsessionIDKey\x18\x15 \x01(\tR\fsessionIDKey\x12\"\n" +
"sessionKey\x18\x15 \x01(\tR\n" +
"sessionKey\x12\"\n" +
"\fseqPlacement\x18\x16 \x01(\tR\fseqPlacement\x12\x16\n" + "\fseqPlacement\x18\x16 \x01(\tR\fseqPlacement\x12\x16\n" +
"\x06seqKey\x18\x17 \x01(\tR\x06seqKey\x120\n" + "\x06seqKey\x18\x17 \x01(\tR\x06seqKey\x120\n" +
"\x13uplinkDataPlacement\x18\x18 \x01(\tR\x13uplinkDataPlacement\x12$\n" + "\x13uplinkDataPlacement\x18\x18 \x01(\tR\x13uplinkDataPlacement\x12$\n" +
+2 -2
View File
@@ -42,8 +42,8 @@ message Config {
string xPaddingPlacement = 17; string xPaddingPlacement = 17;
string xPaddingMethod = 18; string xPaddingMethod = 18;
string uplinkHTTPMethod = 19; string uplinkHTTPMethod = 19;
string sessionPlacement = 20; string sessionIDPlacement = 20;
string sessionKey = 21; string sessionIDKey = 21;
string seqPlacement = 22; string seqPlacement = 22;
string seqKey = 23; string seqKey = 23;
string uplinkDataPlacement = 24; string uplinkDataPlacement = 24;