From 2101c1a99f5530cd208d1729086fa9a3e91c0053 Mon Sep 17 00:00:00 2001 From: Fangliding Date: Fri, 5 Jun 2026 18:36:18 +0800 Subject: [PATCH] use netip --- proxy/tun/handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/tun/handler.go b/proxy/tun/handler.go index 57e4aedbf..ab5c09cc4 100644 --- a/proxy/tun/handler.go +++ b/proxy/tun/handler.go @@ -2,6 +2,7 @@ package tun import ( "context" + "net/netip" "syscall" "github.com/xtls/xray-core/common" @@ -80,10 +81,9 @@ func (t *Handler) Init(ctx context.Context, pm policy.Manager, dispatcher routin return nil } return c.Control(func(fd uintptr) { - ipStr, _, _ := net.SplitHostPort(address) - ip := net.ParseIP(ipStr) + addrPort, _ := netip.ParseAddrPort(address) // skip loopback - if ip != nil && ip.IsLoopback() { + if addrPort.Addr().IsLoopback() { return } err := setinterface(network, address, fd, iface)