From fa2e6be05d1f145de198a85ad91ce02e22f0cbb3 Mon Sep 17 00:00:00 2001 From: adlyq Date: Tue, 31 May 2022 09:59:25 +0800 Subject: [PATCH] fix: TUN file exists --- listener/tun/ipstack/commons/router_android.go | 2 +- listener/tun/ipstack/commons/router_linux.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/listener/tun/ipstack/commons/router_android.go b/listener/tun/ipstack/commons/router_android.go index 172c9ce3..139dbca9 100644 --- a/listener/tun/ipstack/commons/router_android.go +++ b/listener/tun/ipstack/commons/router_android.go @@ -44,7 +44,7 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, return err } - if err = netlink.AddrAdd(metaLink, naddr); err != nil { + if err = netlink.AddrAdd(metaLink, naddr); err != nil && err.Error() != "file exists" { return err } diff --git a/listener/tun/ipstack/commons/router_linux.go b/listener/tun/ipstack/commons/router_linux.go index d5f3edab..a079f535 100644 --- a/listener/tun/ipstack/commons/router_linux.go +++ b/listener/tun/ipstack/commons/router_linux.go @@ -51,7 +51,7 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, return err } - if err = netlink.AddrAdd(metaLink, naddr); err != nil { + if err = netlink.AddrAdd(metaLink, naddr); err != nil && err.Error() != "file exists" { return err } @@ -65,7 +65,7 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, Protocol: 2, Src: ip.AsSlice(), Table: 254, - }); err != nil { + }); err != nil && err.Error() != "file exists" { return err }