mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-16 12:35:54 +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
86 lines
2.3 KiB
Go
86 lines
2.3 KiB
Go
package core_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/xtls/xray-core/app/dispatcher"
|
|
"github.com/xtls/xray-core/app/proxyman"
|
|
"github.com/xtls/xray-core/common"
|
|
"github.com/xtls/xray-core/common/net"
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
"github.com/xtls/xray-core/common/serial"
|
|
"github.com/xtls/xray-core/common/uuid"
|
|
. "github.com/xtls/xray-core/core"
|
|
"github.com/xtls/xray-core/features/dns"
|
|
"github.com/xtls/xray-core/features/dns/localdns"
|
|
_ "github.com/xtls/xray-core/main/distro/all"
|
|
"github.com/xtls/xray-core/proxy/dokodemo"
|
|
"github.com/xtls/xray-core/proxy/vmess"
|
|
"github.com/xtls/xray-core/proxy/vmess/outbound"
|
|
"github.com/xtls/xray-core/testing/servers/tcp"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func TestXrayDependency(t *testing.T) {
|
|
instance := new(Instance)
|
|
|
|
wait := make(chan bool, 1)
|
|
instance.RequireFeatures(func(d dns.Client) {
|
|
if d == nil {
|
|
t.Error("expected dns client fulfilled, but actually nil")
|
|
}
|
|
wait <- true
|
|
}, false)
|
|
instance.AddFeature(localdns.New())
|
|
<-wait
|
|
}
|
|
|
|
func TestXrayClose(t *testing.T) {
|
|
port := tcp.PickPort()
|
|
|
|
userID := uuid.New()
|
|
config := &Config{
|
|
App: []*serial.TypedMessage{
|
|
serial.ToTypedMessage(&dispatcher.Config{}),
|
|
serial.ToTypedMessage(&proxyman.InboundConfig{}),
|
|
serial.ToTypedMessage(&proxyman.OutboundConfig{}),
|
|
},
|
|
Inbound: []*InboundHandlerConfig{
|
|
{
|
|
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
|
PortList: &net.PortList{
|
|
Range: []*net.PortRange{net.SinglePortRange(port)},
|
|
},
|
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
|
}),
|
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
|
Port: uint32(0),
|
|
Networks: []net.Network{net.Network_TCP},
|
|
}),
|
|
},
|
|
},
|
|
Outbound: []*OutboundHandlerConfig{
|
|
{
|
|
ProxySettings: serial.ToTypedMessage(&outbound.Config{
|
|
Receiver: &protocol.ServerEndpoint{
|
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
|
Port: uint32(0),
|
|
User: &protocol.User{
|
|
Account: serial.ToTypedMessage(&vmess.Account{
|
|
Id: userID.String(),
|
|
}),
|
|
},
|
|
},
|
|
}),
|
|
},
|
|
},
|
|
}
|
|
|
|
cfgBytes, err := proto.Marshal(config)
|
|
common.Must(err)
|
|
|
|
server, err := StartInstance("protobuf", cfgBytes)
|
|
common.Must(err)
|
|
server.Close()
|
|
}
|