2021-05-17 20:33:00 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2021-06-10 14:05:56 +08:00
|
|
|
"github.com/Dreamacro/clash/adapter/outbound"
|
2021-05-17 20:33:00 +08:00
|
|
|
C "github.com/Dreamacro/clash/constant"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/container"
|
2022-05-21 17:37:06 +08:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-05-17 20:33:00 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestClash_Vmess(t *testing.T) {
|
|
|
|
configPath := C.Path.Resolve("vmess.json")
|
|
|
|
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{fmt.Sprintf("%s:/etc/v2ray/config.json", configPath)},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
2022-02-27 18:00:04 +08:00
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
UDP: true,
|
2021-05-17 20:33:00 +08:00
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClash_VmessTLS(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-tls.json")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/fullchain.pem", C.Path.Resolve("example.org.pem")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/privkey.pem", C.Path.Resolve("example.org-key.pem")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-tls")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
TLS: true,
|
|
|
|
SkipCertVerify: true,
|
|
|
|
ServerName: "example.org",
|
|
|
|
UDP: true,
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClash_VmessHTTP2(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-http2.json")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/fullchain.pem", C.Path.Resolve("example.org.pem")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/privkey.pem", C.Path.Resolve("example.org-key.pem")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-http2")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "h2",
|
|
|
|
TLS: true,
|
|
|
|
SkipCertVerify: true,
|
|
|
|
ServerName: "example.org",
|
|
|
|
UDP: true,
|
|
|
|
HTTP2Opts: outbound.HTTP2Options{
|
|
|
|
Host: []string{"example.org"},
|
|
|
|
Path: "/test",
|
|
|
|
},
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClash_VmessHTTP(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-http.json")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-http")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "http",
|
|
|
|
UDP: true,
|
|
|
|
HTTPOpts: outbound.HTTPOptions{
|
|
|
|
Method: "GET",
|
|
|
|
Path: []string{"/"},
|
|
|
|
Headers: map[string][]string{
|
|
|
|
"Host": {"www.amazon.com"},
|
|
|
|
"User-Agent": {
|
|
|
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 Edg/84.0.522.49",
|
|
|
|
},
|
|
|
|
"Accept-Encoding": {
|
|
|
|
"gzip, deflate",
|
|
|
|
},
|
|
|
|
"Connection": {
|
|
|
|
"keep-alive",
|
|
|
|
},
|
|
|
|
"Pragma": {"no-cache"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClash_VmessWebsocket(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-ws.json")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-ws")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "ws",
|
|
|
|
UDP: true,
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClash_VmessWebsocketTLS(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-ws-tls.json")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/fullchain.pem", C.Path.Resolve("example.org.pem")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/privkey.pem", C.Path.Resolve("example.org-key.pem")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-01-30 14:14:42 +08:00
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-ws-tls")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "ws",
|
|
|
|
TLS: true,
|
|
|
|
SkipCertVerify: true,
|
|
|
|
UDP: true,
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
2023-01-30 14:14:42 +08:00
|
|
|
func TestClash_VmessWebsocketTLSZero(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-ws-tls-zero.json")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/fullchain.pem", C.Path.Resolve("example.org.pem")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/privkey.pem", C.Path.Resolve("example.org-key.pem")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-ws-tls-zero")
|
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "zero",
|
|
|
|
Network: "ws",
|
|
|
|
TLS: true,
|
|
|
|
SkipCertVerify: true,
|
|
|
|
UDP: true,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
2021-05-17 20:33:00 +08:00
|
|
|
func TestClash_VmessGrpc(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
2021-10-16 20:35:06 +08:00
|
|
|
Image: ImageVmess,
|
2021-05-17 20:33:00 +08:00
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-05-17 20:33:00 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
2021-10-16 20:35:06 +08:00
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-grpc.json")),
|
2021-05-17 20:33:00 +08:00
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/fullchain.pem", C.Path.Resolve("example.org.pem")),
|
|
|
|
fmt.Sprintf("%s:/etc/ssl/v2ray/privkey.pem", C.Path.Resolve("example.org-key.pem")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-grpc")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "grpc",
|
|
|
|
TLS: true,
|
|
|
|
SkipCertVerify: true,
|
|
|
|
UDP: true,
|
|
|
|
ServerName: "example.org",
|
|
|
|
GrpcOpts: outbound.GrpcOptions{
|
2021-08-19 22:11:56 +08:00
|
|
|
GrpcServiceName: "example!",
|
2021-05-17 20:33:00 +08:00
|
|
|
},
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-05-17 20:33:00 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
2021-07-18 17:23:22 +08:00
|
|
|
|
2021-08-22 01:17:29 +08:00
|
|
|
func TestClash_VmessWebsocket0RTT(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
2021-08-22 16:16:45 +08:00
|
|
|
Image: ImageVmess,
|
2021-08-22 01:17:29 +08:00
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-08-22 01:17:29 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
2021-08-22 16:16:45 +08:00
|
|
|
fmt.Sprintf("%s:/etc/v2ray/config.json", C.Path.Resolve("vmess-ws-0rtt.json")),
|
2021-08-22 01:17:29 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-ws-0rtt")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-08-22 01:17:29 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "ws",
|
|
|
|
UDP: true,
|
|
|
|
ServerName: "example.org",
|
|
|
|
WSOpts: outbound.WSOptions{
|
|
|
|
MaxEarlyData: 2048,
|
|
|
|
EarlyDataHeaderName: "Sec-WebSocket-Protocol",
|
|
|
|
},
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-08-22 01:17:29 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
2021-08-22 16:16:45 +08:00
|
|
|
func TestClash_VmessWebsocketXray0RTT(t *testing.T) {
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageXray,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{
|
|
|
|
fmt.Sprintf("%s:/etc/xray/config.json", C.Path.Resolve("vmess-ws-0rtt.json")),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-xray-ws-0rtt")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
2021-08-22 16:16:45 +08:00
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
|
|
|
Network: "ws",
|
|
|
|
UDP: true,
|
|
|
|
ServerName: "example.org",
|
|
|
|
WSOpts: outbound.WSOptions{
|
|
|
|
Path: "/?ed=2048",
|
|
|
|
},
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(t, err)
|
2021-08-22 16:16:45 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|
|
|
|
|
2021-07-18 17:23:22 +08:00
|
|
|
func Benchmark_Vmess(b *testing.B) {
|
2022-05-21 17:37:06 +08:00
|
|
|
configPath := C.Path.Resolve("vmess.json")
|
2021-07-18 17:23:22 +08:00
|
|
|
|
|
|
|
cfg := &container.Config{
|
|
|
|
Image: ImageVmess,
|
|
|
|
ExposedPorts: defaultExposedPorts,
|
2023-01-30 14:14:42 +08:00
|
|
|
Entrypoint: []string{"/usr/bin/v2ray"},
|
|
|
|
Cmd: []string{"run", "-c", "/etc/v2ray/config.json"},
|
2021-07-18 17:23:22 +08:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
|
|
|
PortBindings: defaultPortBindings,
|
|
|
|
Binds: []string{fmt.Sprintf("%s:/etc/v2ray/config.json", configPath)},
|
|
|
|
}
|
|
|
|
|
2022-05-23 12:27:34 +08:00
|
|
|
id, err := startContainer(cfg, hostCfg, "vmess-bench")
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(b, err)
|
2021-07-18 17:23:22 +08:00
|
|
|
|
|
|
|
b.Cleanup(func() {
|
|
|
|
cleanContainer(id)
|
|
|
|
})
|
|
|
|
|
|
|
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
|
|
Name: "vmess",
|
|
|
|
Server: localIP.String(),
|
|
|
|
Port: 10002,
|
|
|
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
|
|
Cipher: "auto",
|
2021-07-18 17:37:23 +08:00
|
|
|
AlterID: 0,
|
2021-07-18 17:23:22 +08:00
|
|
|
UDP: true,
|
|
|
|
})
|
2022-05-21 17:37:06 +08:00
|
|
|
require.NoError(b, err)
|
2021-07-18 17:23:22 +08:00
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
benchmarkProxy(b, proxy)
|
|
|
|
}
|