station: Default device type to "unknown" and propagate DHCP hostname
GuessDeviceType silently returned "mobile" for any device whose hostname or MAC OUI didn't match a known pattern, so the UI labelled every unidentified device as a phone. Default to "unknown" instead and broaden hostname matching (pixel/galaxy, thinkpad, imac/-pc, QEMU OUI). The hostapd backend was also dropping DHCP hostnames on the floor: the correlator only forwarded MAC->IP, and convertStation hard-coded the hostname to "". Replace UpdateIPMapping with UpdateLeaseInfo that carries both maps so hostnames flow through to ConnectedDevice.Name. Frontend gains a "Sans nom" fallback when no hostname is available and French labels for the device-type badge.
This commit is contained in:
parent
0797f7dd50
commit
a758c331c0
4 changed files with 68 additions and 35 deletions
|
|
@ -87,19 +87,26 @@ type BackendConfig struct {
|
|||
HostapdInterface string // Hostapd interface name for DBus
|
||||
}
|
||||
|
||||
// GuessDeviceType attempts to guess device type from hostname and MAC address
|
||||
// GuessDeviceType attempts to guess device type from hostname and MAC address.
|
||||
// Returns "unknown" when no signal is strong enough — the frontend renders that
|
||||
// as a neutral icon rather than mislabeling unknown devices as "mobile".
|
||||
func GuessDeviceType(hostname, mac string) string {
|
||||
hostname = strings.ToLower(hostname)
|
||||
|
||||
if strings.Contains(hostname, "iphone") || strings.Contains(hostname, "android") {
|
||||
if strings.Contains(hostname, "iphone") || strings.Contains(hostname, "android") ||
|
||||
strings.Contains(hostname, "pixel") || strings.Contains(hostname, "galaxy") {
|
||||
return "mobile"
|
||||
} else if strings.Contains(hostname, "ipad") || strings.Contains(hostname, "tablet") {
|
||||
return "tablet"
|
||||
} else if strings.Contains(hostname, "macbook") || strings.Contains(hostname, "laptop") {
|
||||
} else if strings.Contains(hostname, "macbook") || strings.Contains(hostname, "laptop") ||
|
||||
strings.Contains(hostname, "thinkpad") {
|
||||
return "laptop"
|
||||
} else if strings.Contains(hostname, "imac") || strings.Contains(hostname, "desktop") ||
|
||||
strings.Contains(hostname, "-pc") {
|
||||
return "desktop"
|
||||
}
|
||||
|
||||
// Guess by MAC prefix (OUI)
|
||||
// Guess by MAC prefix (OUI) — VM hypervisor MACs are almost always laptops
|
||||
if len(mac) >= 8 {
|
||||
macPrefix := strings.ToUpper(mac[:8])
|
||||
switch macPrefix {
|
||||
|
|
@ -107,8 +114,8 @@ func GuessDeviceType(hostname, mac string) string {
|
|||
return "laptop"
|
||||
case "08:00:27": // VirtualBox
|
||||
return "laptop"
|
||||
default:
|
||||
return "mobile"
|
||||
case "52:54:00": // QEMU/KVM
|
||||
return "laptop"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue