diff options
| author | 2020-01-28 20:44:12 +0100 | |
|---|---|---|
| committer | 2020-01-28 20:48:25 +0100 | |
| commit | 2bc596c21f562c144b0b9b23c06c18d08f210fa4 (patch) | |
| tree | f6dd38176d256f5a53e98df1aed91708dcf173be /manager | |
| parent | tunnel: deduplicate addresses from config (diff) | |
| download | wireguard-windows-jd/adminnobs.tar.xz wireguard-windows-jd/adminnobs.zip | |
manager: add ability to update silentlyjd/adminnobs
Diffstat (limited to 'manager')
| -rw-r--r-- | manager/updatestate.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/manager/updatestate.go b/manager/updatestate.go index b54cc367..4cc9a8f8 100644 --- a/manager/updatestate.go +++ b/manager/updatestate.go @@ -9,6 +9,7 @@ import ( "log" "time" + "golang.zx2c4.com/wireguard/windows/conf" "golang.zx2c4.com/wireguard/windows/updater" "golang.zx2c4.com/wireguard/windows/version" ) @@ -35,12 +36,23 @@ func checkForUpdates() { first := true for { - update, err := updater.CheckForUpdate() - if err == nil && update != nil { - log.Println("An update is available") - updateState = UpdateStateFoundUpdate - IPCServerNotifyUpdateFound(updateState) - return + var err error + if conf.AdminBool("SilentUpdate") { + progress := updater.DownloadVerifyAndExecute(0) + for { + dp := <-progress + if dp.Complete || dp.Error != nil { + break + } + } + } else { + update, err := updater.CheckForUpdate() + if err == nil && update != nil { + log.Println("An update is available") + updateState = UpdateStateFoundUpdate + IPCServerNotifyUpdateFound(updateState) + return + } } if err != nil { log.Printf("Update checker: %v", err) |
