@@ -34,10 +34,16 @@ func testVMess0(t *testing.T, security string) {
34
34
user , err := uuid .DefaultGenerator .NewV4 ()
35
35
require .NoError (t , err )
36
36
t .Run ("self" , func (t * testing.T ) {
37
- testVMessSelf (t , security , user , false , false )
37
+ testVMessSelf (t , security , user , 0 , false , false )
38
38
})
39
39
t .Run ("self-padding" , func (t * testing.T ) {
40
- testVMessSelf (t , security , user , true , false )
40
+ testVMessSelf (t , security , user , 0 , true , false )
41
+ })
42
+ t .Run ("self-legacy" , func (t * testing.T ) {
43
+ testVMessSelf (t , security , user , 1 , false , false )
44
+ })
45
+ t .Run ("self-legacy-padding" , func (t * testing.T ) {
46
+ testVMessSelf (t , security , user , 1 , true , false )
41
47
})
42
48
t .Run ("outbound" , func (t * testing.T ) {
43
49
testVMessOutboundWithV2Ray (t , security , user , false , false , 0 )
@@ -57,22 +63,31 @@ func testVMess1(t *testing.T, security string) {
57
63
user , err := uuid .DefaultGenerator .NewV4 ()
58
64
require .NoError (t , err )
59
65
t .Run ("self" , func (t * testing.T ) {
60
- testVMessSelf (t , security , user , false , false )
66
+ testVMessSelf (t , security , user , 0 , false , false )
61
67
})
62
68
t .Run ("self-padding" , func (t * testing.T ) {
63
- testVMessSelf (t , security , user , true , false )
69
+ testVMessSelf (t , security , user , 0 , true , false )
64
70
})
65
71
t .Run ("self-authid" , func (t * testing.T ) {
66
- testVMessSelf (t , security , user , false , true )
72
+ testVMessSelf (t , security , user , 0 , false , true )
67
73
})
68
74
t .Run ("self-padding-authid" , func (t * testing.T ) {
69
- testVMessSelf (t , security , user , true , true )
75
+ testVMessSelf (t , security , user , 0 , true , true )
76
+ })
77
+ t .Run ("self-legacy" , func (t * testing.T ) {
78
+ testVMessSelf (t , security , user , 1 , false , false )
79
+ })
80
+ t .Run ("self-legacy-padding" , func (t * testing.T ) {
81
+ testVMessSelf (t , security , user , 1 , true , false )
70
82
})
71
83
t .Run ("inbound" , func (t * testing.T ) {
72
- testVMessInboundWithV2Ray (t , security , user , false )
84
+ testVMessInboundWithV2Ray (t , security , user , 0 , false )
73
85
})
74
86
t .Run ("inbound-authid" , func (t * testing.T ) {
75
- testVMessInboundWithV2Ray (t , security , user , true )
87
+ testVMessInboundWithV2Ray (t , security , user , 0 , true )
88
+ })
89
+ t .Run ("inbound-legacy" , func (t * testing.T ) {
90
+ testVMessInboundWithV2Ray (t , security , user , 64 , false )
76
91
})
77
92
t .Run ("outbound" , func (t * testing.T ) {
78
93
testVMessOutboundWithV2Ray (t , security , user , false , false , 0 )
@@ -92,15 +107,9 @@ func testVMess1(t *testing.T, security string) {
92
107
t .Run ("outbound-legacy-padding" , func (t * testing.T ) {
93
108
testVMessOutboundWithV2Ray (t , security , user , true , false , 1 )
94
109
})
95
- t .Run ("outbound-legacy-authid" , func (t * testing.T ) {
96
- testVMessOutboundWithV2Ray (t , security , user , false , true , 1 )
97
- })
98
- t .Run ("outbound-legacy-padding-authid" , func (t * testing.T ) {
99
- testVMessOutboundWithV2Ray (t , security , user , true , true , 1 )
100
- })
101
110
}
102
111
103
- func testVMessInboundWithV2Ray (t * testing.T , security string , uuid uuid.UUID , authenticatedLength bool ) {
112
+ func testVMessInboundWithV2Ray (t * testing.T , security string , uuid uuid.UUID , alterId int , authenticatedLength bool ) {
104
113
content , err := os .ReadFile ("config/vmess-client.json" )
105
114
require .NoError (t , err )
106
115
config , err := ajson .Unmarshal (content )
@@ -111,6 +120,7 @@ func testVMessInboundWithV2Ray(t *testing.T, security string, uuid uuid.UUID, au
111
120
outbound .MustKey ("port" ).SetNumeric (float64 (serverPort ))
112
121
user := outbound .MustKey ("users" ).MustIndex (0 )
113
122
user .MustKey ("id" ).SetString (uuid .String ())
123
+ user .MustKey ("alterId" ).SetNumeric (float64 (alterId ))
114
124
user .MustKey ("security" ).SetString (security )
115
125
var experiments string
116
126
if authenticatedLength {
@@ -143,8 +153,9 @@ func testVMessInboundWithV2Ray(t *testing.T, security string, uuid uuid.UUID, au
143
153
},
144
154
Users : []option.VMessUser {
145
155
{
146
- Name : "sekai" ,
147
- UUID : uuid .String (),
156
+ Name : "sekai" ,
157
+ UUID : uuid .String (),
158
+ AlterId : alterId ,
148
159
},
149
160
},
150
161
},
@@ -212,10 +223,11 @@ func testVMessOutboundWithV2Ray(t *testing.T, security string, uuid uuid.UUID, g
212
223
testSuit (t , clientPort , testPort )
213
224
}
214
225
215
- func testVMessSelf (t * testing.T , security string , uuid uuid.UUID , globalPadding bool , authenticatedLength bool ) {
226
+ func testVMessSelf (t * testing.T , security string , uuid uuid.UUID , alterId int , globalPadding bool , authenticatedLength bool ) {
216
227
startInstance (t , option.Options {
217
228
Log : & option.LogOptions {
218
- Level : "error" ,
229
+ Level : "error" ,
230
+ Output : "stderr" ,
219
231
},
220
232
Inbounds : []option.Inbound {
221
233
{
@@ -237,8 +249,9 @@ func testVMessSelf(t *testing.T, security string, uuid uuid.UUID, globalPadding
237
249
},
238
250
Users : []option.VMessUser {
239
251
{
240
- Name : "sekai" ,
241
- UUID : uuid .String (),
252
+ Name : "sekai" ,
253
+ UUID : uuid .String (),
254
+ AlterId : alterId ,
242
255
},
243
256
},
244
257
},
@@ -258,6 +271,7 @@ func testVMessSelf(t *testing.T, security string, uuid uuid.UUID, globalPadding
258
271
},
259
272
Security : security ,
260
273
UUID : uuid .String (),
274
+ AlterId : alterId ,
261
275
GlobalPadding : globalPadding ,
262
276
AuthenticatedLength : authenticatedLength ,
263
277
},
0 commit comments