Use LatestHandshake to validate endpoint (#149)
* wireguard: `wg show iface dump` reader and parser * mesh: use LatestHandshake to validate NAT Endpoints * add skip on error * switch to loop parsing So the stop on error pattern can be used * Add error handling to ParseDump
This commit is contained in:
committed by
GitHub
parent
0733c83a0a
commit
e12b5029d7
@@ -119,3 +119,15 @@ func ShowConf(iface string) ([]byte, error) {
|
||||
}
|
||||
return stdout.Bytes(), nil
|
||||
}
|
||||
|
||||
// ShowDump gets the WireGuard configuration and runtime information for the given interface.
|
||||
func ShowDump(iface string) ([]byte, error) {
|
||||
cmd := exec.Command("wg", "show", iface, "dump")
|
||||
var stderr, stdout bytes.Buffer
|
||||
cmd.Stderr = &stderr
|
||||
cmd.Stdout = &stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
return nil, fmt.Errorf("failed to read the WireGuard dump output: %s", stderr.String())
|
||||
}
|
||||
return stdout.Bytes(), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user