Skip to content

Commit 4a0df71

Browse files
committed
Add ws compatibility test
1 parent ef801cb commit 4a0df71

17 files changed

+305
-115
lines changed

test/config/vmess-ws-client.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"log": {
3+
"loglevel": "debug"
4+
},
5+
"inbounds": [
6+
{
7+
"listen": "127.0.0.1",
8+
"port": "1080",
9+
"protocol": "socks",
10+
"settings": {
11+
"auth": "noauth",
12+
"udp": true,
13+
"ip": "127.0.0.1"
14+
}
15+
}
16+
],
17+
"outbounds": [
18+
{
19+
"protocol": "vmess",
20+
"settings": {
21+
"vnext": [
22+
{
23+
"address": "127.0.0.1",
24+
"port": 1234,
25+
"users": [
26+
{
27+
"id": ""
28+
}
29+
]
30+
}
31+
]
32+
},
33+
"streamSettings": {
34+
"network": "ws",
35+
"security": "tls",
36+
"tlsSettings": {
37+
"serverName": "example.org",
38+
"certificates": [
39+
{
40+
"certificateFile": "/path/to/certificate.crt",
41+
"keyFile": "/path/to/private.key"
42+
}
43+
]
44+
},
45+
"wsSettings": {
46+
"maxEarlyData": 2048,
47+
"earlyDataHeaderName": ""
48+
}
49+
}
50+
}
51+
]
52+
}

test/config/vmess-ws-server.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"log": {
3+
"loglevel": "debug"
4+
},
5+
"inbounds": [
6+
{
7+
"listen": "0.0.0.0",
8+
"port": 1234,
9+
"protocol": "vmess",
10+
"settings": {
11+
"clients": [
12+
{
13+
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
14+
}
15+
]
16+
},
17+
"streamSettings": {
18+
"network": "ws",
19+
"security": "tls",
20+
"tlsSettings": {
21+
"serverName": "example.org",
22+
"certificates": [
23+
{
24+
"certificateFile": "/path/to/certificate.crt",
25+
"keyFile": "/path/to/private.key"
26+
}
27+
]
28+
},
29+
"wsSettings": {
30+
"maxEarlyData": 2048,
31+
"earlyDataHeaderName": ""
32+
}
33+
}
34+
}
35+
],
36+
"outbounds": [
37+
{
38+
"protocol": "freedom"
39+
}
40+
]
41+
}

test/direct_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import (
1010

1111
func TestProxyProtocol(t *testing.T) {
1212
startInstance(t, option.Options{
13-
Log: &option.LogOptions{
14-
Level: "error",
15-
},
1613
Inbounds: []option.Inbound{
1714
{
1815
Type: C.TypeMixed,

test/go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ require (
6262
github.com/sagernet/sing-dns v0.0.0-20220822023312-3e086b06d666 // indirect
6363
github.com/sagernet/sing-tun v0.0.0-20220828031750-185b6c880a83 // indirect
6464
github.com/sagernet/sing-vmess v0.0.0-20220829020559-33915075430c // indirect
65-
github.com/sagernet/smux v0.0.0-20220812084127-e2d085ee3939 // indirect
65+
github.com/sagernet/smux v0.0.0-20220831015742-e0f1988e3195 // indirect
6666
github.com/sirupsen/logrus v1.8.1 // indirect
6767
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
6868
go.uber.org/atomic v1.10.0 // indirect
6969
go.uber.org/multierr v1.6.0 // indirect
7070
go.uber.org/zap v1.22.0 // indirect
7171
go4.org/netipx v0.0.0-20220812043211-3cc044ffd68d // indirect
72-
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d // indirect
72+
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
7373
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
7474
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
75-
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect
75+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
7676
golang.org/x/text v0.3.7 // indirect
7777
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
7878
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f // indirect
7979
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 // indirect
80-
golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478 // indirect
80+
golang.zx2c4.com/wireguard v0.0.0-20220829161405-d1d08426b27b // indirect
8181
google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f // indirect
8282
google.golang.org/grpc v1.49.0 // indirect
8383
google.golang.org/protobuf v1.28.1 // indirect

test/go.sum

+8-8
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ github.com/sagernet/sing-tun v0.0.0-20220828031750-185b6c880a83 h1:SoWiHYuOCVedq
165165
github.com/sagernet/sing-tun v0.0.0-20220828031750-185b6c880a83/go.mod h1:76r07HS1WRcEI4mE9pFsohfTBUt1j/G9Avz6DaOP3VU=
166166
github.com/sagernet/sing-vmess v0.0.0-20220829020559-33915075430c h1:92Gn78/z/t6CkzZ4XWG/uPiCxhUmjPULFEHFMDY6K8k=
167167
github.com/sagernet/sing-vmess v0.0.0-20220829020559-33915075430c/go.mod h1:82O6gzbxLha/W/jxSVQbsqf2lVdRTjMIgyLug0lpJps=
168-
github.com/sagernet/smux v0.0.0-20220812084127-e2d085ee3939 h1:pB1Dh1NbwVrLhQhotr4O4Hs3yhiBzmg3AvnUyYjL4x4=
169-
github.com/sagernet/smux v0.0.0-20220812084127-e2d085ee3939/go.mod h1:yedWtra8nyGJ+SyI+ziwuaGMzBatbB10P1IOOZbbSK8=
168+
github.com/sagernet/smux v0.0.0-20220831015742-e0f1988e3195 h1:5VBIbVw9q7aKbrFdT83mjkyvQ+VaRsQ6yflTepfln38=
169+
github.com/sagernet/smux v0.0.0-20220831015742-e0f1988e3195/go.mod h1:yedWtra8nyGJ+SyI+ziwuaGMzBatbB10P1IOOZbbSK8=
170170
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
171171
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
172172
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
@@ -205,8 +205,8 @@ golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaE
205205
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
206206
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
207207
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
208-
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d h1:3qF+Z8Hkrw9sOhrFHti9TlB1Hkac1x+DNRkv0XQiFjo=
209-
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
208+
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
209+
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
210210
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
211211
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
212212
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
@@ -275,8 +275,8 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc
275275
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
276276
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
277277
golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
278-
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
279-
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
278+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
279+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
280280
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
281281
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
282282
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -311,8 +311,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
311311
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
312312
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 h1:Ug9qvr1myri/zFN6xL17LSCBGFDnphBBhzmILHsM5TY=
313313
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
314-
golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478 h1:vDy//hdR+GnROE3OdYbQKt9rdtNdHkDtONvpRwmls/0=
315-
golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478/go.mod h1:bVQfyl2sCM/QIIGHpWbFGfHPuDvqnCNkT6MQLTCjO/U=
314+
golang.zx2c4.com/wireguard v0.0.0-20220829161405-d1d08426b27b h1:qgrKnOfe1zyURRNdmDlGbN32i38Zjmw0B1+TMdHcOvg=
315+
golang.zx2c4.com/wireguard v0.0.0-20220829161405-d1d08426b27b/go.mod h1:6y4CqPAy54NwiN4nC8K+R1eMpQDB1P2d25qmunh2RSA=
316316
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
317317
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
318318
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=

test/hysteria_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ func TestHysteriaSelf(t *testing.T) {
1414
}
1515
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
1616
startInstance(t, option.Options{
17-
Log: &option.LogOptions{
18-
Level: "error",
19-
},
2017
Inbounds: []option.Inbound{
2118
{
2219
Type: C.TypeMixed,
@@ -92,9 +89,6 @@ func TestHysteriaInbound(t *testing.T) {
9289
}
9390
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
9491
startInstance(t, option.Options{
95-
Log: &option.LogOptions{
96-
Level: "error",
97-
},
9892
Inbounds: []option.Inbound{
9993
{
10094
Type: C.TypeHysteria,
@@ -145,9 +139,6 @@ func TestHysteriaOutbound(t *testing.T) {
145139
},
146140
})
147141
startInstance(t, option.Options{
148-
Log: &option.LogOptions{
149-
Level: "error",
150-
},
151142
Inbounds: []option.Inbound{
152143
{
153144
Type: C.TypeMixed,

test/inbound_detour_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ func TestChainedInbound(t *testing.T) {
1313
method := shadowaead_2022.List[0]
1414
password := mkBase64(t, 16)
1515
startInstance(t, option.Options{
16-
Log: &option.LogOptions{
17-
Level: "error",
18-
},
1916
Inbounds: []option.Inbound{
2017
{
2118
Type: C.TypeMixed,

test/mux_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ func testShadowsocksMux(t *testing.T, protocol string) {
3737
method := shadowaead_2022.List[0]
3838
password := mkBase64(t, 16)
3939
startInstance(t, option.Options{
40-
Log: &option.LogOptions{
41-
Level: "error",
42-
},
4340
Inbounds: []option.Inbound{
4441
{
4542
Type: C.TypeMixed,
@@ -101,9 +98,6 @@ func testShadowsocksMux(t *testing.T, protocol string) {
10198
func testVMessMux(t *testing.T, protocol string) {
10299
user, _ := uuid.NewV4()
103100
startInstance(t, option.Options{
104-
Log: &option.LogOptions{
105-
Level: "error",
106-
},
107101
Inbounds: []option.Inbound{
108102
{
109103
Type: C.TypeMixed,

test/naive_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ import (
1313
func TestNaiveInboundWithNginx(t *testing.T) {
1414
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
1515
startInstance(t, option.Options{
16-
Log: &option.LogOptions{
17-
Level: "error",
18-
},
1916
Inbounds: []option.Inbound{
2017
{
2118
Type: C.TypeNaive,
@@ -62,9 +59,6 @@ func TestNaiveInboundWithNginx(t *testing.T) {
6259
func TestNaiveInbound(t *testing.T) {
6360
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
6461
startInstance(t, option.Options{
65-
Log: &option.LogOptions{
66-
Level: "error",
67-
},
6862
Inbounds: []option.Inbound{
6963
{
7064
Type: C.TypeNaive,
@@ -110,9 +104,6 @@ func TestNaiveHTTP3Inbound(t *testing.T) {
110104
}
111105
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
112106
startInstance(t, option.Options{
113-
Log: &option.LogOptions{
114-
Level: "error",
115-
},
116107
Inbounds: []option.Inbound{
117108
{
118109
Type: C.TypeNaive,

test/shadowsocks_test.go

-12
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ func testShadowsocksInboundWithShadowsocksRust(t *testing.T, method string, pass
7777
Cmd: []string{"-s", F.ToString("127.0.0.1:", serverPort), "-b", F.ToString("0.0.0.0:", clientPort), "-m", method, "-k", password, "-U"},
7878
})
7979
startInstance(t, option.Options{
80-
Log: &option.LogOptions{
81-
Level: "error",
82-
},
8380
Inbounds: []option.Inbound{
8481
{
8582
Type: C.TypeShadowsocks,
@@ -105,9 +102,6 @@ func testShadowsocksOutboundWithShadowsocksRust(t *testing.T, method string, pas
105102
Cmd: []string{"-s", F.ToString("0.0.0.0:", serverPort), "-m", method, "-k", password, "-U"},
106103
})
107104
startInstance(t, option.Options{
108-
Log: &option.LogOptions{
109-
Level: "error",
110-
},
111105
Inbounds: []option.Inbound{
112106
{
113107
Type: C.TypeMixed,
@@ -138,9 +132,6 @@ func testShadowsocksOutboundWithShadowsocksRust(t *testing.T, method string, pas
138132

139133
func testShadowsocksSelf(t *testing.T, method string, password string) {
140134
startInstance(t, option.Options{
141-
Log: &option.LogOptions{
142-
Level: "error",
143-
},
144135
Inbounds: []option.Inbound{
145136
{
146137
Type: C.TypeMixed,
@@ -199,9 +190,6 @@ func TestShadowsocksUoT(t *testing.T) {
199190
method := shadowaead_2022.List[0]
200191
password := mkBase64(t, 16)
201192
startInstance(t, option.Options{
202-
Log: &option.LogOptions{
203-
Level: "error",
204-
},
205193
Inbounds: []option.Inbound{
206194
{
207195
Type: C.TypeMixed,

test/trojan_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ func TestTrojanOutbound(t *testing.T) {
2020
},
2121
})
2222
startInstance(t, option.Options{
23-
Log: &option.LogOptions{
24-
Level: "error",
25-
},
2623
Inbounds: []option.Inbound{
2724
{
2825
Type: C.TypeMixed,
@@ -58,9 +55,6 @@ func TestTrojanOutbound(t *testing.T) {
5855
func TestTrojanSelf(t *testing.T) {
5956
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
6057
startInstance(t, option.Options{
61-
Log: &option.LogOptions{
62-
Level: "error",
63-
},
6458
Inbounds: []option.Inbound{
6559
{
6660
Type: C.TypeMixed,

test/v2ray_grpc_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ func testV2RayGRPCInbound(t *testing.T, forceLite bool) {
2727
require.NoError(t, err)
2828
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
2929
startInstance(t, option.Options{
30-
Log: &option.LogOptions{
31-
Level: "error",
32-
},
3330
Inbounds: []option.Inbound{
3431
{
3532
Type: C.TypeVMess,
@@ -125,9 +122,6 @@ func testV2RayGRPCOutbound(t *testing.T, forceLite bool) {
125122
},
126123
})
127124
startInstance(t, option.Options{
128-
Log: &option.LogOptions{
129-
Level: "error",
130-
},
131125
Inbounds: []option.Inbound{
132126
{
133127
Type: C.TypeMixed,

0 commit comments

Comments
 (0)