Fix tests

This commit is contained in:
世界 2024-11-18 18:59:19 +08:00
parent 4df18ecec7
commit 6749e631b4
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
29 changed files with 453 additions and 391 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/sagernet/quic-go/http3" "github.com/sagernet/quic-go/http3"
"github.com/sagernet/sing-box" "github.com/sagernet/sing-box"
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/include"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common/bufio" "github.com/sagernet/sing/common/bufio"
"github.com/sagernet/sing/common/debug" "github.com/sagernet/sing/common/debug"
@ -28,6 +29,12 @@ func TestMain(m *testing.M) {
goleak.VerifyTestMain(m) goleak.VerifyTestMain(m)
} }
var globalCtx context.Context
func init() {
globalCtx = box.Context(context.Background(), include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry())
}
func startInstance(t *testing.T, options option.Options) *box.Box { func startInstance(t *testing.T, options option.Options) *box.Box {
if debug.Enabled { if debug.Enabled {
options.Log = &option.LogOptions{ options.Log = &option.LogOptions{
@ -38,8 +45,7 @@ func startInstance(t *testing.T, options option.Options) *box.Box {
Level: "warning", Level: "warning",
} }
} }
// ctx := context.Background() ctx, cancel := context.WithCancel(globalCtx)
ctx, cancel := context.WithCancel(context.Background())
var instance *box.Box var instance *box.Box
var err error var err error
for retry := 0; retry < 3; retry++ { for retry := 0; retry < 3; retry++ {

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks/shadowaead_2022" "github.com/sagernet/sing-shadowsocks/shadowaead_2022"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
) )
@ -15,22 +17,22 @@ func TestBrutalShadowsocks(t *testing.T) {
method := shadowaead_2022.List[0] method := shadowaead_2022.List[0]
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Method: method, Method: method,
@ -46,14 +48,14 @@ func TestBrutalShadowsocks(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -100,22 +102,22 @@ func TestBrutalTrojan(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanInboundOptions{ Options: &option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TrojanUser{{Password: password}}, Users: []option.TrojanUser{{Password: password}},
@ -138,14 +140,14 @@ func TestBrutalTrojan(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
Tag: "ss-out", Tag: "ss-out",
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -197,22 +199,22 @@ func TestBrutalTrojan(t *testing.T) {
func TestBrutalVMess(t *testing.T) { func TestBrutalVMess(t *testing.T) {
user, _ := uuid.NewV4() user, _ := uuid.NewV4()
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{{UUID: user.String()}}, Users: []option.VMessUser{{UUID: user.String()}},
@ -227,14 +229,14 @@ func TestBrutalVMess(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "ss-out", Tag: "ss-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -279,22 +281,22 @@ func TestBrutalVMess(t *testing.T) {
func TestBrutalVLESS(t *testing.T) { func TestBrutalVLESS(t *testing.T) {
user, _ := uuid.NewV4() user, _ := uuid.NewV4()
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVLESS, Type: C.TypeVLESS,
VLESSOptions: option.VLESSInboundOptions{ Options: &option.VLESSInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VLESSUser{{UUID: user.String()}}, Users: []option.VLESSUser{{UUID: user.String()}},
@ -326,14 +328,14 @@ func TestBrutalVLESS(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVLESS, Type: C.TypeVLESS,
Tag: "ss-out", Tag: "ss-out",
VLESSOptions: option.VLESSOutboundOptions{ Options: &option.VLESSOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,41 +6,43 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
// Since this is a feature one-off added by outsiders, I won't address these anymore. // Since this is a feature one-off added by outsiders, I won't address these anymore.
func _TestProxyProtocol(t *testing.T) { func _TestProxyProtocol(t *testing.T) {
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
DirectOptions: option.DirectInboundOptions{ Options: &option.DirectInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
ProxyProtocol: true, ProxyProtocol: true,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
Tag: "proxy-out", Tag: "proxy-out",
DirectOptions: option.DirectOutboundOptions{ Options: &option.DirectOutboundOptions{
OverrideAddress: "127.0.0.1", OverrideAddress: "127.0.0.1",
OverridePort: serverPort, OverridePort: serverPort,
ProxyProtocol: 2, ProxyProtocol: 2,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-dns" "github.com/sagernet/sing-dns"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
) )
@ -14,22 +16,22 @@ import (
func TestTUICDomainUDP(t *testing.T) { func TestTUICDomainUDP(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
TUICOptions: option.TUICInboundOptions{ Options: &option.TUICInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
InboundOptions: option.InboundOptions{ InboundOptions: option.InboundOptions{
DomainStrategy: option.DomainStrategy(dns.DomainStrategyUseIPv6), DomainStrategy: option.DomainStrategy(dns.DomainStrategyUseIPv6),
@ -49,14 +51,14 @@ func TestTUICDomainUDP(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
Tag: "tuic-out", Tag: "tuic-out",
TUICOptions: option.TUICOutboundOptions{ Options: &option.TUICOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -8,6 +8,7 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common" "github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
) )
@ -16,22 +17,22 @@ func TestECH(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
echConfig, echKey := common.Must2(tls.ECHKeygenDefault("not.example.org", false)) echConfig, echKey := common.Must2(tls.ECHKeygenDefault("not.example.org", false))
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanInboundOptions{ Options: &option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TrojanUser{ Users: []option.TrojanUser{
@ -55,14 +56,14 @@ func TestECH(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
Tag: "trojan-out", Tag: "trojan-out",
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -109,22 +110,22 @@ func TestECHQUIC(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
echConfig, echKey := common.Must2(tls.ECHKeygenDefault("not.example.org", false)) echConfig, echKey := common.Must2(tls.ECHKeygenDefault("not.example.org", false))
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
TUICOptions: option.TUICInboundOptions{ Options: &option.TUICInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TUICUser{{ Users: []option.TUICUser{{
@ -145,14 +146,14 @@ func TestECHQUIC(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
Tag: "tuic-out", Tag: "tuic-out",
TUICOptions: option.TUICOutboundOptions{ Options: &option.TUICOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -199,22 +200,22 @@ func TestECHHysteria2(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
echConfig, echKey := common.Must2(tls.ECHKeygenDefault("not.example.org", false)) echConfig, echKey := common.Must2(tls.ECHKeygenDefault("not.example.org", false))
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeHysteria2, Type: C.TypeHysteria2,
Hysteria2Options: option.Hysteria2InboundOptions{ Options: &option.Hysteria2InboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.Hysteria2User{{ Users: []option.Hysteria2User{{
@ -235,14 +236,14 @@ func TestECHHysteria2(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeHysteria2, Type: C.TypeHysteria2,
Tag: "hy2-out", Tag: "hy2-out",
Hysteria2Options: option.Hysteria2OutboundOptions{ Options: &option.Hysteria2OutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -13,7 +13,7 @@ require (
github.com/docker/go-connections v0.5.0 github.com/docker/go-connections v0.5.0
github.com/gofrs/uuid/v5 v5.3.0 github.com/gofrs/uuid/v5 v5.3.0
github.com/sagernet/quic-go v0.48.2-beta.1 github.com/sagernet/quic-go v0.48.2-beta.1
github.com/sagernet/sing v0.6.0-beta.2 github.com/sagernet/sing v0.6.0-beta.3
github.com/sagernet/sing-dns v0.4.0-beta.1 github.com/sagernet/sing-dns v0.4.0-beta.1
github.com/sagernet/sing-quic v0.4.0-alpha.4 github.com/sagernet/sing-quic v0.4.0-alpha.4
github.com/sagernet/sing-shadowsocks v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.7
@ -25,8 +25,8 @@ require (
) )
require ( require (
berty.tech/go-libtor v1.0.385 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect github.com/andybalholm/brotli v1.0.6 // indirect
github.com/caddyserver/certmagic v0.20.0 // indirect github.com/caddyserver/certmagic v0.20.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect github.com/cloudflare/circl v1.3.7 // indirect
@ -38,6 +38,7 @@ require (
github.com/felixge/httpsnoop v1.0.4 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-chi/chi/v5 v5.1.0 // indirect github.com/go-chi/chi/v5 v5.1.0 // indirect
github.com/go-chi/render v1.0.3 // indirect
github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect
@ -49,6 +50,7 @@ require (
github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a // indirect github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a // indirect
github.com/hashicorp/yamux v0.1.2 // indirect github.com/hashicorp/yamux v0.1.2 // indirect
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2 // indirect
github.com/josharian/native v1.1.0 // indirect github.com/josharian/native v1.1.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect
@ -65,16 +67,17 @@ require (
github.com/moby/term v0.5.0 // indirect github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.9.7 // indirect github.com/onsi/ginkgo/v2 v2.9.7 // indirect
github.com/ooni/go-libtor v1.1.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/oschwald/maxminddb-golang v1.12.0 // indirect github.com/oschwald/maxminddb-golang v1.12.0 // indirect
github.com/pierrec/lz4/v4 v4.1.14 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 // indirect github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 // indirect
github.com/sagernet/cors v1.2.1 // indirect
github.com/sagernet/fswatch v0.1.1 // indirect github.com/sagernet/fswatch v0.1.1 // indirect
github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff // indirect github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff // indirect
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
@ -83,11 +86,12 @@ require (
github.com/sagernet/sing-mux v0.3.0-alpha.1 // indirect github.com/sagernet/sing-mux v0.3.0-alpha.1 // indirect
github.com/sagernet/sing-shadowtls v0.2.0-alpha.2 // indirect github.com/sagernet/sing-shadowtls v0.2.0-alpha.2 // indirect
github.com/sagernet/sing-tun v0.6.0-beta.2 // indirect github.com/sagernet/sing-tun v0.6.0-beta.2 // indirect
github.com/sagernet/sing-vmess v0.1.12 // indirect github.com/sagernet/sing-vmess v0.2.0-beta.1 // indirect
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
github.com/sagernet/utls v1.6.7 // indirect github.com/sagernet/utls v1.6.7 // indirect
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8 // indirect github.com/sagernet/wireguard-go v0.0.1-beta.4 // indirect
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect
github.com/vishvananda/netns v0.0.4 // indirect github.com/vishvananda/netns v0.0.4 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect github.com/zeebo/blake3 v0.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
@ -107,6 +111,7 @@ require (
golang.org/x/text v0.20.0 // indirect golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.7.0 // indirect golang.org/x/time v0.7.0 // indirect
golang.org/x/tools v0.24.0 // indirect golang.org/x/tools v0.24.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/grpc v1.67.1 // indirect google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect google.golang.org/protobuf v1.35.1 // indirect

View file

@ -1,9 +1,9 @@
berty.tech/go-libtor v1.0.385 h1:RWK94C3hZj6Z2GdvePpHJLnWYobFr3bY/OdUJ5aoEXw=
berty.tech/go-libtor v1.0.385/go.mod h1:9swOOQVb+kmvuAlsgWUK/4c52pm69AdbJsxLzk+fJEw=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/caddyserver/certmagic v0.20.0 h1:bTw7LcEZAh9ucYCRXyCpIrSAGplplI0vGYJ4BpCQ/Fc= github.com/caddyserver/certmagic v0.20.0 h1:bTw7LcEZAh9ucYCRXyCpIrSAGplplI0vGYJ4BpCQ/Fc=
@ -14,7 +14,6 @@ github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vc
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/cretz/bine v0.1.0/go.mod h1:6PF6fWAvYtwjRGkAuDEJeWNOv3a2hUouSP/yRYXmvHw=
github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo= github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo=
github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI= github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -34,6 +33,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@ -65,6 +66,9 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjw
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2 h1:9K06NfxkBh25x56yVhWWlKFE8YpicaSfHwoV8SFbueA=
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2/go.mod h1:3A9PQ1cunSDF/1rbTq99Ts4pVnycWg+vlPkfeD2NLFI=
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA= github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
@ -107,14 +111,14 @@ github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss=
github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0= github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4=
github.com/ooni/go-libtor v1.1.8 h1:Wo3V3DVTxl5vZdxtQakqYP+DAHx7pPtAFSl1bnAa08w=
github.com/ooni/go-libtor v1.1.8/go.mod h1:q1YyLwRD9GeMyeerVvwc0vJ2YgwDLTp2bdVcrh/JXyI=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs= github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY= github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE=
github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -127,51 +131,45 @@ github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a h1:+NkI2670SQpQWvkk
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a/go.mod h1:63s7jpZqcDAIpj8oI/1v4Izok+npJOHACFCU6+huCkM= github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a/go.mod h1:63s7jpZqcDAIpj8oI/1v4Izok+npJOHACFCU6+huCkM=
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 h1:YbmpqPQEMdlk9oFSKYWRqVuu9qzNiOayIonKmv1gCXY= github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 h1:YbmpqPQEMdlk9oFSKYWRqVuu9qzNiOayIonKmv1gCXY=
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1/go.mod h1:J2yAxTFPDjrDPhuAi9aWFz2L3ox9it4qAluBBbN0H5k= github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1/go.mod h1:J2yAxTFPDjrDPhuAi9aWFz2L3ox9it4qAluBBbN0H5k=
github.com/sagernet/cors v1.2.1 h1:Cv5Z8y9YSD6Gm+qSpNrL3LO4lD3eQVvbFYJSG7JCMHQ=
github.com/sagernet/cors v1.2.1/go.mod h1:O64VyOjjhrkLmQIjF4KGRrJO/5dVXFdpEmCW/eISRAI=
github.com/sagernet/fswatch v0.1.1 h1:YqID+93B7VRfqIH3PArW/XpJv5H4OLEVWDfProGoRQs= github.com/sagernet/fswatch v0.1.1 h1:YqID+93B7VRfqIH3PArW/XpJv5H4OLEVWDfProGoRQs=
github.com/sagernet/fswatch v0.1.1/go.mod h1:nz85laH0mkQqJfaOrqPpkwtU1znMFNVTpT/5oRsVz/o= github.com/sagernet/fswatch v0.1.1/go.mod h1:nz85laH0mkQqJfaOrqPpkwtU1znMFNVTpT/5oRsVz/o=
github.com/sagernet/gvisor v0.0.0-20241021032506-a4324256e4a3 h1:RxEz7LhPNiF/gX/Hg+OXr5lqsM9iVAgmaK1L1vzlDRM= github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff h1:mlohw3360Wg1BNGook/UHnISXhUx4Gd/3tVLs5T0nSs=
github.com/sagernet/gvisor v0.0.0-20241021032506-a4324256e4a3/go.mod h1:ehZwnT2UpmOWAHFL48XdBhnd4Qu4hN2O3Ji0us3ZHMw=
github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff/go.mod h1:ehZwnT2UpmOWAHFL48XdBhnd4Qu4hN2O3Ji0us3ZHMw= github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff/go.mod h1:ehZwnT2UpmOWAHFL48XdBhnd4Qu4hN2O3Ji0us3ZHMw=
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZNjr6sGeT00J8uU7JF4cNUdb44/Duis= github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZNjr6sGeT00J8uU7JF4cNUdb44/Duis=
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM= github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I= github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8= github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
github.com/sagernet/quic-go v0.48.0-beta.1 h1:86hQZrmuoARI3BpDRkQaP0iAVpywA4YsRrzJPYuPKWg= github.com/sagernet/quic-go v0.48.2-beta.1 h1:W0plrLWa1XtOWDTdX3CJwxmQuxkya12nN5BRGZ87kEg=
github.com/sagernet/quic-go v0.48.0-beta.1/go.mod h1:1WgdDIVD1Gybp40JTWketeSfKA/+or9YMLaG5VeTk4k=
github.com/sagernet/quic-go v0.48.2-beta.1/go.mod h1:1WgdDIVD1Gybp40JTWketeSfKA/+or9YMLaG5VeTk4k= github.com/sagernet/quic-go v0.48.2-beta.1/go.mod h1:1WgdDIVD1Gybp40JTWketeSfKA/+or9YMLaG5VeTk4k=
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc= github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc=
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU= github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
github.com/sagernet/sing v0.5.0-rc.4.0.20241022031908-cd17884118cb h1:3IhGq2UmcbQfAcuqyE8RYKFapqEEa3eItS/MrZr+5l8= github.com/sagernet/sing v0.6.0-beta.3 h1:T8MKw7dEjG4a24m/sHDIQLMjc45rZvYHSYO9/Mwk6nI=
github.com/sagernet/sing v0.5.0-rc.4.0.20241022031908-cd17884118cb/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing v0.6.0-beta.3/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing v0.6.0-beta.2/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing-dns v0.4.0-beta.1 h1:W1XkdhigwxDOMgMDVB+9kdomCpb7ExsZfB4acPcTZFY=
github.com/sagernet/sing-dns v0.3.0-rc.2.0.20241021154031-a59e0fbba3ce h1:OfpxE5qnXMyU/9LtNgX4M7bGP11lJx4s+KZ3Sijb0HE=
github.com/sagernet/sing-dns v0.3.0-rc.2.0.20241021154031-a59e0fbba3ce/go.mod h1:TqLIelI+FAbVEdiTRolhGLOwvhVjY7oT+wezlOJUQ7M=
github.com/sagernet/sing-dns v0.4.0-beta.1/go.mod h1:8wuFcoFkWM4vJuQyg8e97LyvDwe0/Vl7G839WLcKDs8= github.com/sagernet/sing-dns v0.4.0-beta.1/go.mod h1:8wuFcoFkWM4vJuQyg8e97LyvDwe0/Vl7G839WLcKDs8=
github.com/sagernet/sing-mux v0.2.1-0.20241020175909-fe6153f7a9ec h1:6Fd/VsEsw9qIjaGi1IBTZSb4b4v5JYtNcoiBtGsQC48= github.com/sagernet/sing-mux v0.3.0-alpha.1 h1:IgNX5bJBpL41gGbp05pdDOvh/b5eUQ6cv9240+Ngipg=
github.com/sagernet/sing-mux v0.2.1-0.20241020175909-fe6153f7a9ec/go.mod h1:RSwqqHwbtTOX3vs6ms8vMtBGH/0ZNyLm/uwt6TlmR84=
github.com/sagernet/sing-mux v0.3.0-alpha.1/go.mod h1:FTcImmdfW38Lz7b+HQ+mxxOth1lz4ao8uEnz+MwIJQE= github.com/sagernet/sing-mux v0.3.0-alpha.1/go.mod h1:FTcImmdfW38Lz7b+HQ+mxxOth1lz4ao8uEnz+MwIJQE=
github.com/sagernet/sing-quic v0.3.0-rc.1 h1:SlzL1yfEAKJyRduub8vzOVtbyTLAX7RZEEBZxO5utts= github.com/sagernet/sing-quic v0.4.0-alpha.4 h1:P9xAx3nIfcqb9M8jfgs0uLm+VxCcaY++FCqaBfHY3dQ=
github.com/sagernet/sing-quic v0.3.0-rc.1/go.mod h1:uX+aUHA0fgIN6U3WViseDpSdTQriViZ7qz0Wbsf1mNQ=
github.com/sagernet/sing-quic v0.4.0-alpha.4/go.mod h1:h5RkKTmUhudJKzK7c87FPXD5w1bJjVyxMN9+opZcctA= github.com/sagernet/sing-quic v0.4.0-alpha.4/go.mod h1:h5RkKTmUhudJKzK7c87FPXD5w1bJjVyxMN9+opZcctA=
github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8= github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8=
github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE= github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE=
github.com/sagernet/sing-shadowsocks2 v0.2.0 h1:wpZNs6wKnR7mh1wV9OHwOyUr21VkS3wKFHi+8XwgADg= github.com/sagernet/sing-shadowsocks2 v0.2.0 h1:wpZNs6wKnR7mh1wV9OHwOyUr21VkS3wKFHi+8XwgADg=
github.com/sagernet/sing-shadowsocks2 v0.2.0/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ= github.com/sagernet/sing-shadowsocks2 v0.2.0/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnVpEx6Tw3k= github.com/sagernet/sing-shadowtls v0.2.0-alpha.2 h1:RPrpgAdkP5td0vLfS5ldvYosFjSsZtRPxiyLV6jyKg0=
github.com/sagernet/sing-shadowtls v0.1.4/go.mod h1:F8NBgsY5YN2beQavdgdm1DPlhaKQlaL6lpDdcBglGK4=
github.com/sagernet/sing-shadowtls v0.2.0-alpha.2/go.mod h1:0j5XlzKxaWRIEjc1uiSKmVoWb0k+L9QgZVb876+thZA= github.com/sagernet/sing-shadowtls v0.2.0-alpha.2/go.mod h1:0j5XlzKxaWRIEjc1uiSKmVoWb0k+L9QgZVb876+thZA=
github.com/sagernet/sing-tun v0.4.0-rc.4.0.20241021153919-9ae45181180d h1:zWcIQM3eAKJGzy7zhqkO7zm7ZI890OdR4vSwx2mevS0= github.com/sagernet/sing-tun v0.6.0-beta.2 h1:GK7r2jWKm7RhlJGTq4QadgFcebQia1c3BO3OlYMcQJ0=
github.com/sagernet/sing-tun v0.4.0-rc.4.0.20241021153919-9ae45181180d/go.mod h1:Xhv+Mz2nE7HZTwResni8EtTa7AMJz/S6uQLT5lV23M8=
github.com/sagernet/sing-tun v0.6.0-beta.2/go.mod h1:fisFCbC4Vfb6HqQNcwPJi2CDK2bf0Xapyz3j3t4cnHE= github.com/sagernet/sing-tun v0.6.0-beta.2/go.mod h1:fisFCbC4Vfb6HqQNcwPJi2CDK2bf0Xapyz3j3t4cnHE=
github.com/sagernet/sing-vmess v0.1.12 h1:2gFD8JJb+eTFMoa8FIVMnknEi+vCSfaiTXTfEYAYAPg= github.com/sagernet/sing-vmess v0.2.0-beta.1 h1:5sXQ23uwNlZuDvygzi0dFtnG0Csm/SNqTjAHXJkpuj4=
github.com/sagernet/sing-vmess v0.1.12/go.mod h1:luTSsfyBGAc9VhtCqwjR+dt1QgqBhuYBCONB/POhF8I= github.com/sagernet/sing-vmess v0.2.0-beta.1/go.mod h1:fLyE1emIcvQ5DV8reFWnufquZ7MkCSYM5ThodsR9NrQ=
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ= github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo= github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo=
github.com/sagernet/utls v1.6.7 h1:Ep3+aJ8FUGGta+II2IEVNUc3EDhaRCZINWkj/LloIA8= github.com/sagernet/utls v1.6.7 h1:Ep3+aJ8FUGGta+II2IEVNUc3EDhaRCZINWkj/LloIA8=
github.com/sagernet/utls v1.6.7/go.mod h1:Uua1TKO/FFuAhLr9rkaVnnrTmmiItzDjv1BUb2+ERwM= github.com/sagernet/utls v1.6.7/go.mod h1:Uua1TKO/FFuAhLr9rkaVnnrTmmiItzDjv1BUb2+ERwM=
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8 h1:R0OMYAScomNAVpTfbHFpxqJpvwuhxSRi+g6z7gZhABs= github.com/sagernet/wireguard-go v0.0.1-beta.4 h1:8uyM5fxfEXdu4RH05uOK+v25i3lTNdCYMPSAUJ14FnI=
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8/go.mod h1:K4J7/npM+VAMUeUmTa2JaA02JmyheP0GpRBOUvn3ecc= github.com/sagernet/wireguard-go v0.0.1-beta.4/go.mod h1:jGXij2Gn2wbrWuYNUmmNhf1dwcZtvyAvQoe8Xd8MbUo=
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 h1:6uUiZcDRnZSAegryaUGwPC/Fj13JSHwiTftrXhMmYOc= github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 h1:6uUiZcDRnZSAegryaUGwPC/Fj13JSHwiTftrXhMmYOc=
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854/go.mod h1:LtfoSK3+NG57tvnVEHgcuBW9ujgE8enPSgzgwStwCAA= github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854/go.mod h1:LtfoSK3+NG57tvnVEHgcuBW9ujgE8enPSgzgwStwCAA=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
@ -179,11 +177,12 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
github.com/spyzhov/ajson v0.9.4 h1:MVibcTCgO7DY4IlskdqIlCmDOsUOZ9P7oKj8ifdcf84= github.com/spyzhov/ajson v0.9.4 h1:MVibcTCgO7DY4IlskdqIlCmDOsUOZ9P7oKj8ifdcf84=
github.com/spyzhov/ajson v0.9.4/go.mod h1:a6oSw0MMb7Z5aD2tPoPO+jq11ETKgXUr2XktHdT8Wt8= github.com/spyzhov/ajson v0.9.4/go.mod h1:a6oSw0MMb7Z5aD2tPoPO+jq11ETKgXUr2XktHdT8Wt8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 h1:tHNk7XK9GkmKUR6Gh8gVBKXc2MVSZ4G/NnWLtzw4gNA=
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923/go.mod h1:eLL9Nub3yfAho7qB0MzZizFhTU2QkLeoVsWdHtDW264=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@ -219,12 +218,10 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
@ -238,36 +235,32 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
@ -281,6 +274,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg= google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M= google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc= google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc=

View file

@ -6,39 +6,41 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestHTTPSelf(t *testing.T) { func TestHTTPSelf(t *testing.T) {
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeHTTP, Type: C.TypeHTTP,
Tag: "http-out", Tag: "http-out",
HTTPOptions: option.HTTPOutboundOptions{ Options: &option.HTTPOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-quic/hysteria2" "github.com/sagernet/sing-quic/hysteria2"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestHysteria2Self(t *testing.T) { func TestHysteria2Self(t *testing.T) {
@ -28,22 +30,22 @@ func testHysteria2Self(t *testing.T, salamanderPassword string) {
} }
} }
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeHysteria2, Type: C.TypeHysteria2,
Hysteria2Options: option.Hysteria2InboundOptions{ Options: &option.Hysteria2InboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
UpMbps: 100, UpMbps: 100,
@ -63,14 +65,14 @@ func testHysteria2Self(t *testing.T, salamanderPassword string) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeHysteria2, Type: C.TypeHysteria2,
Tag: "hy2-out", Tag: "hy2-out",
Hysteria2Options: option.Hysteria2OutboundOptions{ Options: &option.Hysteria2OutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -115,12 +117,12 @@ func testHysteria2Self(t *testing.T, salamanderPassword string) {
func TestHysteria2Inbound(t *testing.T) { func TestHysteria2Inbound(t *testing.T) {
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeHysteria2, Type: C.TypeHysteria2,
Hysteria2Options: option.Hysteria2InboundOptions{ Options: &option.Hysteria2InboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Obfs: &option.Hysteria2Obfs{ Obfs: &option.Hysteria2Obfs{
@ -167,21 +169,21 @@ func TestHysteria2Outbound(t *testing.T) {
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeHysteria2, Type: C.TypeHysteria2,
Hysteria2Options: option.Hysteria2OutboundOptions{ Options: &option.Hysteria2OutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,27 +6,29 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestHysteriaSelf(t *testing.T) { func TestHysteriaSelf(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeHysteria, Type: C.TypeHysteria,
HysteriaOptions: option.HysteriaInboundOptions{ Options: &option.HysteriaInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
UpMbps: 100, UpMbps: 100,
@ -46,14 +48,14 @@ func TestHysteriaSelf(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeHysteria, Type: C.TypeHysteria,
Tag: "hy-out", Tag: "hy-out",
HysteriaOptions: option.HysteriaOutboundOptions{ Options: &option.HysteriaOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -98,12 +100,12 @@ func TestHysteriaSelf(t *testing.T) {
func TestHysteriaInbound(t *testing.T) { func TestHysteriaInbound(t *testing.T) {
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeHysteria, Type: C.TypeHysteria,
HysteriaOptions: option.HysteriaInboundOptions{ Options: &option.HysteriaInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
UpMbps: 100, UpMbps: 100,
@ -149,21 +151,21 @@ func TestHysteriaOutbound(t *testing.T) {
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeHysteria, Type: C.TypeHysteria,
HysteriaOptions: option.HysteriaOutboundOptions{ Options: &option.HysteriaOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,31 +7,35 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks/shadowaead_2022" "github.com/sagernet/sing-shadowsocks/shadowaead_2022"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestChainedInbound(t *testing.T) { func TestChainedInbound(t *testing.T) {
method := shadowaead_2022.List[0] method := shadowaead_2022.List[0]
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
InboundOptions: option.InboundOptions{
Detour: "detour", Detour: "detour",
}, },
},
Method: method, Method: method,
Password: password, Password: password,
}, },
@ -39,9 +43,9 @@ func TestChainedInbound(t *testing.T) {
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "detour", Tag: "detour",
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: otherPort, ListenPort: otherPort,
}, },
Method: method, Method: method,
@ -49,14 +53,14 @@ func TestChainedInbound(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
Method: method, Method: method,
Password: password, Password: password,
DialerOptions: option.DialerOptions{ DialerOptions: option.DialerOptions{
@ -67,7 +71,7 @@ func TestChainedInbound(t *testing.T) {
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "detour-out", Tag: "detour-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/spyzhov/ajson" "github.com/spyzhov/ajson"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -37,12 +39,12 @@ func TestMuxCoolServer(t *testing.T) {
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -81,21 +83,21 @@ func TestMuxCoolClient(t *testing.T) {
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -112,22 +114,22 @@ func TestMuxCoolClient(t *testing.T) {
func TestMuxCoolSelf(t *testing.T) { func TestMuxCoolSelf(t *testing.T) {
user := newUUID() user := newUUID()
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -139,14 +141,14 @@ func TestMuxCoolSelf(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks/shadowaead_2022" "github.com/sagernet/sing-shadowsocks/shadowaead_2022"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
) )
@ -55,22 +57,22 @@ func testShadowsocksMux(t *testing.T, options option.OutboundMultiplexOptions) {
method := shadowaead_2022.List[0] method := shadowaead_2022.List[0]
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Method: method, Method: method,
@ -81,14 +83,14 @@ func testShadowsocksMux(t *testing.T, options option.OutboundMultiplexOptions) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -125,22 +127,22 @@ func testShadowsocksMux(t *testing.T, options option.OutboundMultiplexOptions) {
func testVMessMux(t *testing.T, options option.OutboundMultiplexOptions) { func testVMessMux(t *testing.T, options option.OutboundMultiplexOptions) {
user, _ := uuid.NewV4() user, _ := uuid.NewV4()
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -154,14 +156,14 @@ func testVMessMux(t *testing.T, options option.OutboundMultiplexOptions) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,19 +6,21 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/auth" "github.com/sagernet/sing/common/auth"
"github.com/sagernet/sing/common/json/badoption"
"github.com/sagernet/sing/common/network" "github.com/sagernet/sing/common/network"
) )
func TestNaiveInboundWithNginx(t *testing.T) { func TestNaiveInboundWithNginx(t *testing.T) {
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeNaive, Type: C.TypeNaive,
NaiveOptions: option.NaiveInboundOptions{ Options: &option.NaiveInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: otherPort, ListenPort: otherPort,
}, },
Users: []auth.User{ Users: []auth.User{
@ -59,12 +61,12 @@ func TestNaiveInboundWithNginx(t *testing.T) {
func TestNaiveInbound(t *testing.T) { func TestNaiveInbound(t *testing.T) {
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeNaive, Type: C.TypeNaive,
NaiveOptions: option.NaiveInboundOptions{ Options: &option.NaiveInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []auth.User{ Users: []auth.User{
@ -103,12 +105,12 @@ func TestNaiveInbound(t *testing.T) {
func TestNaiveHTTP3Inbound(t *testing.T) { func TestNaiveHTTP3Inbound(t *testing.T) {
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeNaive, Type: C.TypeNaive,
NaiveOptions: option.NaiveInboundOptions{ Options: &option.NaiveInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []auth.User{ Users: []auth.User{

View file

@ -7,7 +7,9 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks2/shadowstream" "github.com/sagernet/sing-shadowsocks2/shadowstream"
"github.com/sagernet/sing/common"
F "github.com/sagernet/sing/common/format" F "github.com/sagernet/sing/common/format"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestShadowsocksLegacy(t *testing.T) { func TestShadowsocksLegacy(t *testing.T) {
@ -24,21 +26,21 @@ func testShadowsocksLegacy(t *testing.T, method string) {
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -9,7 +9,9 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks/shadowaead_2022" "github.com/sagernet/sing-shadowsocks/shadowaead_2022"
"github.com/sagernet/sing/common"
F "github.com/sagernet/sing/common/format" F "github.com/sagernet/sing/common/format"
"github.com/sagernet/sing/common/json/badoption"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -99,12 +101,12 @@ func testShadowsocksInboundWithShadowsocksRust(t *testing.T, method string, pass
Cmd: []string{"-s", F.ToString("127.0.0.1:", serverPort), "-b", F.ToString("0.0.0.0:", clientPort), "-m", method, "-k", password, "-U"}, Cmd: []string{"-s", F.ToString("127.0.0.1:", serverPort), "-b", F.ToString("0.0.0.0:", clientPort), "-m", method, "-k", password, "-U"},
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Method: method, Method: method,
@ -124,21 +126,21 @@ func testShadowsocksOutboundWithShadowsocksRust(t *testing.T, method string, pas
Cmd: []string{"-s", F.ToString("0.0.0.0:", serverPort), "-m", method, "-k", password, "-U"}, Cmd: []string{"-s", F.ToString("0.0.0.0:", serverPort), "-m", method, "-k", password, "-U"},
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -154,22 +156,22 @@ func testShadowsocksOutboundWithShadowsocksRust(t *testing.T, method string, pas
func testShadowsocksSelf(t *testing.T, method string, password string) { func testShadowsocksSelf(t *testing.T, method string, password string) {
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Method: method, Method: method,
@ -177,14 +179,14 @@ func testShadowsocksSelf(t *testing.T, method string, password string) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -221,22 +223,22 @@ func TestShadowsocksUoT(t *testing.T) {
method := shadowaead_2022.List[0] method := shadowaead_2022.List[0]
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Method: method, Method: method,
@ -244,14 +246,14 @@ func TestShadowsocksUoT(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -289,22 +291,22 @@ func TestShadowsocksUoT(t *testing.T) {
func testShadowsocks2022EIH(t *testing.T, method string, password string) { func testShadowsocks2022EIH(t *testing.T, method string, password string) {
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Method: method, Method: method,
@ -317,14 +319,14 @@ func testShadowsocks2022EIH(t *testing.T, method string, password string) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -10,7 +10,9 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks/shadowaead_2022" "github.com/sagernet/sing-shadowsocks/shadowaead_2022"
"github.com/sagernet/sing/common"
F "github.com/sagernet/sing/common/format" F "github.com/sagernet/sing/common/format"
"github.com/sagernet/sing/common/json/badoption"
"github.com/stretchr/testify/require" "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] method := shadowaead_2022.List[0]
ssPassword := mkBase64(t, 16) ssPassword := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
@ -50,12 +52,15 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
{ {
Type: C.TypeShadowTLS, Type: C.TypeShadowTLS,
Tag: "in", Tag: "in",
ShadowTLSOptions: option.ShadowTLSInboundOptions{ Options: &option.ShadowTLSInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
InboundOptions: option.InboundOptions{
Detour: "detour", Detour: "detour",
}, },
},
Handshake: option.ShadowTLSHandshakeOptions{ Handshake: option.ShadowTLSHandshakeOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "google.com", Server: "google.com",
@ -70,9 +75,9 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "detour", Tag: "detour",
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: otherPort, ListenPort: otherPort,
}, },
Method: method, 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, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
Method: method, Method: method,
Password: ssPassword, Password: ssPassword,
DialerOptions: option.DialerOptions{ DialerOptions: option.DialerOptions{
@ -94,7 +99,7 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
{ {
Type: C.TypeShadowTLS, Type: C.TypeShadowTLS,
Tag: "detour", Tag: "detour",
ShadowTLSOptions: option.ShadowTLSOutboundOptions{ Options: &option.ShadowTLSOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -142,12 +147,12 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool)
func TestShadowTLSFallback(t *testing.T) { func TestShadowTLSFallback(t *testing.T) {
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeShadowTLS, Type: C.TypeShadowTLS,
ShadowTLSOptions: option.ShadowTLSInboundOptions{ Options: &option.ShadowTLSInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Handshake: option.ShadowTLSHandshakeOptions{ Handshake: option.ShadowTLSHandshakeOptions{
@ -189,25 +194,27 @@ 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}, 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{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "in", Tag: "in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowTLS, Type: C.TypeShadowTLS,
ShadowTLSOptions: option.ShadowTLSInboundOptions{ Options: &option.ShadowTLSInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
InboundOptions: option.InboundOptions{
Detour: "detour", Detour: "detour",
}, },
},
Handshake: option.ShadowTLSHandshakeOptions{ Handshake: option.ShadowTLSHandshakeOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "google.com", Server: "google.com",
@ -223,23 +230,23 @@ func TestShadowTLSInbound(t *testing.T) {
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "detour", Tag: "detour",
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
}, },
Method: method, Method: method,
Password: password, Password: password,
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "out", Tag: "out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: otherPort, ServerPort: otherPort,
@ -283,12 +290,12 @@ func TestShadowTLSOutbound(t *testing.T) {
Env: []string{"RUST_LOG=trace"}, Env: []string{"RUST_LOG=trace"},
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
@ -296,9 +303,9 @@ func TestShadowTLSOutbound(t *testing.T) {
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "detour", Tag: "detour",
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: otherPort, ListenPort: otherPort,
}, },
Method: method, Method: method,
@ -306,10 +313,10 @@ func TestShadowTLSOutbound(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
Method: method, Method: method,
Password: password, Password: password,
DialerOptions: option.DialerOptions{ DialerOptions: option.DialerOptions{
@ -320,7 +327,7 @@ func TestShadowTLSOutbound(t *testing.T) {
{ {
Type: C.TypeShadowTLS, Type: C.TypeShadowTLS,
Tag: "detour", Tag: "detour",
ShadowTLSOptions: option.ShadowTLSOutboundOptions{ Options: &option.ShadowTLSOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,6 +6,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestShadowsocksObfs(t *testing.T) { func TestShadowsocksObfs(t *testing.T) {
@ -33,21 +35,21 @@ func testShadowsocksPlugin(t *testing.T, name string, opts string, args string)
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,28 +7,30 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-shadowsocks/shadowaead" "github.com/sagernet/sing-shadowsocks/shadowaead"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestTCPSlowOpen(t *testing.T) { func TestTCPSlowOpen(t *testing.T) {
method := shadowaead.List[0] method := shadowaead.List[0]
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
ShadowsocksOptions: option.ShadowsocksInboundOptions{ Options: &option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
TCPFastOpen: true, TCPFastOpen: true,
}, },
@ -37,14 +39,14 @@ func TestTCPSlowOpen(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeShadowsocks, Type: C.TypeShadowsocks,
Tag: "ss-out", Tag: "ss-out",
ShadowsocksOptions: option.ShadowsocksOutboundOptions{ Options: &option.ShadowsocksOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,27 +6,29 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestUTLS(t *testing.T) { func TestUTLS(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanInboundOptions{ Options: &option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TrojanUser{ Users: []option.TrojanUser{
@ -46,14 +48,14 @@ func TestUTLS(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
Tag: "trojan-out", Tag: "trojan-out",
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,6 +6,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func TestTrojanOutbound(t *testing.T) { func TestTrojanOutbound(t *testing.T) {
@ -20,21 +22,21 @@ func TestTrojanOutbound(t *testing.T) {
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -57,22 +59,22 @@ func TestTrojanOutbound(t *testing.T) {
func TestTrojanSelf(t *testing.T) { func TestTrojanSelf(t *testing.T) {
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanInboundOptions{ Options: &option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TrojanUser{ Users: []option.TrojanUser{
@ -92,14 +94,14 @@ func TestTrojanSelf(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
Tag: "trojan-out", Tag: "trojan-out",
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -140,22 +142,22 @@ func TestTrojanSelf(t *testing.T) {
func TestTrojanPlainSelf(t *testing.T) { func TestTrojanPlainSelf(t *testing.T) {
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanInboundOptions{ Options: &option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TrojanUser{ Users: []option.TrojanUser{
@ -167,14 +169,14 @@ func TestTrojanPlainSelf(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
Tag: "trojan-out", Tag: "trojan-out",
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,6 +6,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
) )
@ -29,22 +31,22 @@ func testTUICSelf(t *testing.T, udpStream bool, zeroRTTHandshake bool) {
udpRelayMode = "quic" udpRelayMode = "quic"
} }
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
TUICOptions: option.TUICInboundOptions{ Options: &option.TUICInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TUICUser{{ Users: []option.TUICUser{{
@ -62,14 +64,14 @@ func testTUICSelf(t *testing.T, udpStream bool, zeroRTTHandshake bool) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
Tag: "tuic-out", Tag: "tuic-out",
TUICOptions: option.TUICOutboundOptions{ Options: &option.TUICOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -113,12 +115,12 @@ func testTUICSelf(t *testing.T, udpStream bool, zeroRTTHandshake bool) {
func TestTUICInbound(t *testing.T) { func TestTUICInbound(t *testing.T) {
caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
TUICOptions: option.TUICInboundOptions{ Options: &option.TUICInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TUICUser{{ Users: []option.TUICUser{{
@ -160,21 +162,21 @@ func TestTUICOutbound(t *testing.T) {
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeTUIC, Type: C.TypeTUIC,
TUICOptions: option.TUICOutboundOptions{ Options: &option.TUICOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -1,5 +1,6 @@
package main package main
/*
import ( import (
"context" "context"
"net/netip" "net/netip"
@ -8,25 +9,27 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/experimental/v2rayapi" "github.com/sagernet/sing-box/experimental/v2rayapi"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestV2RayAPI(t *testing.T) { func TestV2RayAPI(t *testing.T) {
i := startInstance(t, option.Options{ i := startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "in", Tag: "in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
Tag: "out", Tag: "out",
@ -54,3 +57,4 @@ func TestV2RayAPI(t *testing.T) {
require.Equal(t, count, stat.Value) require.Equal(t, count, stat.Value)
} }
} }
*/

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
"github.com/spyzhov/ajson" "github.com/spyzhov/ajson"
@ -27,12 +29,12 @@ func testV2RayGRPCInbound(t *testing.T, forceLite bool) {
require.NoError(t, err) require.NoError(t, err)
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -126,23 +128,23 @@ func testV2RayGRPCOutbound(t *testing.T, forceLite bool) {
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -6,6 +6,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -44,22 +46,22 @@ func testVMessTransportSelf(t *testing.T, server *option.V2RayTransportOptions,
require.NoError(t, err) require.NoError(t, err)
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -80,14 +82,14 @@ func testVMessTransportSelf(t *testing.T, server *option.V2RayTransportOptions,
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -133,22 +135,22 @@ func testTrojanTransportSelf(t *testing.T, server *option.V2RayTransportOptions,
require.NoError(t, err) require.NoError(t, err)
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
TrojanOptions: option.TrojanInboundOptions{ Options: &option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.TrojanUser{ Users: []option.TrojanUser{
@ -169,14 +171,14 @@ func testTrojanTransportSelf(t *testing.T, server *option.V2RayTransportOptions,
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeTrojan, Type: C.TypeTrojan,
Tag: "vmess-out", Tag: "vmess-out",
TrojanOptions: option.TrojanOutboundOptions{ Options: &option.TrojanOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -224,22 +226,22 @@ func TestVMessQUICSelf(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -260,14 +262,14 @@ func TestVMessQUICSelf(t *testing.T) {
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -312,22 +314,22 @@ func testV2RayTransportNOTLSSelf(t *testing.T, transport *option.V2RayTransportO
user, err := uuid.DefaultGenerator.NewV4() user, err := uuid.DefaultGenerator.NewV4()
require.NoError(t, err) require.NoError(t, err)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -340,14 +342,14 @@ func testV2RayTransportNOTLSSelf(t *testing.T, transport *option.V2RayTransportO
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
"github.com/spyzhov/ajson" "github.com/spyzhov/ajson"
@ -61,12 +63,12 @@ func testV2RayWebsocketInbound(t *testing.T, maxEarlyData uint32, earlyDataHeade
require.NoError(t, err) require.NoError(t, err)
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org") _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -158,23 +160,23 @@ func testV2RayWebsocketOutbound(t *testing.T, maxEarlyData uint32, earlyDataHead
}, },
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
"github.com/gofrs/uuid/v5" "github.com/gofrs/uuid/v5"
"github.com/spyzhov/ajson" "github.com/spyzhov/ajson"
@ -181,12 +183,12 @@ func testVMessInboundWithV2Ray(t *testing.T, security string, alterId int, authe
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -229,21 +231,21 @@ func testVMessOutboundWithV2Ray(t *testing.T, security string, globalPadding boo
}) })
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
@ -263,22 +265,22 @@ func testVMessOutboundWithV2Ray(t *testing.T, security string, globalPadding boo
func testVMessSelf(t *testing.T, security string, alterId int, globalPadding bool, authenticatedLength bool, packetAddr bool) { func testVMessSelf(t *testing.T, security string, alterId int, globalPadding bool, authenticatedLength bool, packetAddr bool) {
user := newUUID() user := newUUID()
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
Tag: "mixed-in", Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
VMessOptions: option.VMessInboundOptions{ Options: &option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: serverPort, ListenPort: serverPort,
}, },
Users: []option.VMessUser{ Users: []option.VMessUser{
@ -291,14 +293,14 @@ func testVMessSelf(t *testing.T, security string, alterId int, globalPadding boo
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeDirect, Type: C.TypeDirect,
}, },
{ {
Type: C.TypeVMess, Type: C.TypeVMess,
Tag: "vmess-out", Tag: "vmess-out",
VMessOptions: option.VMessOutboundOptions{ Options: &option.VMessOutboundOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,

View file

@ -7,6 +7,8 @@ import (
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/json/badoption"
) )
func _TestWireGuard(t *testing.T) { func _TestWireGuard(t *testing.T) {
@ -21,26 +23,26 @@ func _TestWireGuard(t *testing.T) {
}) })
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
startInstance(t, option.Options{ startInstance(t, option.Options{
Inbounds: []option.LegacyInbound{ Inbounds: []option.Inbound{
{ {
Type: C.TypeMixed, Type: C.TypeMixed,
MixedOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.IPv4Unspecified()), Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
ListenPort: clientPort, ListenPort: clientPort,
}, },
}, },
}, },
}, },
LegacyOutbounds: []option.LegacyOutbound{ Outbounds: []option.Outbound{
{ {
Type: C.TypeWireGuard, Type: C.TypeWireGuard,
WireGuardOptions: option.WireGuardOutboundOptions{ Options: &option.WireGuardEndpointOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: "127.0.0.1", Server: "127.0.0.1",
ServerPort: serverPort, ServerPort: serverPort,
}, },
LocalAddress: []netip.Prefix{netip.MustParsePrefix("10.0.0.2/32")}, Address: []netip.Prefix{netip.MustParsePrefix("10.0.0.2/32")},
PrivateKey: "qGnwlkZljMxeECW8fbwAWdvgntnbK7B8UmMFl3zM0mk=", PrivateKey: "qGnwlkZljMxeECW8fbwAWdvgntnbK7B8UmMFl3zM0mk=",
PeerPublicKey: "QsdcBm+oJw2oNv0cIFXLIq1E850lgTBonup4qnKEQBg=", PeerPublicKey: "QsdcBm+oJw2oNv0cIFXLIq1E850lgTBonup4qnKEQBg=",
}, },

View file

@ -10,9 +10,9 @@ import (
) )
func TestOptionsWrapper(t *testing.T) { func TestOptionsWrapper(t *testing.T) {
inbound := option.LegacyInbound{ inbound := option.Inbound{
Type: C.TypeHTTP, Type: C.TypeHTTP,
HTTPOptions: option.HTTPMixedInboundOptions{ Options: &option.HTTPMixedInboundOptions{
InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{ InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{
TLS: &option.InboundTLSOptions{ TLS: &option.InboundTLSOptions{
Enabled: true, Enabled: true,
@ -20,13 +20,11 @@ func TestOptionsWrapper(t *testing.T) {
}, },
}, },
} }
rawOptions, err := inbound.RawOptions() tlsOptionsWrapper, loaded := inbound.Options.(option.InboundTLSOptionsWrapper)
require.NoError(t, err)
tlsOptionsWrapper, loaded := rawOptions.(option.InboundTLSOptionsWrapper)
require.True(t, loaded, "find inbound tls options") require.True(t, loaded, "find inbound tls options")
tlsOptions := tlsOptionsWrapper.TakeInboundTLSOptions() tlsOptions := tlsOptionsWrapper.TakeInboundTLSOptions()
require.NotNil(t, tlsOptions, "find inbound tls options") require.NotNil(t, tlsOptions, "find inbound tls options")
tlsOptions.Enabled = false tlsOptions.Enabled = false
tlsOptionsWrapper.ReplaceInboundTLSOptions(tlsOptions) tlsOptionsWrapper.ReplaceInboundTLSOptions(tlsOptions)
require.False(t, inbound.HTTPOptions.TLS.Enabled, "replace tls enabled") require.False(t, inbound.Options.(*option.HTTPMixedInboundOptions).TLS.Enabled, "replace tls enabled")
} }