mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
hostinfo, ipn/ipnlocal: add SetPackage, remove ipnlocal hacks
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
81269fad28
commit
67e5fabdbd
@ -48,6 +48,9 @@ func getOSVersion() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func packageType() string {
|
func packageType() string {
|
||||||
|
if v, _ := packagingType.Load().(string); v != "" {
|
||||||
|
return v
|
||||||
|
}
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
case "windows":
|
||||||
if _, err := os.Stat(`C:\ProgramData\chocolatey\lib\tailscale`); err == nil {
|
if _, err := os.Stat(`C:\ProgramData\chocolatey\lib\tailscale`); err == nil {
|
||||||
@ -95,6 +98,7 @@ func GetEnvType() EnvType {
|
|||||||
var (
|
var (
|
||||||
deviceModelAtomic atomic.Value // of string
|
deviceModelAtomic atomic.Value // of string
|
||||||
osVersionAtomic atomic.Value // of string
|
osVersionAtomic atomic.Value // of string
|
||||||
|
packagingType atomic.Value // of string
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetDeviceModel sets the device model for use in Hostinfo updates.
|
// SetDeviceModel sets the device model for use in Hostinfo updates.
|
||||||
@ -103,6 +107,11 @@ func SetDeviceModel(model string) { deviceModelAtomic.Store(model) }
|
|||||||
// SetOSVersion sets the OS version.
|
// SetOSVersion sets the OS version.
|
||||||
func SetOSVersion(v string) { osVersionAtomic.Store(v) }
|
func SetOSVersion(v string) { osVersionAtomic.Store(v) }
|
||||||
|
|
||||||
|
// SetPackage sets the packaging type for the app.
|
||||||
|
// This is currently (2021-10-05) only used by Android,
|
||||||
|
// set to "nogoogle" for the F-Droid build.
|
||||||
|
func SetPackage(v string) { packagingType.Store(v) }
|
||||||
|
|
||||||
func deviceModel() string {
|
func deviceModel() string {
|
||||||
s, _ := deviceModelAtomic.Load().(string)
|
s, _ := deviceModelAtomic.Load().(string)
|
||||||
return s
|
return s
|
||||||
|
@ -2277,20 +2277,8 @@ func applyPrefsToHostinfo(hi *tailcfg.Hostinfo, prefs *ipn.Prefs) {
|
|||||||
}
|
}
|
||||||
if v := prefs.OSVersion; v != "" && hi.OSVersion == "" {
|
if v := prefs.OSVersion; v != "" && hi.OSVersion == "" {
|
||||||
hi.OSVersion = v
|
hi.OSVersion = v
|
||||||
|
|
||||||
// The Android app annotates when Google Play Services
|
|
||||||
// aren't available by tacking on a string to the
|
|
||||||
// OSVersion. Promote that to the Hostinfo.Package
|
|
||||||
// field instead, rather than adding a new pref, as
|
|
||||||
// this applyPrefsToHostinfo mechanism is mostly
|
|
||||||
// abused currently. TODO(bradfitz): instead let
|
|
||||||
// frontends update Hostinfo, without using Prefs.
|
|
||||||
if runtime.GOOS == "android" && strings.HasSuffix(v, " [nogoogle]") {
|
|
||||||
hi.Package = "nogoogle"
|
|
||||||
hi.OSVersion = strings.TrimSuffix(v, " [nogoogle]")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if m := prefs.DeviceModel; m != "" {
|
if m := prefs.DeviceModel; m != "" && hi.DeviceModel == "" {
|
||||||
hi.DeviceModel = m
|
hi.DeviceModel = m
|
||||||
}
|
}
|
||||||
hi.RoutableIPs = append(prefs.AdvertiseRoutes[:0:0], prefs.AdvertiseRoutes...)
|
hi.RoutableIPs = append(prefs.AdvertiseRoutes[:0:0], prefs.AdvertiseRoutes...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user