From f7e651019949ee0a434a41d65e3edfdc2f2216ce Mon Sep 17 00:00:00 2001 From: Fangliding Date: Thu, 7 May 2026 17:29:51 +0800 Subject: [PATCH] Fix bug --- common/singbridge/pipe.go | 2 +- proxy/shadowsocks_2022/inbound.go | 5 +++++ proxy/shadowsocks_2022/inbound_multi.go | 5 +++++ proxy/shadowsocks_2022/inbound_relay.go | 5 +++++ proxy/shadowsocks_2022/outbound.go | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common/singbridge/pipe.go b/common/singbridge/pipe.go index 5bb4b8d1..fef0fdcb 100644 --- a/common/singbridge/pipe.go +++ b/common/singbridge/pipe.go @@ -45,7 +45,7 @@ func (w *PipeConnWrapper) Close() error { func (w *PipeConnWrapper) Read(b []byte) (n int, err error) { w.T.Update() - n, err = w.Read(b) + n, err = w.R.Read(b) if err != nil { // uplinkonly w.T.SetTimeout(3 * time.Second) diff --git a/proxy/shadowsocks_2022/inbound.go b/proxy/shadowsocks_2022/inbound.go index 76b01302..edf9857c 100644 --- a/proxy/shadowsocks_2022/inbound.go +++ b/proxy/shadowsocks_2022/inbound.go @@ -2,6 +2,7 @@ package shadowsocks_2022 import ( "context" + "time" shadowsocks "github.com/sagernet/sing-shadowsocks" "github.com/sagernet/sing-shadowsocks/shadowaead_2022" @@ -18,6 +19,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet/stat" @@ -152,6 +154,9 @@ func (i *Inbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, me Reader: link.Reader, Writer: link.Writer, Dest: destination, + T: signal.CancelAfterInactivity(ctx, func() { + common.Interrupt(link.Reader) + }, 300*time.Second), } return bufio.CopyPacketConn(ctx, conn, outConn) } diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 345840b6..d6d68c09 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" "sync" + "time" "github.com/sagernet/sing-shadowsocks/shadowaead_2022" C "github.com/sagernet/sing/common" @@ -22,6 +23,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/features/routing" @@ -273,6 +275,9 @@ func (i *MultiUserInbound) NewPacketConnection(ctx context.Context, conn N.Packe Reader: link.Reader, Writer: link.Writer, Dest: destination, + T: signal.CancelAfterInactivity(ctx, func() { + common.Interrupt(link.Reader) + }, 300*time.Second), } return bufio.CopyPacketConn(ctx, conn, outConn) } diff --git a/proxy/shadowsocks_2022/inbound_relay.go b/proxy/shadowsocks_2022/inbound_relay.go index b29ab303..4ca5e207 100644 --- a/proxy/shadowsocks_2022/inbound_relay.go +++ b/proxy/shadowsocks_2022/inbound_relay.go @@ -4,6 +4,7 @@ import ( "context" "strconv" "strings" + "time" "github.com/sagernet/sing-shadowsocks/shadowaead_2022" C "github.com/sagernet/sing/common" @@ -20,6 +21,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/features/routing" @@ -177,6 +179,9 @@ func (i *RelayInbound) NewPacketConnection(ctx context.Context, conn N.PacketCon Reader: link.Reader, Writer: link.Writer, Dest: destination, + T: signal.CancelAfterInactivity(ctx, func() { + common.Interrupt(link.Reader) + }, 300*time.Second), } return bufio.CopyPacketConn(ctx, conn, outConn) } diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index dd2e4259..bd3e4c4e 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -16,6 +16,7 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" @@ -142,6 +143,9 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int Writer: link.Writer, Conn: inboundConn, Dest: destination, + T: signal.CancelAfterInactivity(ctx, func() { + common.Interrupt(link.Reader) + }, 300*time.Second), } }