mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-30 04:21:29 +00:00
84 lines
1.9 KiB
Go
84 lines
1.9 KiB
Go
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"
|
|
"github.com/sagernet/sing/common"
|
|
"github.com/sagernet/sing/common/json/badoption"
|
|
)
|
|
|
|
func TestTCPSlowOpen(t *testing.T) {
|
|
method := shadowaead.List[0]
|
|
password := mkBase64(t, 16)
|
|
startInstance(t, option.Options{
|
|
LegacyInbounds: []option.LegacyInbound{
|
|
{
|
|
Type: C.TypeMixed,
|
|
Tag: "mixed-in",
|
|
MixedOptions: option.HTTPMixedInboundOptions{
|
|
ListenOptions: option.ListenOptions{
|
|
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
|
ListenPort: clientPort,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Type: C.TypeShadowsocks,
|
|
ShadowsocksOptions: option.ShadowsocksInboundOptions{
|
|
ListenOptions: option.ListenOptions{
|
|
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
|
ListenPort: serverPort,
|
|
TCPFastOpen: true,
|
|
},
|
|
Method: method,
|
|
Password: password,
|
|
},
|
|
},
|
|
},
|
|
LegacyOutbounds: []option.LegacyOutbound{
|
|
{
|
|
Type: C.TypeDirect,
|
|
},
|
|
{
|
|
Type: C.TypeShadowsocks,
|
|
Tag: "ss-out",
|
|
ShadowsocksOptions: option.ShadowsocksOutboundOptions{
|
|
ServerOptions: option.ServerOptions{
|
|
Server: "127.0.0.1",
|
|
ServerPort: serverPort,
|
|
},
|
|
DialerOptions: option.DialerOptions{
|
|
TCPFastOpen: true,
|
|
},
|
|
Method: method,
|
|
Password: password,
|
|
},
|
|
},
|
|
},
|
|
Route: &option.RouteOptions{
|
|
Rules: []option.Rule{
|
|
{
|
|
Type: C.RuleTypeDefault,
|
|
DefaultOptions: option.DefaultRule{
|
|
RawDefaultRule: option.RawDefaultRule{
|
|
Inbound: []string{"mixed-in"},
|
|
},
|
|
RuleAction: option.RuleAction{
|
|
Action: C.RuleActionTypeRoute,
|
|
|
|
RouteOptions: option.RouteActionOptions{
|
|
Outbound: "ss-out",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
testSuit(t, clientPort, testPort)
|
|
}
|