feat: VLAN in FDB, persist vlan, enrich port-devices with hostname, UI columns
Made-with: Cursor
This commit is contained in:
+23
-1
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user