forked from SagerNet/sing-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathss_plugin_test.go
66 lines (61 loc) · 1.75 KB
/
ss_plugin_test.go
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
package main
import (
"net/netip"
"testing"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
)
func TestShadowsocksObfs(t *testing.T) {
for _, mode := range []string{
"http", "tls",
} {
t.Run("obfs-local "+mode, func(t *testing.T) {
testShadowsocksPlugin(t, "obfs-local", "obfs="+mode, "--plugin obfs-server --plugin-opts obfs="+mode)
})
}
}
// Since I can't test this on m1 mac (rosetta error: bss_size overflow), I don't care about it
func _TestShadowsocksV2RayPlugin(t *testing.T) {
testShadowsocksPlugin(t, "v2ray-plugin", "", "--plugin v2ray-plugin --plugin-opts=server")
}
func testShadowsocksPlugin(t *testing.T, name string, opts string, args string) {
startDockerContainer(t, DockerOptions{
Image: ImageShadowsocksLegacy,
Ports: []uint16{serverPort, testPort},
Env: []string{
"SS_MODULE=ss-server",
"SS_CONFIG=-s 0.0.0.0 -u -p 10000 -m chacha20-ietf-poly1305 -k FzcLbKs2dY9mhL " + args,
},
})
startInstance(t, option.Options{
Inbounds: []option.Inbound{
{
Type: C.TypeMixed,
Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort,
},
},
},
},
Outbounds: []option.Outbound{
{
Type: C.TypeShadowsocks,
Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{
Server: "127.0.0.1",
ServerPort: serverPort,
},
Method: "chacha20-ietf-poly1305",
Password: "FzcLbKs2dY9mhL",
Plugin: name,
PluginOptions: opts,
},
},
},
})
testSuitSimple(t, clientPort, testPort)
}