mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
hostinfo: use Distro field for distinguishing Windows Server builds
Some editions of Windows server share the same build number as their client counterpart; we must use an additional field found in the OS version information to distinguish between them. Even though "Distro" has Linux connotations, it is the most appropriate hostinfo field. What is Windows Server if not an alternate distribution of Windows? This PR populates Distro with "Server" when applicable. Fixes #11785 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
This commit is contained in:
@@ -13,18 +13,28 @@ import (
|
||||
"golang.org/x/sys/windows/registry"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/util/winutil"
|
||||
"tailscale.com/util/winutil/winenv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
distroName = lazyDistroName.Get
|
||||
osVersion = lazyOSVersion.Get
|
||||
packageType = lazyPackageType.Get
|
||||
}
|
||||
|
||||
var (
|
||||
lazyDistroName = &lazyAtomicValue[string]{f: ptr.To(distroNameWindows)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: ptr.To(osVersionWindows)}
|
||||
lazyPackageType = &lazyAtomicValue[string]{f: ptr.To(packageTypeWindows)}
|
||||
)
|
||||
|
||||
func distroNameWindows() string {
|
||||
if winenv.IsWindowsServer() {
|
||||
return "Server"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func osVersionWindows() string {
|
||||
major, minor, build := windows.RtlGetNtVersionNumbers()
|
||||
s := fmt.Sprintf("%d.%d.%d", major, minor, build)
|
||||
|
Reference in New Issue
Block a user