mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 16:13:31 +01:00
fix: remove existing wiretrustee interface if existed
This commit is contained in:
parent
d4a24ac001
commit
3c4b0b3a4b
@ -30,8 +30,27 @@ func CreateWithKernel(iface string, address string) error {
|
||||
attrs: &attrs,
|
||||
}
|
||||
|
||||
// check if interface exists
|
||||
l, err := netlink.LinkByName(WgInterfaceDefault)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case netlink.LinkNotFoundError:
|
||||
break
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// remove if interface exists
|
||||
if l != nil {
|
||||
err = netlink.LinkDel(&link)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("adding device: %s", iface)
|
||||
err := netlink.LinkAdd(&link)
|
||||
err = netlink.LinkAdd(&link)
|
||||
if os.IsExist(err) {
|
||||
log.Infof("interface %s already exists. Will reuse.", iface)
|
||||
} else if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user