aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ADMIN_REGISTRY.md13
-rw-r--r--conf/admin.go36
-rw-r--r--manager/updatestate.go24
3 files changed, 67 insertions, 6 deletions
diff --git a/ADMIN_REGISTRY.md b/ADMIN_REGISTRY.md
new file mode 100644
index 00000000..ba96b6ff
--- /dev/null
+++ b/ADMIN_REGISTRY.md
@@ -0,0 +1,13 @@
+## Registry Keys for Admins
+
+These are advanced configuration nobs that admins can set to do unusual things
+that are not recommended. There is no UI to enable these, and no such thing is
+planned. Use at your own risk, and please make sure you know what you're doing.
+
+
+#### `HKLM\Software\WireGuard\SilentUpdate`
+
+When this key is set to `DWORD(1)`, WireGuard will silently update itself when
+an update is available. Note that this is not recommended, as all tunnels will
+be disrupted during the update, during which time Windows will revert to its
+ordinary routing rules.
diff --git a/conf/admin.go b/conf/admin.go
new file mode 100644
index 00000000..5740907a
--- /dev/null
+++ b/conf/admin.go
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
+ */
+
+package conf
+
+import "golang.org/x/sys/windows/registry"
+
+const adminRegKey = `Software\WireGuard`
+
+var adminKey registry.Key
+
+func openAdminKey() (registry.Key, error) {
+ if adminKey != 0 {
+ return adminKey, nil
+ }
+ var err error
+ adminKey, err = registry.OpenKey(registry.LOCAL_MACHINE, adminRegKey, registry.QUERY_VALUE | registry.SET_VALUE)
+ if err != nil {
+ return 0, err
+ }
+ return adminKey, nil
+}
+
+func AdminBool(name string) bool {
+ key, err := openAdminKey()
+ if err != nil {
+ return false
+ }
+ val, _, err := key.GetIntegerValue(name)
+ if err != nil {
+ return false
+ }
+ return val != 0
+}
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)