1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/infra/conf/vless_test.go

135 lines
2.5 KiB
Go
Raw Normal View History

2020-07-28 11:00:23 -04:00
package conf_test
import (
"testing"
"v2ray.com/core/common/net"
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/serial"
. "v2ray.com/core/infra/conf"
"v2ray.com/core/proxy/vless"
"v2ray.com/core/proxy/vless/inbound"
"v2ray.com/core/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",
2020-09-23 21:59:14 -04:00
"flow": "xtls-rprx-origin-udp443",
2020-07-28 11:00:23 -04:00
"encryption": "none",
"level": 0
}
]
}]
}`,
Parser: loadJSON(creator),
Output: &outbound.Config{
2020-08-28 03:51:09 -04:00
Vnext: []*protocol.ServerEndpoint{
2020-07-28 11:00:23 -04:00
{
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",
2020-09-23 21:59:14 -04:00
Flow: "xtls-rprx-origin-udp443",
2020-07-28 11:00:23 -04:00
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",
2020-09-23 21:59:14 -04:00
"flow": "xtls-rprx-origin",
2020-07-28 11:00:23 -04:00
"level": 0,
"email": "love@v2fly.org"
}
],
"decryption": "none",
2020-08-28 03:51:09 -04:00
"fallbacks": [
{
"dest": 80
},
{
"alpn": "h2",
"dest": "@/dev/shm/domain.socket",
"xver": 2
},
{
"path": "/innerws",
"dest": "serve-ws-none"
}
]
2020-07-28 11:00:23 -04:00
}`,
Parser: loadJSON(creator),
Output: &inbound.Config{
2020-08-28 03:51:09 -04:00
Clients: []*protocol.User{
2020-07-28 11:00:23 -04:00
{
Account: serial.ToTypedMessage(&vless.Account{
2020-09-23 21:59:14 -04:00
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
Flow: "xtls-rprx-origin",
2020-07-28 11:00:23 -04:00
}),
Level: 0,
Email: "love@v2fly.org",
},
},
Decryption: "none",
2020-08-28 03:51:09 -04:00
Fallbacks: []*inbound.Fallback{
{
Alpn: "",
Path: "",
Type: "tcp",
Dest: "127.0.0.1:80",
Xver: 0,
2020-07-28 11:00:23 -04:00
},
2020-08-28 03:51:09 -04:00
{
Alpn: "h2",
Path: "",
Type: "unix",
2020-09-07 04:39:53 -04:00
Dest: "@/dev/shm/domain.socket",
2020-08-28 03:51:09 -04:00
Xver: 2,
},
{
Alpn: "",
Path: "/innerws",
Type: "serve",
Dest: "serve-ws-none",
Xver: 0,
2020-08-03 02:13:26 -04:00
},
2020-07-28 11:00:23 -04:00
},
},
},
})
}