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:
Maycon Santos
2022-02-20 19:03:16 +01:00
committed by GitHub
parent 60a9da734f
commit 5546eba36a
3 changed files with 40 additions and 8 deletions
+14 -4
View File
@@ -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
}
}