hostinfo,distro: Identify Western Digital MyCloud devices.

root@WDMyCloud HD_a2 # ./tailscale debug hostinfo
{
  "IPNVersion": "1.25.0-dev20220605-t7fea52e02",
  "OS": "linux",
  "OSVersion": "5.22.113",
  "Desktop": false,
  "DeviceModel": "WD My Cloud Gen2: Marvell Armada 375",
  "Hostname": "WDMyCloud",
  "GoArch": "arm"
}

Updates https://github.com/tailscale/tailscale/issues/4622

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:
Denton Gentry 2022-06-04 21:34:06 -07:00 committed by Denton Gentry
parent 0687195bee
commit c6ac82e3a6
2 changed files with 19 additions and 10 deletions

View File

@ -37,6 +37,7 @@ func linuxDeviceModel() string {
// Otherwise, try the Devicetree model, usually set on // Otherwise, try the Devicetree model, usually set on
// ARM SBCs, etc. // ARM SBCs, etc.
// Example: "Raspberry Pi 4 Model B Rev 1.2" // Example: "Raspberry Pi 4 Model B Rev 1.2"
// Example: "WD My Cloud Gen2: Marvell Armada 375"
"/sys/firmware/devicetree/base/model", // Raspberry Pi 4 Model B Rev 1.2" "/sys/firmware/devicetree/base/model", // Raspberry Pi 4 Model B Rev 1.2"
} { } {
b, _ := os.ReadFile(path) b, _ := os.ReadFile(path)
@ -55,6 +56,9 @@ func osVersionLinux() string {
propFile = "/etc.defaults/VERSION" propFile = "/etc.defaults/VERSION"
case distro.OpenWrt: case distro.OpenWrt:
propFile = "/etc/openwrt_release" propFile = "/etc/openwrt_release"
case distro.WDMyCloud:
slurp, _ := ioutil.ReadFile("/etc/version")
return fmt.Sprintf("%s", string(bytes.TrimSpace(slurp)))
} }
m := map[string]string{} m := map[string]string{}

View File

@ -14,16 +14,17 @@
type Distro string type Distro string
const ( const (
Debian = Distro("debian") Debian = Distro("debian")
Arch = Distro("arch") Arch = Distro("arch")
Synology = Distro("synology") Synology = Distro("synology")
OpenWrt = Distro("openwrt") OpenWrt = Distro("openwrt")
NixOS = Distro("nixos") NixOS = Distro("nixos")
QNAP = Distro("qnap") QNAP = Distro("qnap")
Pfsense = Distro("pfsense") Pfsense = Distro("pfsense")
OPNsense = Distro("opnsense") OPNsense = Distro("opnsense")
TrueNAS = Distro("truenas") TrueNAS = Distro("truenas")
Gokrazy = Distro("gokrazy") Gokrazy = Distro("gokrazy")
WDMyCloud = Distro("wdmycloud")
) )
var distroAtomic atomic.Value // of Distro var distroAtomic atomic.Value // of Distro
@ -73,6 +74,10 @@ func linuxDistro() Distro {
return QNAP return QNAP
case haveDir("/gokrazy"): case haveDir("/gokrazy"):
return Gokrazy return Gokrazy
case have("/usr/local/wdmcserver/bin/wdmc.xml"): // Western Digital MyCloud OS3
return WDMyCloud
case have("/usr/sbin/wd_crontab.sh"): // Western Digital MyCloud OS5
return WDMyCloud
} }
return "" return ""
} }