tailcfg, localapi: plumb device token to server

Updates tailscale/corp#8940

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
David Crawshaw
2023-01-29 14:04:40 -08:00
committed by David Crawshaw
parent 38b32be926
commit 8cf2805cca
9 changed files with 130 additions and 27 deletions

View File

@@ -50,6 +50,7 @@ func New() *tailcfg.Hostinfo {
GoVersion: runtime.Version(),
Machine: condCall(unameMachine),
DeviceModel: deviceModel(),
PushDeviceToken: pushDeviceToken(),
Cloud: string(cloudenv.Get()),
NoLogsNoSupport: envknob.NoLogsNoSupport(),
AllowsUpdate: envknob.AllowsRemoteUpdate(),
@@ -153,12 +154,16 @@ func GetEnvType() EnvType {
}
var (
deviceModelAtomic atomic.Value // of string
osVersionAtomic atomic.Value // of string
desktopAtomic atomic.Value // of opt.Bool
packagingType atomic.Value // of string
pushDeviceTokenAtomic atomic.Value // of string
deviceModelAtomic atomic.Value // of string
osVersionAtomic atomic.Value // of string
desktopAtomic atomic.Value // of opt.Bool
packagingType atomic.Value // of string
)
// SetPushDeviceToken sets the device token for use in Hostinfo updates.
func SetPushDeviceToken(token string) { pushDeviceTokenAtomic.Store(token) }
// SetDeviceModel sets the device model for use in Hostinfo updates.
func SetDeviceModel(model string) { deviceModelAtomic.Store(model) }
@@ -176,6 +181,11 @@ func deviceModel() string {
return s
}
func pushDeviceToken() string {
s, _ := pushDeviceTokenAtomic.Load().(string)
return s
}
func desktop() (ret opt.Bool) {
if runtime.GOOS != "linux" {
return opt.Bool("")