mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-03 03:59:07 +02:00
Write to temp file before saving data (#238)
* Create temp file before saving data On the event of full disk, we may encounter the case where the destination file get replaced by an empty file as the ioutil.WriteFile truncates the destination before write. * Close the tempFile instance before moving it * Blacklist Wireguard interfaces for ICE checks
This commit is contained in:
@@ -2,6 +2,7 @@ package peer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"golang.zx2c4.com/wireguard/wgctrl"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -87,11 +88,20 @@ func interfaceFilter(blackList []string) func(string) bool {
|
||||
}
|
||||
}
|
||||
return func(iFace string) bool {
|
||||
if len(blackListMap) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
_, ok := blackListMap[iFace]
|
||||
return !ok
|
||||
if ok {
|
||||
return false
|
||||
}
|
||||
// look for unlisted Wireguard interfaces
|
||||
wg, err := wgctrl.New()
|
||||
if err != nil {
|
||||
log.Debugf("trying to create a wgctrl client failed with: %v", err)
|
||||
}
|
||||
defer wg.Close()
|
||||
|
||||
_, err = wg.Device(iFace)
|
||||
return err != nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user