@@ -16,8 +16,6 @@ import (
1616 "github.com/xtls/xray-core/common/platform/filesystem"
1717 "github.com/xtls/xray-core/common/serial"
1818 "github.com/xtls/xray-core/transport/internet"
19- httpheader "github.com/xtls/xray-core/transport/internet/headers/http"
20- "github.com/xtls/xray-core/transport/internet/http"
2119 "github.com/xtls/xray-core/transport/internet/httpupgrade"
2220 "github.com/xtls/xray-core/transport/internet/kcp"
2321 "github.com/xtls/xray-core/transport/internet/reality"
@@ -344,51 +342,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
344342 return config , nil
345343}
346344
347- type HTTPConfig struct {
348- Host * StringList `json:"host"`
349- Path string `json:"path"`
350- ReadIdleTimeout int32 `json:"read_idle_timeout"`
351- HealthCheckTimeout int32 `json:"health_check_timeout"`
352- Method string `json:"method"`
353- Headers map [string ]* StringList `json:"headers"`
354- }
355-
356- // Build implements Buildable.
357- func (c * HTTPConfig ) Build () (proto.Message , error ) {
358- if c .ReadIdleTimeout <= 0 {
359- c .ReadIdleTimeout = 0
360- }
361- if c .HealthCheckTimeout <= 0 {
362- c .HealthCheckTimeout = 0
363- }
364- config := & http.Config {
365- Path : c .Path ,
366- IdleTimeout : c .ReadIdleTimeout ,
367- HealthCheckTimeout : c .HealthCheckTimeout ,
368- }
369- if c .Host != nil {
370- config .Host = []string (* c .Host )
371- }
372- if c .Method != "" {
373- config .Method = c .Method
374- }
375- if len (c .Headers ) > 0 {
376- config .Header = make ([]* httpheader.Header , 0 , len (c .Headers ))
377- headerNames := sortMapKeys (c .Headers )
378- for _ , key := range headerNames {
379- value := c .Headers [key ]
380- if value == nil {
381- return nil , errors .New ("empty HTTP header value: " + key ).AtError ()
382- }
383- config .Header = append (config .Header , & httpheader.Header {
384- Name : key ,
385- Value : append ([]string (nil ), (* value )... ),
386- })
387- }
388- }
389- return config , nil
390- }
391-
392345func readFileOrString (f string , s []string ) ([]byte , error ) {
393346 if len (f ) > 0 {
394347 return filesystem .ReadFile (f )
@@ -709,20 +662,23 @@ func (p TransportProtocol) Build() (string, error) {
709662 switch strings .ToLower (string (p )) {
710663 case "raw" , "tcp" :
711664 return "tcp" , nil
665+ case "xhttp" , "splithttp" :
666+ return "splithttp" , nil
712667 case "kcp" , "mkcp" :
713668 return "mkcp" , nil
714- case "ws" , "websocket" :
715- return "websocket" , nil
716- case "h2" , "h3" , "http" :
717- errors .PrintDeprecatedFeatureWarning ("HTTP transport" , "XHTTP transport" )
718- return "http" , nil
719669 case "grpc" :
720- errors .PrintMigrateFeatureInfo ("gRPC transport" , "XHTTP transport " )
670+ errors .PrintDeprecatedFeatureWarning ("gRPC transport (with unnecessary costs, etc.) " , "XHTTP stream-up H2 " )
721671 return "grpc" , nil
672+ case "ws" , "websocket" :
673+ errors .PrintDeprecatedFeatureWarning ("WebSocket transport (with ALPN http/1.1, etc.)" , "XHTTP H2 & H3" )
674+ return "websocket" , nil
722675 case "httpupgrade" :
676+ errors .PrintDeprecatedFeatureWarning ("HTTPUpgrade transport (with ALPN http/1.1, etc.)" , "XHTTP H2 & H3" )
723677 return "httpupgrade" , nil
724- case "xhttp" , "splithttp" :
725- return "splithttp" , nil
678+ case "h2" , "h3" , "http" :
679+ return "" , errors .PrintRemovedFeatureError ("HTTP transport (without header padding, etc.)" , "XHTTP stream-one H2 & H3" )
680+ case "quic" :
681+ return "" , errors .PrintRemovedFeatureError ("QUIC transport (without web service, etc.)" , "XHTTP stream-one H3" )
726682 default :
727683 return "" , errors .New ("Config: unknown transport protocol: " , p )
728684 }
@@ -852,14 +808,13 @@ type StreamConfig struct {
852808 REALITYSettings * REALITYConfig `json:"realitySettings"`
853809 RAWSettings * TCPConfig `json:"rawSettings"`
854810 TCPSettings * TCPConfig `json:"tcpSettings"`
811+ XHTTPSettings * SplitHTTPConfig `json:"xhttpSettings"`
812+ SplitHTTPSettings * SplitHTTPConfig `json:"splithttpSettings"`
855813 KCPSettings * KCPConfig `json:"kcpSettings"`
814+ GRPCSettings * GRPCConfig `json:"grpcSettings"`
856815 WSSettings * WebSocketConfig `json:"wsSettings"`
857- HTTPSettings * HTTPConfig `json:"httpSettings"`
858- SocketSettings * SocketConfig `json:"sockopt"`
859- GRPCConfig * GRPCConfig `json:"grpcSettings"`
860816 HTTPUPGRADESettings * HttpUpgradeConfig `json:"httpupgradeSettings"`
861- XHTTPSettings * SplitHTTPConfig `json:"xhttpSettings"`
862- SplitHTTPSettings * SplitHTTPConfig `json:"splithttpSettings"`
817+ SocketSettings * SocketConfig `json:"sockopt"`
863818}
864819
865820// Build implements Buildable.
@@ -893,8 +848,8 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
893848 config .SecuritySettings = append (config .SecuritySettings , tm )
894849 config .SecurityType = tm .Type
895850 case "reality" :
896- if config .ProtocolName != "tcp" && config .ProtocolName != "http " && config .ProtocolName != "grpc" && config . ProtocolName != "splithttp " {
897- return nil , errors .New ("REALITY only supports RAW, H2, gRPC and XHTTP for now." )
851+ if config .ProtocolName != "tcp" && config .ProtocolName != "splithttp " && config .ProtocolName != "grpc" {
852+ return nil , errors .New ("REALITY only supports RAW, XHTTP and gRPC for now." )
898853 }
899854 if c .REALITYSettings == nil {
900855 return nil , errors .New (`REALITY: Empty "realitySettings".` )
@@ -924,38 +879,31 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
924879 Settings : serial .ToTypedMessage (ts ),
925880 })
926881 }
927- if c .KCPSettings != nil {
928- ts , err := c .KCPSettings .Build ()
929- if err != nil {
930- return nil , errors .New ("Failed to build mKCP config." ).Base (err )
931- }
932- config .TransportSettings = append (config .TransportSettings , & internet.TransportConfig {
933- ProtocolName : "mkcp" ,
934- Settings : serial .ToTypedMessage (ts ),
935- })
882+ if c .XHTTPSettings != nil {
883+ c .SplitHTTPSettings = c .XHTTPSettings
936884 }
937- if c .WSSettings != nil {
938- ts , err := c .WSSettings .Build ()
885+ if c .SplitHTTPSettings != nil {
886+ hs , err := c .SplitHTTPSettings .Build ()
939887 if err != nil {
940- return nil , errors .New ("Failed to build WebSocket config." ).Base (err )
888+ return nil , errors .New ("Failed to build XHTTP config." ).Base (err )
941889 }
942890 config .TransportSettings = append (config .TransportSettings , & internet.TransportConfig {
943- ProtocolName : "websocket " ,
944- Settings : serial .ToTypedMessage (ts ),
891+ ProtocolName : "splithttp " ,
892+ Settings : serial .ToTypedMessage (hs ),
945893 })
946894 }
947- if c .HTTPSettings != nil {
948- ts , err := c .HTTPSettings .Build ()
895+ if c .KCPSettings != nil {
896+ ts , err := c .KCPSettings .Build ()
949897 if err != nil {
950- return nil , errors .New ("Failed to build HTTP config." ).Base (err )
898+ return nil , errors .New ("Failed to build mKCP config." ).Base (err )
951899 }
952900 config .TransportSettings = append (config .TransportSettings , & internet.TransportConfig {
953- ProtocolName : "http " ,
901+ ProtocolName : "mkcp " ,
954902 Settings : serial .ToTypedMessage (ts ),
955903 })
956904 }
957- if c .GRPCConfig != nil {
958- gs , err := c .GRPCConfig .Build ()
905+ if c .GRPCSettings != nil {
906+ gs , err := c .GRPCSettings .Build ()
959907 if err != nil {
960908 return nil , errors .New ("Failed to build gRPC config." ).Base (err )
961909 }
@@ -964,33 +912,30 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
964912 Settings : serial .ToTypedMessage (gs ),
965913 })
966914 }
967- if c .HTTPUPGRADESettings != nil {
968- hs , err := c .HTTPUPGRADESettings .Build ()
915+ if c .WSSettings != nil {
916+ ts , err := c .WSSettings .Build ()
969917 if err != nil {
970- return nil , errors .New ("Failed to build HttpUpgrade config." ).Base (err )
918+ return nil , errors .New ("Failed to build WebSocket config." ).Base (err )
971919 }
972920 config .TransportSettings = append (config .TransportSettings , & internet.TransportConfig {
973- ProtocolName : "httpupgrade " ,
974- Settings : serial .ToTypedMessage (hs ),
921+ ProtocolName : "websocket " ,
922+ Settings : serial .ToTypedMessage (ts ),
975923 })
976924 }
977- if c .XHTTPSettings != nil {
978- c .SplitHTTPSettings = c .XHTTPSettings
979- }
980- if c .SplitHTTPSettings != nil {
981- hs , err := c .SplitHTTPSettings .Build ()
925+ if c .HTTPUPGRADESettings != nil {
926+ hs , err := c .HTTPUPGRADESettings .Build ()
982927 if err != nil {
983- return nil , errors .New ("Failed to build XHTTP config." ).Base (err )
928+ return nil , errors .New ("Failed to build HTTPUpgrade config." ).Base (err )
984929 }
985930 config .TransportSettings = append (config .TransportSettings , & internet.TransportConfig {
986- ProtocolName : "splithttp " ,
931+ ProtocolName : "httpupgrade " ,
987932 Settings : serial .ToTypedMessage (hs ),
988933 })
989934 }
990935 if c .SocketSettings != nil {
991936 ss , err := c .SocketSettings .Build ()
992937 if err != nil {
993- return nil , errors .New ("Failed to build sockopt" ).Base (err )
938+ return nil , errors .New ("Failed to build sockopt. " ).Base (err )
994939 }
995940 config .SocketSettings = ss
996941 }
0 commit comments