From 1b231aa239cf3a37fb1ec379f642e4ac52ffc53d Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Thu, 31 Jul 2025 12:09:57 +0800 Subject: [PATCH] Fix packetaddr panic --- protocol/vless/inbound.go | 4 ++-- protocol/vmess/inbound.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/protocol/vless/inbound.go b/protocol/vless/inbound.go index f9e505a8..3cc53db4 100644 --- a/protocol/vless/inbound.go +++ b/protocol/vless/inbound.go @@ -15,11 +15,11 @@ import ( "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/transport/v2ray" - "github.com/sagernet/sing-vmess" "github.com/sagernet/sing-vmess/packetaddr" "github.com/sagernet/sing-vmess/vless" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/auth" + "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" "github.com/sagernet/sing/common/logger" @@ -189,7 +189,7 @@ func (h *Inbound) newPacketConnectionEx(ctx context.Context, conn N.PacketConn, } if metadata.Destination.Fqdn == packetaddr.SeqPacketMagicAddress { metadata.Destination = M.Socksaddr{} - conn = packetaddr.NewConn(conn.(vmess.PacketConn), metadata.Destination) + conn = packetaddr.NewConn(bufio.NewNetPacketConn(conn), metadata.Destination) h.logger.InfoContext(ctx, "[", user, "] inbound packet addr connection") } else { h.logger.InfoContext(ctx, "[", user, "] inbound packet connection to ", metadata.Destination) diff --git a/protocol/vmess/inbound.go b/protocol/vmess/inbound.go index 706beb17..059d4775 100644 --- a/protocol/vmess/inbound.go +++ b/protocol/vmess/inbound.go @@ -19,6 +19,7 @@ import ( "github.com/sagernet/sing-vmess/packetaddr" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/auth" + "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" "github.com/sagernet/sing/common/logger" @@ -203,7 +204,7 @@ func (h *Inbound) newPacketConnectionEx(ctx context.Context, conn N.PacketConn, } if metadata.Destination.Fqdn == packetaddr.SeqPacketMagicAddress { metadata.Destination = M.Socksaddr{} - conn = packetaddr.NewConn(conn.(vmess.PacketConn), metadata.Destination) + conn = packetaddr.NewConn(bufio.NewNetPacketConn(conn), metadata.Destination) h.logger.InfoContext(ctx, "[", user, "] inbound packet addr connection") } else { h.logger.InfoContext(ctx, "[", user, "] inbound packet connection to ", metadata.Destination)