From 6c094cc1989661df5f4203f59b151c90b558bbc8 Mon Sep 17 00:00:00 2001 From: kari-ts Date: Fri, 20 Feb 2026 09:53:00 -0800 Subject: [PATCH] android: set hostname fn Use device name, with hardware model as a fallback for hostname in Android, since os.Hostname returns localhost Updates tailscale/tailscale#7875 Signed-off-by: kari-ts --- libtailscale/backend.go | 5 ++++- libtailscale/tailscale.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libtailscale/backend.go b/libtailscale/backend.go index 16fa0c6701..82ca78ece3 100644 --- a/libtailscale/backend.go +++ b/libtailscale/backend.go @@ -115,11 +115,14 @@ func (a *App) runBackend(ctx context.Context, hardwareAttestation bool) error { paths.AppSharedDir.Store(a.dataDir) hostinfo.SetOSVersion(a.osVersion()) hostinfo.SetPackage(a.appCtx.GetInstallSource()) - deviceModel := a.modelName() + deviceModel := a.deviceName() if a.isChromeOS() { deviceModel = "ChromeOS: " + deviceModel } hostinfo.SetDeviceModel(deviceModel) + hostinfo.SetHostnameFn(func() (string, error) { + return a.deviceName(), nil + }) type configPair struct { rcfg *router.Config diff --git a/libtailscale/tailscale.go b/libtailscale/tailscale.go index f3c6938a8f..0c22a6e7a3 100644 --- a/libtailscale/tailscale.go +++ b/libtailscale/tailscale.go @@ -88,9 +88,9 @@ func (a *App) osVersion() string { return version } -// modelName return the MANUFACTURER + MODEL from +// deviceName returns the user-set name if available, or MANUFACTURER + MODEL from // android.os.Build. -func (a *App) modelName() string { +func (a *App) deviceName() string { model, err := a.appCtx.GetDeviceName() if err != nil { panic(err)