mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 09:00:04 +08:00
chore: add singMux inbound test for shadowsocks/trojan/vless/vmess
Some checks failed
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Failing after 1s
Test / test (1.21, ubuntu-latest) (push) Failing after 1s
Test / test (1.22, ubuntu-latest) (push) Failing after 1s
Test / test (1.23, ubuntu-latest) (push) Failing after 1s
Test / test (1.24, ubuntu-latest) (push) Failing after 1s
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 1s
Some checks failed
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Failing after 1s
Test / test (1.21, ubuntu-latest) (push) Failing after 1s
Test / test (1.22, ubuntu-latest) (push) Failing after 1s
Test / test (1.23, ubuntu-latest) (push) Failing after 1s
Test / test (1.24, ubuntu-latest) (push) Failing after 1s
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 1s
This commit is contained in:
parent
76052b5b26
commit
314bcdff95
30
listener/inbound/mux_test.go
Normal file
30
listener/inbound/mux_test.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package inbound_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/adapter/outbound"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
var singMuxProtocolList = []string{"h2mux", "smux", "yamux"}
|
||||||
|
|
||||||
|
func testSingMux(t *testing.T, tunnel *TestTunnel, out outbound.ProxyAdapter) {
|
||||||
|
t.Run("singmux", func(t *testing.T) {
|
||||||
|
for _, protocol := range singMuxProtocolList {
|
||||||
|
t.Run(protocol, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
singMuxOption := outbound.SingMuxOption{
|
||||||
|
Enabled: true,
|
||||||
|
Protocol: protocol,
|
||||||
|
}
|
||||||
|
out, err := outbound.NewSingMux(singMuxOption, out)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
tunnel.DoTest(t, out)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -77,6 +77,8 @@ func testInboundShadowSocks0(t *testing.T, inboundOptions inbound.ShadowSocksOpt
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
tunnel.DoTest(t, out)
|
tunnel.DoTest(t, out)
|
||||||
|
|
||||||
|
testSingMux(t, tunnel, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInboundShadowSocks_Basic(t *testing.T) {
|
func TestInboundShadowSocks_Basic(t *testing.T) {
|
||||||
|
|||||||
@ -42,6 +42,8 @@ func testInboundTrojan(t *testing.T, inboundOptions inbound.TrojanOption, outbou
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
tunnel.DoTest(t, out)
|
tunnel.DoTest(t, out)
|
||||||
|
|
||||||
|
testSingMux(t, tunnel, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInboundTrojan_TLS(t *testing.T) {
|
func TestInboundTrojan_TLS(t *testing.T) {
|
||||||
|
|||||||
@ -42,6 +42,8 @@ func testInboundVless(t *testing.T, inboundOptions inbound.VlessOption, outbound
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
tunnel.DoTest(t, out)
|
tunnel.DoTest(t, out)
|
||||||
|
|
||||||
|
testSingMux(t, tunnel, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInboundVless_TLS(t *testing.T) {
|
func TestInboundVless_TLS(t *testing.T) {
|
||||||
|
|||||||
@ -44,6 +44,8 @@ func testInboundVMess(t *testing.T, inboundOptions inbound.VmessOption, outbound
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
tunnel.DoTest(t, out)
|
tunnel.DoTest(t, out)
|
||||||
|
|
||||||
|
testSingMux(t, tunnel, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInboundVMess_Basic(t *testing.T) {
|
func TestInboundVMess_Basic(t *testing.T) {
|
||||||
|
|||||||
@ -72,7 +72,7 @@ func NewListenerHandler(lc ListenerConfig) (h *ListenerHandler, err error) {
|
|||||||
NewStreamContext: func(ctx context.Context, conn net.Conn) context.Context {
|
NewStreamContext: func(ctx context.Context, conn net.Conn) context.Context {
|
||||||
return ctx
|
return ctx
|
||||||
},
|
},
|
||||||
Logger: log.SingLogger,
|
Logger: log.SingInfoToDebugLogger, // convert sing-mux info log to debug
|
||||||
Handler: h,
|
Handler: h,
|
||||||
Padding: lc.MuxOption.Padding,
|
Padding: lc.MuxOption.Padding,
|
||||||
Brutal: mux.BrutalOptions{
|
Brutal: mux.BrutalOptions{
|
||||||
|
|||||||
13
log/sing.go
13
log/sing.go
@ -65,4 +65,17 @@ func (l singLogger) Panic(args ...any) {
|
|||||||
Fatalln(fmt.Sprint(args...))
|
Fatalln(fmt.Sprint(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type singInfoToDebugLogger struct {
|
||||||
|
singLogger
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l singInfoToDebugLogger) InfoContext(ctx context.Context, args ...any) {
|
||||||
|
Debugln(fmt.Sprint(args...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l singInfoToDebugLogger) Info(args ...any) {
|
||||||
|
Debugln(fmt.Sprint(args...))
|
||||||
|
}
|
||||||
|
|
||||||
var SingLogger L.ContextLogger = singLogger{}
|
var SingLogger L.ContextLogger = singLogger{}
|
||||||
|
var SingInfoToDebugLogger L.ContextLogger = singInfoToDebugLogger{}
|
||||||
|
|||||||
@ -29,9 +29,15 @@ type netAddr struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (addr netAddr) RemoteAddr() net.Addr {
|
func (addr netAddr) RemoteAddr() net.Addr {
|
||||||
|
if addr.remoteAddr == nil {
|
||||||
|
return &net.TCPAddr{IP: net.IPv4zero, Port: 0}
|
||||||
|
}
|
||||||
return addr.remoteAddr
|
return addr.remoteAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (addr netAddr) LocalAddr() net.Addr {
|
func (addr netAddr) LocalAddr() net.Addr {
|
||||||
|
if addr.localAddr == nil {
|
||||||
|
return &net.TCPAddr{IP: net.IPv4zero, Port: 0}
|
||||||
|
}
|
||||||
return addr.localAddr
|
return addr.localAddr
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user