Fix tests
This commit is contained in:
@@ -10,7 +10,9 @@ import (
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing-shadowsocks/shadowaead_2022"
|
||||
"github.com/sagernet/sing/common"
|
||||
F "github.com/sagernet/sing/common/format"
|
||||
"github.com/sagernet/sing/common/json/badoption"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -37,12 +39,12 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
|
||||
method := shadowaead_2022.List[0]
|
||||
ssPassword := mkBase64(t, 16)
|
||||
startInstance(t, option.Options{
|
||||
Inbounds: []option.LegacyInbound{
|
||||
Inbounds: []option.Inbound{
|
||||
{
|
||||
Type: C.TypeMixed,
|
||||
MixedOptions: option.HTTPMixedInboundOptions{
|
||||
Options: &option.HTTPMixedInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: clientPort,
|
||||
},
|
||||
},
|
||||
@@ -50,11 +52,14 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
|
||||
{
|
||||
Type: C.TypeShadowTLS,
|
||||
Tag: "in",
|
||||
ShadowTLSOptions: option.ShadowTLSInboundOptions{
|
||||
Options: &option.ShadowTLSInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: serverPort,
|
||||
Detour: "detour",
|
||||
|
||||
InboundOptions: option.InboundOptions{
|
||||
Detour: "detour",
|
||||
},
|
||||
},
|
||||
Handshake: option.ShadowTLSHandshakeOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
@@ -70,9 +75,9 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
Tag: "detour",
|
||||
ShadowsocksOptions: option.ShadowsocksInboundOptions{
|
||||
Options: &option.ShadowsocksInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: otherPort,
|
||||
},
|
||||
Method: method,
|
||||
@@ -80,10 +85,10 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
|
||||
},
|
||||
},
|
||||
},
|
||||
LegacyOutbounds: []option.LegacyOutbound{
|
||||
Outbounds: []option.Outbound{
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
ShadowsocksOptions: option.ShadowsocksOutboundOptions{
|
||||
Options: &option.ShadowsocksOutboundOptions{
|
||||
Method: method,
|
||||
Password: ssPassword,
|
||||
DialerOptions: option.DialerOptions{
|
||||
@@ -94,7 +99,7 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
|
||||
{
|
||||
Type: C.TypeShadowTLS,
|
||||
Tag: "detour",
|
||||
ShadowTLSOptions: option.ShadowTLSOutboundOptions{
|
||||
Options: &option.ShadowTLSOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: "127.0.0.1",
|
||||
ServerPort: serverPort,
|
||||
@@ -142,12 +147,12 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
|
||||
|
||||
func TestShadowTLSFallback(t *testing.T) {
|
||||
startInstance(t, option.Options{
|
||||
Inbounds: []option.LegacyInbound{
|
||||
Inbounds: []option.Inbound{
|
||||
{
|
||||
Type: C.TypeShadowTLS,
|
||||
ShadowTLSOptions: option.ShadowTLSInboundOptions{
|
||||
Options: &option.ShadowTLSInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: serverPort,
|
||||
},
|
||||
Handshake: option.ShadowTLSHandshakeOptions{
|
||||
@@ -189,24 +194,26 @@ func TestShadowTLSInbound(t *testing.T) {
|
||||
Cmd: []string{"--v3", "--threads", "1", "client", "--listen", "0.0.0.0:" + F.ToString(otherPort), "--server", "127.0.0.1:" + F.ToString(serverPort), "--sni", "google.com", "--password", password},
|
||||
})
|
||||
startInstance(t, option.Options{
|
||||
Inbounds: []option.LegacyInbound{
|
||||
Inbounds: []option.Inbound{
|
||||
{
|
||||
Type: C.TypeMixed,
|
||||
Tag: "in",
|
||||
MixedOptions: option.HTTPMixedInboundOptions{
|
||||
Options: &option.HTTPMixedInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: clientPort,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.TypeShadowTLS,
|
||||
ShadowTLSOptions: option.ShadowTLSInboundOptions{
|
||||
Options: &option.ShadowTLSInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: serverPort,
|
||||
Detour: "detour",
|
||||
InboundOptions: option.InboundOptions{
|
||||
Detour: "detour",
|
||||
},
|
||||
},
|
||||
Handshake: option.ShadowTLSHandshakeOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
@@ -223,23 +230,23 @@ func TestShadowTLSInbound(t *testing.T) {
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
Tag: "detour",
|
||||
ShadowsocksOptions: option.ShadowsocksInboundOptions{
|
||||
Options: &option.ShadowsocksInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
},
|
||||
},
|
||||
},
|
||||
LegacyOutbounds: []option.LegacyOutbound{
|
||||
Outbounds: []option.Outbound{
|
||||
{
|
||||
Type: C.TypeDirect,
|
||||
},
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
Tag: "out",
|
||||
ShadowsocksOptions: option.ShadowsocksOutboundOptions{
|
||||
Options: &option.ShadowsocksOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: "127.0.0.1",
|
||||
ServerPort: otherPort,
|
||||
@@ -283,12 +290,12 @@ func TestShadowTLSOutbound(t *testing.T) {
|
||||
Env: []string{"RUST_LOG=trace"},
|
||||
})
|
||||
startInstance(t, option.Options{
|
||||
Inbounds: []option.LegacyInbound{
|
||||
Inbounds: []option.Inbound{
|
||||
{
|
||||
Type: C.TypeMixed,
|
||||
MixedOptions: option.HTTPMixedInboundOptions{
|
||||
Options: &option.HTTPMixedInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: clientPort,
|
||||
},
|
||||
},
|
||||
@@ -296,9 +303,9 @@ func TestShadowTLSOutbound(t *testing.T) {
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
Tag: "detour",
|
||||
ShadowsocksOptions: option.ShadowsocksInboundOptions{
|
||||
Options: &option.ShadowsocksInboundOptions{
|
||||
ListenOptions: option.ListenOptions{
|
||||
Listen: option.NewListenAddress(netip.IPv4Unspecified()),
|
||||
Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
|
||||
ListenPort: otherPort,
|
||||
},
|
||||
Method: method,
|
||||
@@ -306,10 +313,10 @@ func TestShadowTLSOutbound(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
LegacyOutbounds: []option.LegacyOutbound{
|
||||
Outbounds: []option.Outbound{
|
||||
{
|
||||
Type: C.TypeShadowsocks,
|
||||
ShadowsocksOptions: option.ShadowsocksOutboundOptions{
|
||||
Options: &option.ShadowsocksOutboundOptions{
|
||||
Method: method,
|
||||
Password: password,
|
||||
DialerOptions: option.DialerOptions{
|
||||
@@ -320,7 +327,7 @@ func TestShadowTLSOutbound(t *testing.T) {
|
||||
{
|
||||
Type: C.TypeShadowTLS,
|
||||
Tag: "detour",
|
||||
ShadowTLSOptions: option.ShadowTLSOutboundOptions{
|
||||
Options: &option.ShadowTLSOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: "127.0.0.1",
|
||||
ServerPort: serverPort,
|
||||
|
||||
Reference in New Issue
Block a user