mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-28 06:55:58 +03:00
Migrate multiplex and UoT server to inbound &
Add tcp-brutal support for multiplex
This commit is contained in:
86
test/brutal_test.go
Normal file
86
test/brutal_test.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"testing"
|
||||
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing-shadowsocks/shadowaead_2022"
|
||||
)
|
||||
|
||||
func TestMuxBrutal(t *testing.T) {
|
||||
method := shadowaead_2022.List[0]
|
||||
password := mkBase64(t, 16)
|
||||
startInstance(t, option.Options{
|
||||
Inbounds: []option.Inbound{
|
||||
{
|
||||
Type: C.TypeMixed,
|
||||
Tag: "mixed-in",
|
||||
MixedOptions: option.HTTPMixedInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
ListenPort: clientPort,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
ShadowsocksOptions: option.ShadowsocksInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
ListenPort: serverPort,
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
Multiplex: &option.InboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
Brutal: &option.BrutalOptions{
|
||||
Enabled: true,
|
||||
UpMbps: 100,
|
||||
DownMbps: 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Outbounds: []option.Outbound{
|
||||
{
|
||||
Type: C.TypeDirect,
|
||||
},
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
Tag: "ss-out",
|
||||
ShadowsocksOptions: option.ShadowsocksOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: "127.0.0.1",
|
||||
ServerPort: serverPort,
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
Multiplex: &option.OutboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
Protocol: "smux",
|
||||
Padding: true,
|
||||
Brutal: &option.BrutalOptions{
|
||||
Enabled: true,
|
||||
UpMbps: 100,
|
||||
DownMbps: 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Route: &option.RouteOptions{
|
||||
Rules: []option.Rule{
|
||||
{
|
||||
DefaultOptions: option.DefaultRule{
|
||||
Inbound: []string{"mixed-in"},
|
||||
Outbound: "ss-out",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
testSuit(t, clientPort, testPort)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ require (
|
||||
github.com/sagernet/gvisor v0.0.0-20230930141345-5fef6f2e17ab // indirect
|
||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 // indirect
|
||||
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
|
||||
github.com/sagernet/sing-mux v0.1.3 // indirect
|
||||
github.com/sagernet/sing-mux v0.1.4-0.20231106145412-8912fc890007 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
||||
github.com/sagernet/sing-tun v0.1.19-0.20231106133355-e77e52da4df5 // indirect
|
||||
github.com/sagernet/sing-vmess v0.1.8 // indirect
|
||||
|
||||
@@ -135,8 +135,8 @@ github.com/sagernet/sing v0.2.18-0.20231105080609-f4910823a651 h1:Mf2AaTaFY8Iig5
|
||||
github.com/sagernet/sing v0.2.18-0.20231105080609-f4910823a651/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
|
||||
github.com/sagernet/sing-dns v0.1.10 h1:iIU7nRBlUYj+fF2TaktGIvRiTFFrHwSMedLQsvlTZCI=
|
||||
github.com/sagernet/sing-dns v0.1.10/go.mod h1:vtUimtf7Nq9EdvD5WTpfCr69KL1M7bcgOVKiYBiAY/c=
|
||||
github.com/sagernet/sing-mux v0.1.3 h1:fAf7PZa2A55mCeh0KKM02f1k2Y4vEmxuZZ/51ahkkLA=
|
||||
github.com/sagernet/sing-mux v0.1.3/go.mod h1:wGeIeiiFLx4HUM5LAg65wrNZ/X1muOimqK0PEhNbPi0=
|
||||
github.com/sagernet/sing-mux v0.1.4-0.20231106145412-8912fc890007 h1:Y5Nk/BenBi0iHwvcbRNYZYLmOBBlvqcyx2y1lFkraA0=
|
||||
github.com/sagernet/sing-mux v0.1.4-0.20231106145412-8912fc890007/go.mod h1:wGeIeiiFLx4HUM5LAg65wrNZ/X1muOimqK0PEhNbPi0=
|
||||
github.com/sagernet/sing-quic v0.1.3 h1:YfSPGQdlE6YspjPSlQJaVH333leFiYQM8JX7TumsWQs=
|
||||
github.com/sagernet/sing-quic v0.1.3/go.mod h1:wvGU7MYih+cpJV2VrrpSGyjZIFSmUyqzawzmDyqeWJA=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY=
|
||||
|
||||
@@ -18,7 +18,7 @@ var muxProtocols = []string{
|
||||
}
|
||||
|
||||
func TestVMessSMux(t *testing.T) {
|
||||
testVMessMux(t, option.MultiplexOptions{
|
||||
testVMessMux(t, option.OutboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
Protocol: "smux",
|
||||
})
|
||||
@@ -27,7 +27,7 @@ func TestVMessSMux(t *testing.T) {
|
||||
func TestShadowsocksMux(t *testing.T) {
|
||||
for _, protocol := range muxProtocols {
|
||||
t.Run(protocol, func(t *testing.T) {
|
||||
testShadowsocksMux(t, option.MultiplexOptions{
|
||||
testShadowsocksMux(t, option.OutboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
Protocol: protocol,
|
||||
})
|
||||
@@ -36,7 +36,7 @@ func TestShadowsocksMux(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShadowsockH2Mux(t *testing.T) {
|
||||
testShadowsocksMux(t, option.MultiplexOptions{
|
||||
testShadowsocksMux(t, option.OutboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
Protocol: "h2mux",
|
||||
Padding: true,
|
||||
@@ -44,14 +44,14 @@ func TestShadowsockH2Mux(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShadowsockSMuxPadding(t *testing.T) {
|
||||
testShadowsocksMux(t, option.MultiplexOptions{
|
||||
testShadowsocksMux(t, option.OutboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
Protocol: "smux",
|
||||
Padding: true,
|
||||
})
|
||||
}
|
||||
|
||||
func testShadowsocksMux(t *testing.T, options option.MultiplexOptions) {
|
||||
func testShadowsocksMux(t *testing.T, options option.OutboundMultiplexOptions) {
|
||||
method := shadowaead_2022.List[0]
|
||||
password := mkBase64(t, 16)
|
||||
startInstance(t, option.Options{
|
||||
@@ -90,9 +90,9 @@ func testShadowsocksMux(t *testing.T, options option.MultiplexOptions) {
|
||||
Server: "127.0.0.1",
|
||||
ServerPort: serverPort,
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
MultiplexOptions: &options,
|
||||
Method: method,
|
||||
Password: password,
|
||||
Multiplex: &options,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -110,7 +110,7 @@ func testShadowsocksMux(t *testing.T, options option.MultiplexOptions) {
|
||||
testSuit(t, clientPort, testPort)
|
||||
}
|
||||
|
||||
func testVMessMux(t *testing.T, options option.MultiplexOptions) {
|
||||
func testVMessMux(t *testing.T, options option.OutboundMultiplexOptions) {
|
||||
user, _ := uuid.NewV4()
|
||||
startInstance(t, option.Options{
|
||||
Inbounds: []option.Inbound{
|
||||
@@ -136,6 +136,9 @@ func testVMessMux(t *testing.T, options option.MultiplexOptions) {
|
||||
UUID: user.String(),
|
||||
},
|
||||
},
|
||||
Multiplex: &option.InboundMultiplexOptions{
|
||||
Enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -232,7 +232,7 @@ func TestShadowsocksUoT(t *testing.T) {
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
UDPOverTCPOptions: &option.UDPOverTCPOptions{
|
||||
UDPOverTCP: &option.UDPOverTCPOptions{
|
||||
Enabled: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user