aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/version/os_linux.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-04-28 12:27:06 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-04-29 08:41:30 +0200
commit51a410523acd4687a91ff6b48e05a4c7d711126a (patch)
tree1c3e6059569376c72336ba09f06e9a5ee5e1e833 /version/os_linux.go
parentgo.mod: use forked winio with no thirdparty deps (diff)
downloadwireguard-windows-51a410523acd4687a91ff6b48e05a4c7d711126a.tar.xz
wireguard-windows-51a410523acd4687a91ff6b48e05a4c7d711126a.zip
updater: add initial skeleton
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'version/os_linux.go')
-rw-r--r--version/os_linux.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/version/os_linux.go b/version/os_linux.go
new file mode 100644
index 00000000..7e5c4f1c
--- /dev/null
+++ b/version/os_linux.go
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
+ */
+
+package version
+
+import (
+ "bytes"
+ "fmt"
+ "golang.org/x/sys/unix"
+)
+
+// This isn't a Linux program, yes, but having the updater package work across platforms is quite helpful for testing.
+
+func utsToStr(u [65]byte) string {
+ i := bytes.IndexByte(u[:], 0)
+ if i < 0 {
+ return string(u[:])
+ }
+ return string(u[:i])
+}
+
+func OsName() string {
+ var utsname unix.Utsname
+ if unix.Uname(&utsname) != nil {
+ return "Unix Unknown"
+ }
+ return fmt.Sprintf("%s %s %s", utsToStr(utsname.Sysname), utsToStr(utsname.Release), utsToStr(utsname.Version))
+}