mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
134
infra/conf/vless_test.go
Normal file
134
infra/conf/vless_test.go
Normal file
|
@ -0,0 +1,134 @@
|
|||
package conf_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/xtls/xray-core/v1/common/net"
|
||||
"github.com/xtls/xray-core/v1/common/protocol"
|
||||
"github.com/xtls/xray-core/v1/common/serial"
|
||||
. "github.com/xtls/xray-core/v1/infra/conf"
|
||||
"github.com/xtls/xray-core/v1/proxy/vless"
|
||||
"github.com/xtls/xray-core/v1/proxy/vless/inbound"
|
||||
"github.com/xtls/xray-core/v1/proxy/vless/outbound"
|
||||
)
|
||||
|
||||
func TestVLessOutbound(t *testing.T) {
|
||||
creator := func() Buildable {
|
||||
return new(VLessOutboundConfig)
|
||||
}
|
||||
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
Input: `{
|
||||
"vnext": [{
|
||||
"address": "example.com",
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
"id": "27848739-7e62-4138-9fd3-098a63964b6b",
|
||||
"flow": "xtls-rprx-direct-udp443",
|
||||
"encryption": "none",
|
||||
"level": 0
|
||||
}
|
||||
]
|
||||
}]
|
||||
}`,
|
||||
Parser: loadJSON(creator),
|
||||
Output: &outbound.Config{
|
||||
Vnext: []*protocol.ServerEndpoint{
|
||||
{
|
||||
Address: &net.IPOrDomain{
|
||||
Address: &net.IPOrDomain_Domain{
|
||||
Domain: "example.com",
|
||||
},
|
||||
},
|
||||
Port: 443,
|
||||
User: []*protocol.User{
|
||||
{
|
||||
Account: serial.ToTypedMessage(&vless.Account{
|
||||
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
|
||||
Flow: "xtls-rprx-direct-udp443",
|
||||
Encryption: "none",
|
||||
}),
|
||||
Level: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestVLessInbound(t *testing.T) {
|
||||
creator := func() Buildable {
|
||||
return new(VLessInboundConfig)
|
||||
}
|
||||
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
Input: `{
|
||||
"clients": [
|
||||
{
|
||||
"id": "27848739-7e62-4138-9fd3-098a63964b6b",
|
||||
"flow": "xtls-rprx-direct",
|
||||
"level": 0,
|
||||
"email": "love@example.com"
|
||||
}
|
||||
],
|
||||
"decryption": "none",
|
||||
"fallbacks": [
|
||||
{
|
||||
"dest": 80
|
||||
},
|
||||
{
|
||||
"alpn": "h2",
|
||||
"dest": "@/dev/shm/domain.socket",
|
||||
"xver": 2
|
||||
},
|
||||
{
|
||||
"path": "/innerws",
|
||||
"dest": "serve-ws-none"
|
||||
}
|
||||
]
|
||||
}`,
|
||||
Parser: loadJSON(creator),
|
||||
Output: &inbound.Config{
|
||||
Clients: []*protocol.User{
|
||||
{
|
||||
Account: serial.ToTypedMessage(&vless.Account{
|
||||
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
|
||||
Flow: "xtls-rprx-direct",
|
||||
}),
|
||||
Level: 0,
|
||||
Email: "love@example.com",
|
||||
},
|
||||
},
|
||||
Decryption: "none",
|
||||
Fallbacks: []*inbound.Fallback{
|
||||
{
|
||||
Alpn: "",
|
||||
Path: "",
|
||||
Type: "tcp",
|
||||
Dest: "127.0.0.1:80",
|
||||
Xver: 0,
|
||||
},
|
||||
{
|
||||
Alpn: "h2",
|
||||
Path: "",
|
||||
Type: "unix",
|
||||
Dest: "@/dev/shm/domain.socket",
|
||||
Xver: 2,
|
||||
},
|
||||
{
|
||||
Alpn: "",
|
||||
Path: "/innerws",
|
||||
Type: "serve",
|
||||
Dest: "serve-ws-none",
|
||||
Xver: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue