1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
| package v4_test
|
| import (
| "testing"
|
| "github.com/v2fly/v2ray-core/v5/common/net"
| "github.com/v2fly/v2ray-core/v5/common/protocol"
| "github.com/v2fly/v2ray-core/v5/common/serial"
| "github.com/v2fly/v2ray-core/v5/infra/conf/cfgcommon"
| "github.com/v2fly/v2ray-core/v5/infra/conf/cfgcommon/testassist"
| v4 "github.com/v2fly/v2ray-core/v5/infra/conf/v4"
| "github.com/v2fly/v2ray-core/v5/proxy/vless"
| "github.com/v2fly/v2ray-core/v5/proxy/vless/inbound"
| "github.com/v2fly/v2ray-core/v5/proxy/vless/outbound"
| )
|
| func TestVLessOutbound(t *testing.T) {
| creator := func() cfgcommon.Buildable {
| return new(v4.VLessOutboundConfig)
| }
|
| testassist.RunMultiTestCase(t, []testassist.TestCase{
| {
| Input: `{
| "vnext": [{
| "address": "example.com",
| "port": 443,
| "users": [
| {
| "id": "27848739-7e62-4138-9fd3-098a63964b6b",
| "encryption": "none",
| "level": 0
| }
| ]
| }]
| }`,
| Parser: testassist.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",
| Encryption: "none",
| }),
| Level: 0,
| },
| },
| },
| },
| },
| },
| })
| }
|
| func TestVLessInbound(t *testing.T) {
| creator := func() cfgcommon.Buildable {
| return new(v4.VLessInboundConfig)
| }
|
| testassist.RunMultiTestCase(t, []testassist.TestCase{
| {
| Input: `{
| "clients": [
| {
| "id": "27848739-7e62-4138-9fd3-098a63964b6b",
| "level": 0,
| "email": "love@v2fly.org"
| }
| ],
| "decryption": "none",
| "fallbacks": [
| {
| "dest": 80
| },
| {
| "alpn": "h2",
| "dest": "@/dev/shm/domain.socket",
| "xver": 2
| },
| {
| "path": "/innerws",
| "dest": "serve-ws-none"
| }
| ]
| }`,
| Parser: testassist.LoadJSON(creator),
| Output: &inbound.Config{
| Clients: []*protocol.User{
| {
| Account: serial.ToTypedMessage(&vless.Account{
| Id: "27848739-7e62-4138-9fd3-098a63964b6b",
| }),
| Level: 0,
| Email: "love@v2fly.org",
| },
| },
| 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,
| },
| },
| },
| },
| })
| }
|
|