Fix shadowsocks plugins
This commit is contained in:
@@ -38,6 +38,7 @@ const (
|
||||
ImageShadowTLS = "ghcr.io/ihciah/shadow-tls:latest"
|
||||
ImageShadowsocksR = "teddysun/shadowsocks-r:latest"
|
||||
ImageXRayCore = "teddysun/xray:latest"
|
||||
ImageShadowsocksLegacy = "mritd/shadowsocks:latest"
|
||||
)
|
||||
|
||||
var allImages = []string{
|
||||
@@ -52,6 +53,7 @@ var allImages = []string{
|
||||
ImageShadowTLS,
|
||||
ImageShadowsocksR,
|
||||
ImageXRayCore,
|
||||
ImageShadowsocksLegacy,
|
||||
}
|
||||
|
||||
var localIP = netip.MustParseAddr("127.0.0.1")
|
||||
|
||||
63
test/ss_plugin_test.go
Normal file
63
test/ss_plugin_test.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"testing"
|
||||
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
)
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
MixedOptions: option.HTTPMixedInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.ListenAddress(netip.IPv4Unspecified()),
|
||||
ListenPort: clientPort,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Outbounds: []option.Outbound{
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
ShadowsocksOptions: 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)
|
||||
}
|
||||
Reference in New Issue
Block a user