Bypass default interface for loopback

This commit is contained in:
Fangliding
2026-06-05 17:16:53 +08:00
parent fdb9b616fc
commit bbc8103a7d
+6
View File
@@ -80,6 +80,12 @@ 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)
// skip loopback
if ip != nil && ip.IsLoopback() {
return
}
err := setinterface(network, address, fd, iface)
if err != nil {
errors.LogInfoInner(context.Background(), err, "[tun] falied to set interface")