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
|
|
@ -81,14 +81,20 @@ func (dc *DHCPCorrelator) correlate() {
|
|||
return
|
||||
}
|
||||
|
||||
// Build MAC -> IP mapping
|
||||
// Build MAC -> IP and MAC -> hostname mappings. Hostnames live in the
|
||||
// dhcpd "client-hostname" field and let us label devices instead of
|
||||
// falling back to bare MAC addresses.
|
||||
macToIP := make(map[string]string)
|
||||
macToHostname := make(map[string]string)
|
||||
for _, lease := range leases {
|
||||
macToIP[lease.MAC] = lease.IP
|
||||
mac := strings.ToLower(lease.MAC)
|
||||
macToIP[mac] = lease.IP
|
||||
if lease.Hostname != "" {
|
||||
macToHostname[mac] = lease.Hostname
|
||||
}
|
||||
}
|
||||
|
||||
// Update backend with IP mappings
|
||||
dc.backend.UpdateIPMapping(macToIP)
|
||||
dc.backend.UpdateLeaseInfo(macToIP, macToHostname)
|
||||
}
|
||||
|
||||
// parseDHCPLeases reads and parses DHCP lease file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue