mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
64547b2b86
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>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// 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[:])
|
|
}
|