mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-16 20:45:50 +00:00
1. **Fixed XPadding Placement Dropdown**: - Added the missing `cookie` and `query` options to `xPaddingPlacement` (`stream_xhttp.html`). - *Why:* Previously, users wanting `cookie` obfuscation were forced to use the `header` placement string. This caused Xray-core to blindly intercept the entire monolithic HTTP Cookie header, failing internal padding-length validations and causing the inbound to silently drop the connection. 2. **Fixed Uplink Data Placement Validation**: - Replaced the unsupported `query` option with `cookie` in `uplinkDataPlacement`. - *Why:* Xray-core's `transport_internet.go` explicitly forbids `query` as an uplink placement option. Selecting it from the UI previously sent a payload that would cause Xray-core to instantly throw an `unsupported uplink data placement: query` panic. Adding `cookie` perfectly aligns the UI with Xray-core restrictions. ### Related Issues - Resolves #3992
58 lines
1 KiB
Go
58 lines
1 KiB
Go
package serial_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
. "github.com/xtls/xray-core/common/serial"
|
|
)
|
|
|
|
func TestToString(t *testing.T) {
|
|
s := "a"
|
|
data := []struct {
|
|
Value interface{}
|
|
String string
|
|
}{
|
|
{Value: s, String: s},
|
|
{Value: &s, String: s},
|
|
{Value: errors.New("t"), String: "t"},
|
|
{Value: []byte{'b', 'c'}, String: "[98 99]"},
|
|
}
|
|
|
|
for _, c := range data {
|
|
if r := cmp.Diff(ToString(c.Value), c.String); r != "" {
|
|
t.Error(r)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestConcat(t *testing.T) {
|
|
testCases := []struct {
|
|
Input []interface{}
|
|
Output string
|
|
}{
|
|
{
|
|
Input: []interface{}{
|
|
"a", "b",
|
|
},
|
|
Output: "ab",
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
actual := Concat(testCase.Input...)
|
|
if actual != testCase.Output {
|
|
t.Error("Unexpected output: ", actual, " but want: ", testCase.Output)
|
|
}
|
|
}
|
|
}
|
|
|
|
func BenchmarkConcat(b *testing.B) {
|
|
input := []interface{}{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"}
|
|
|
|
b.ReportAllocs()
|
|
for i := 0; i < b.N; i++ {
|
|
_ = Concat(input...)
|
|
}
|
|
}
|