libadlin: Avoid wg infinite loops
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2022-04-20 20:11:38 +02:00
parent 4933c2f042
commit 6ac58634b8

View File

@ -1,6 +1,7 @@
package adlin package adlin
import ( import (
"context"
"crypto/ed25519" "crypto/ed25519"
"crypto/rand" "crypto/rand"
"crypto/sha512" "crypto/sha512"
@ -60,10 +61,13 @@ var (
) )
func _readWgDump() (wgd map[string]*WGDump, err error) { func _readWgDump() (wgd map[string]*WGDump, err error) {
out, errr := exec.Command("wg", "show", "wg-adlin", "dump").Output() ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
if errr != nil { out, err := exec.CommandContext(ctx, "wg", "show", "wg-adlin", "dump").Output()
return nil, errr
if err != nil {
return nil, err
} }
wgd = map[string]*WGDump{} wgd = map[string]*WGDump{}
@ -105,7 +109,7 @@ func readWgDump() (wgd map[string]*WGDump, err error) {
wgDumpCache_mutex.RLock() wgDumpCache_mutex.RLock()
} }
return wgd, nil return
} }
type TunnelToken struct { type TunnelToken struct {