mirror of https://github.com/tailscale/tailscale/
tailcfg,hostinfo: add Hostinfo.Machine and Hostinfo.GoArchVar
For detecting a non-ideal binary running on the current CPU. And for helping detect the best Synology package to update to. Updates #6995 Change-Id: I722f806675b60ce95364471b11c388150c0d4aea Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/7037/head
parent
fd92fbd69e
commit
64547b2b86
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2023 Tailscale Inc & AUTHORS All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build linux || freebsd || openbsd || darwin
|
||||||
|
|
||||||
|
package hostinfo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
"tailscale.com/types/ptr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
unameMachine = lazyUnameMachine.Get
|
||||||
|
}
|
||||||
|
|
||||||
|
var lazyUnameMachine = &lazyAtomicValue[string]{f: ptr.To(unameMachineUnix)}
|
||||||
|
|
||||||
|
func unameMachineUnix() string {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "android":
|
||||||
|
// Don't call on Android for now. We're late in the 1.36 release cycle
|
||||||
|
// and don't want to test syscall filters on various Android versions to
|
||||||
|
// see what's permitted. Notably, the hostinfo_linux.go file has build
|
||||||
|
// tag !android, so maybe Uname is verboten.
|
||||||
|
return ""
|
||||||
|
case "ios":
|
||||||
|
// For similar reasons, don't call on iOS. There aren't many iOS devices
|
||||||
|
// and we know their CPU properties so calling this is only risk and no
|
||||||
|
// reward.
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var un unix.Utsname
|
||||||
|
unix.Uname(&un)
|
||||||
|
return unix.ByteSliceToString(un.Machine[:])
|
||||||
|
}
|
Loading…
Reference in New Issue