From 295b0da0e512420873b041af31f493e1f4d13db7 Mon Sep 17 00:00:00 2001 From: Kr328 Date: Sun, 18 Jun 2023 11:16:40 +0800 Subject: [PATCH] Fix: should check originDst is nil (#2797) --- adapter/inbound/http.go | 6 ++++-- adapter/inbound/packet.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/adapter/inbound/http.go b/adapter/inbound/http.go index b27ea88..a7a5552 100644 --- a/adapter/inbound/http.go +++ b/adapter/inbound/http.go @@ -18,8 +18,10 @@ func NewHTTP(target socks5.Addr, source net.Addr, originTarget net.Addr, conn ne metadata.SrcIP = ip metadata.SrcPort = port } - if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { - metadata.OriginDst = addrPort + if originTarget != nil { + if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { + metadata.OriginDst = addrPort + } } return context.NewConnContext(conn, metadata) } diff --git a/adapter/inbound/packet.go b/adapter/inbound/packet.go index bfa1355..2e1e728 100644 --- a/adapter/inbound/packet.go +++ b/adapter/inbound/packet.go @@ -28,8 +28,10 @@ func NewPacket(target socks5.Addr, originTarget net.Addr, packet C.UDPPacket, so metadata.SrcIP = ip metadata.SrcPort = port } - if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { - metadata.OriginDst = addrPort + if originTarget != nil { + if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { + metadata.OriginDst = addrPort + } } return &PacketAdapter{ UDPPacket: packet,