diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-09-09 12:23:42 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-09-09 12:24:07 +0200 |
commit | 0e245a943a09740c50c16612482f89e5f7964827 (patch) | |
tree | b72dc98a046fab93f12aca43a1e785f84eeb7fb0 /conf/admin_windows.go | |
parent | version: bump (diff) | |
download | wireguard-windows-0e245a943a09740c50c16612482f89e5f7964827.tar.xz wireguard-windows-0e245a943a09740c50c16612482f89e5f7964827.zip |
conf: use wgnt for those enrolled in insider program
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | conf/admin_windows.go | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/conf/admin_windows.go b/conf/admin_windows.go index 9b1a4035..3ac1cae0 100644 --- a/conf/admin_windows.go +++ b/conf/admin_windows.go @@ -5,7 +5,11 @@ package conf -import "golang.org/x/sys/windows/registry" +import ( + "strings" + + "golang.org/x/sys/windows/registry" +) const adminRegKey = `Software\WireGuard` @@ -23,7 +27,34 @@ func openAdminKey() (registry.Key, error) { return adminKey, nil } +func IsInsiderEnrolled() bool { + if AdminBool("IgnoreInsiderProgram") { + return false + } + key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\WindowsSelfHost\Applicability`, registry.QUERY_VALUE) + if err != nil { + return false + } + defer key.Close() + val, _, err := key.GetIntegerValue("IsBuildFlightingEnabled") + if err != nil || val != 1 { + return false + } + val, _, err = key.GetIntegerValue("EnablePreviewBuilds") + if err != nil || val != 1 { + return false + } + ring, _, err := key.GetStringValue("Ring") + if err != nil || !strings.EqualFold(ring, "external") { + return false + } + return true +} + func AdminBool(name string) bool { + if name == "ExperimentalKernelDriver" && IsInsiderEnrolled() { + return true + } key, err := openAdminKey() if err != nil { return false |