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,