From c7bc67e44c524e85639d63a1aec3cdd45cb2fc0f Mon Sep 17 00:00:00 2001 From: Skyxim Date: Thu, 28 Apr 2022 12:44:27 +0800 Subject: [PATCH] fix: handle metadata when dst is ip:port --- adapter/inbound/socket.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/adapter/inbound/socket.go b/adapter/inbound/socket.go index 5aa90034..28608be9 100644 --- a/adapter/inbound/socket.go +++ b/adapter/inbound/socket.go @@ -2,6 +2,7 @@ package inbound import ( "net" + "net/netip" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/context" @@ -36,7 +37,13 @@ func NewInner(conn net.Conn, dst string, host string) *context.ConnContext { if h, port, err := net.SplitHostPort(dst); err == nil { metadata.DstPort = port if host == "" { - metadata.Host = h + if ip, err := netip.ParseAddr(h); err == nil { + metadata.DstIP = ip + metadata.AddrType = C.AtypIPv4 + if ip.Is6() { + metadata.AddrType = C.AtypIPv6 + } + } } }