@@ -8,12 +8,9 @@ import (
88 "strings"
99
1010 "github.com/xtls/xray-core/common"
11- "github.com/xtls/xray-core/core"
1211 "github.com/xtls/xray-core/transport/internet"
1312)
1413
15- const paddingQuery = "x_padding"
16-
1714func (c * Config ) GetNormalizedPath () string {
1815 pathAndQuery := strings .SplitN (c .Path , "?" , 2 )
1916 path := pathAndQuery [0 ]
@@ -37,54 +34,40 @@ func (c *Config) GetNormalizedQuery() string {
3734 query = pathAndQuery [1 ]
3835 }
3936
40- if query != "" {
41- query += "&"
42- }
43- query += "x_version=" + core .Version ()
37+ /*
38+ if query != "" {
39+ query += "&"
40+ }
41+ query += "x_version=" + core.Version()
42+ */
4443
4544 return query
4645}
4746
48- func (c * Config ) GetRequestHeader () http.Header {
47+ func (c * Config ) GetRequestHeader (rawURL string ) http.Header {
4948 header := http.Header {}
5049 for k , v := range c .Headers {
5150 header .Add (k , v )
5251 }
5352
54- paddingLen := c .GetNormalizedXPaddingBytes ().rand ()
55- if paddingLen > 0 {
56- query , err := url .ParseQuery (c .GetNormalizedQuery ())
57- if err != nil {
58- query = url.Values {}
59- }
60- // https://www.rfc-editor.org/rfc/rfc7541.html#appendix-B
61- // h2's HPACK Header Compression feature employs a huffman encoding using a static table.
62- // 'X' is assigned an 8 bit code, so HPACK compression won't change actual padding length on the wire.
63- // https://www.rfc-editor.org/rfc/rfc9204.html#section-4.1.2-2
64- // h3's similar QPACK feature uses the same huffman table.
65- query .Set (paddingQuery , strings .Repeat ("X" , int (paddingLen )))
66-
67- referrer := url.URL {
68- Scheme : "https" , // maybe http actually, but this part is not being checked
69- Host : c .Host ,
70- Path : c .GetNormalizedPath (),
71- RawQuery : query .Encode (),
72- }
53+ u , _ := url .Parse (rawURL )
54+ // https://www.rfc-editor.org/rfc/rfc7541.html#appendix-B
55+ // h2's HPACK Header Compression feature employs a huffman encoding using a static table.
56+ // 'X' is assigned an 8 bit code, so HPACK compression won't change actual padding length on the wire.
57+ // https://www.rfc-editor.org/rfc/rfc9204.html#section-4.1.2-2
58+ // h3's similar QPACK feature uses the same huffman table.
59+ u .RawQuery = "x_padding=" + strings .Repeat ("X" , int (c .GetNormalizedXPaddingBytes ().rand ()))
60+ header .Set ("Referer" , u .String ())
7361
74- header .Set ("Referer" , referrer .String ())
75- }
7662 return header
7763}
7864
7965func (c * Config ) WriteResponseHeader (writer http.ResponseWriter ) {
8066 // CORS headers for the browser dialer
8167 writer .Header ().Set ("Access-Control-Allow-Origin" , "*" )
8268 writer .Header ().Set ("Access-Control-Allow-Methods" , "GET, POST" )
83- writer .Header ().Set ("X-Version" , core .Version ())
84- paddingLen := c .GetNormalizedXPaddingBytes ().rand ()
85- if paddingLen > 0 {
86- writer .Header ().Set ("X-Padding" , strings .Repeat ("X" , int (paddingLen )))
87- }
69+ // writer.Header().Set("X-Version", core.Version())
70+ writer .Header ().Set ("X-Padding" , strings .Repeat ("X" , int (c .GetNormalizedXPaddingBytes ().rand ())))
8871}
8972
9073func (c * Config ) GetNormalizedXPaddingBytes () RangeConfig {
@@ -128,6 +111,17 @@ func (c *Config) GetNormalizedScMaxBufferedPosts() int {
128111 return int (c .ScMaxBufferedPosts )
129112}
130113
114+ func (c * Config ) GetNormalizedScStreamUpServerSecs () RangeConfig {
115+ if c .ScStreamUpServerSecs == nil || c .ScStreamUpServerSecs .To == 0 {
116+ return RangeConfig {
117+ From : 20 ,
118+ To : 80 ,
119+ }
120+ }
121+
122+ return * c .ScMinPostsIntervalMs
123+ }
124+
131125func (m * XmuxConfig ) GetNormalizedMaxConcurrency () RangeConfig {
132126 if m .MaxConcurrency == nil {
133127 return RangeConfig {
0 commit comments