feat: VLAN in FDB, persist vlan, enrich port-devices with hostname, UI columns

Made-with: Cursor
This commit is contained in:
PTah
2026-04-13 12:38:05 +10:00
parent 927110167c
commit 886300b6c0
8 changed files with 91 additions and 26 deletions
+23 -1
View File
@@ -364,8 +364,30 @@ func (h *Handler) getScanPortDevices(w http.ResponseWriter, r *http.Request) {
}
limit = n
}
snmpItems := h.store.ListSNMPResults(id, 200000)
ipToName := make(map[string]string, len(snmpItems))
for _, s := range snmpItems {
if !s.Success {
continue
}
name := strings.TrimSpace(s.SysName)
if name == "" {
continue
}
if _, ok := ipToName[s.IP]; !ok {
ipToName[s.IP] = name
}
}
items := h.store.ListPortDeviceResults(id, ip, ifIndex, limit)
for i := range items {
if lip := strings.TrimSpace(items[i].LearnedIP); lip != "" {
if nm, ok := ipToName[lip]; ok {
items[i].Hostname = nm
}
}
}
writeJSON(w, http.StatusOK, map[string]any{
"items": h.store.ListPortDeviceResults(id, ip, ifIndex, limit),
"items": items,
})
}