fix UpdateWgPeers

This commit is contained in:
Matthew R Kasun
2022-01-19 15:00:03 -05:00
parent fc86015c29
commit 353c92e333
3 changed files with 54 additions and 16 deletions

View File

@@ -53,8 +53,19 @@ func SetWGKeyConfig(network string, serveraddr string) error {
// ApplyWGQuickConf - applies wg-quick commands if os supports
func ApplyWGQuickConf(confPath string) error {
_, _ = ncutils.RunCmd("wg-quick down "+confPath, false)
_, err := ncutils.RunCmd("wg-quick up "+confPath, false)
_, err := os.Stat(confPath)
if err != nil {
ncutils.Log(confPath + " does not exist " + err.Error())
return err
}
_, err = ncutils.RunCmd("wg-quick down "+confPath, false)
if err != nil {
ncutils.Log("err runing wg-quick down " + confPath + err.Error())
}
_, err = ncutils.RunCmd("wg-quick up "+confPath, false)
if err != nil {
ncutils.Log("err runing wg-quick up " + confPath + err.Error())
}
return err
}