Pārlūkot izejas kodu

feat(devices): show the VLAN a client sits on, in the list and the detail (#2178) (#2278)

Nacho 3 dienas atpakaļ
vecāks
revīzija
2c3eaf4978

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@ y este proyecto se adhiere a [Versionado Semántico](https://semver.org/lang/es/
 
 
 ### Added
 ### Added
 
 
+- The client list and the device detail show the VLAN a device sits on when a source resolves it (the bridge FDB for wired and bridged clients, the `tag=` of a Proxmox guest), and the detail keeps the difference between "no VLAN known" and "not in any VLAN". The identity was already MAC-based, so a device that moves between VLANs keeps its row and the badge follows; what was missing was the number on screen. The topology already coloured chips by VLAN, this closes the same gap in the list (#2178).
 - The native agent fills the WAN IPv6 it already had in hand: `ipv6-address` comes in the same ubus dump as the IPv4, and the parser now publishes the first global address (link-local and ULA skipped, a deprecated address only when nothing else is left) in `data.wan.ipv6`. A modem uplink gets it from the child netifd creates for it, and an uplink with no IPv4 still reports its v6. The SSH poller shares the parser, so both paths gain it at once, and a router without v6 keeps the field absent (#2275).
 - The native agent fills the WAN IPv6 it already had in hand: `ipv6-address` comes in the same ubus dump as the IPv4, and the parser now publishes the first global address (link-local and ULA skipped, a deprecated address only when nothing else is left) in `data.wan.ipv6`. A modem uplink gets it from the child netifd creates for it, and an uplink with no IPv4 still reports its v6. The SSH poller shares the parser, so both paths gain it at once, and a router without v6 keeps the field absent (#2275).
 - The WAN section accepts an optional `ipv6` field, so an external pusher that reads the uplink's global IPv6 (the gfiber pusher does) can push it instead of journalling it. The server passes it through to the WAN panel and to the WAN port tile, and a unit that reports only IPv6 keeps its address instead of being treated as having no WAN data (#2226). Thanks to @brainnoms for the contract.
 - The WAN section accepts an optional `ipv6` field, so an external pusher that reads the uplink's global IPv6 (the gfiber pusher does) can push it instead of journalling it. The server passes it through to the WAN panel and to the WAN port tile, and a unit that reports only IPv6 keeps its address instead of being treated as having no WAN data (#2226). Thanks to @brainnoms for the contract.
 - The vendor catalog accepts a third mode, `node`, for pushers that must run on the monitored host itself: a Kubernetes node that reads its own kubelet and `/proc`, a Docker host, a storage box. The Integrations page registers the row, issues the token and shows the environment to set, and the server never downloads, installs, starts or stops anything there. Start and stop answer `not_managed`, update only refreshes the published version so the page can point at the download, edit keeps to the label and the interval, and the row stays `pending` until the pusher's first push makes it live (#2272).
 - The vendor catalog accepts a third mode, `node`, for pushers that must run on the monitored host itself: a Kubernetes node that reads its own kubelet and `/proc`, a Docker host, a storage box. The Integrations page registers the row, issues the token and shows the environment to set, and the server never downloads, installs, starts or stops anything there. Start and stop answer `not_managed`, update only refreshes the published version so the page can point at the download, edit keeps to the label and the interval, and the row stays `pending` until the pusher's first push makes it live (#2272).

+ 3 - 0
app/public/locales/en/translation.json

@@ -483,6 +483,9 @@
       },
       },
       "dhcpLease": "DHCP lease",
       "dhcpLease": "DHCP lease",
       "firstSeen": "First seen",
       "firstSeen": "First seen",
+      "vlan": "VLAN",
+      "vlanNone": "No VLAN",
+      "vlanTip": "VLAN {{id}}",
       "lastSeen": "Last seen",
       "lastSeen": "Last seen",
       "infra": "Infrastructure",
       "infra": "Infrastructure",
       "manufacturer": "Manufacturer (OUI)",
       "manufacturer": "Manufacturer (OUI)",

+ 3 - 0
app/public/locales/es/translation.json

@@ -483,6 +483,9 @@
       },
       },
       "dhcpLease": "Concesión DHCP",
       "dhcpLease": "Concesión DHCP",
       "firstSeen": "Primera vez vista",
       "firstSeen": "Primera vez vista",
+      "vlan": "VLAN",
+      "vlanNone": "Sin VLAN",
+      "vlanTip": "VLAN {{id}}",
       "lastSeen": "Última vez vista",
       "lastSeen": "Última vez vista",
       "infra": "Infraestructura",
       "infra": "Infraestructura",
       "manufacturer": "Fabricante (OUI)",
       "manufacturer": "Fabricante (OUI)",

+ 3 - 0
app/public/locales/ru/translation.json

@@ -497,6 +497,9 @@
       },
       },
       "dhcpLease": "Аренда DHCP",
       "dhcpLease": "Аренда DHCP",
       "firstSeen": "Первое появление",
       "firstSeen": "Первое появление",
+      "vlan": "VLAN",
+      "vlanNone": "Без VLAN",
+      "vlanTip": "VLAN {{id}}",
       "lastSeen": "Последнее появление",
       "lastSeen": "Последнее появление",
       "infra": "Инфраструктура",
       "infra": "Инфраструктура",
       "manufacturer": "Производитель (OUI)",
       "manufacturer": "Производитель (OUI)",

+ 3 - 0
app/public/locales/zh/translation.json

@@ -390,6 +390,9 @@
       },
       },
       "dhcpLease": "DHCP 租约",
       "dhcpLease": "DHCP 租约",
       "firstSeen": "首次发现",
       "firstSeen": "首次发现",
+      "vlan": "VLAN",
+      "vlanNone": "无 VLAN",
+      "vlanTip": "VLAN {{id}}",
       "lastSeen": "最近发现",
       "lastSeen": "最近发现",
       "infra": "基础设施",
       "infra": "基础设施",
       "manufacturer": "厂商(OUI)",
       "manufacturer": "厂商(OUI)",

+ 6 - 0
app/src/components/DeviceRow.tsx

@@ -278,6 +278,12 @@ export function DeviceRow({ device, variant = 'compact', className, onClick }: D
               {t('devices.new')}
               {t('devices.new')}
             </span>
             </span>
           )}
           )}
+          {/* #2178: VLAN del cliente cuando una fuente la resuelve. */}
+          {device.vlan !== undefined && device.vlan > 0 && (
+            <span className="shrink-0 rounded border border-border px-1 font-mono text-[10px] text-text-muted">
+              {t('devices.detail.vlan')} {device.vlan}
+            </span>
+          )}
           {/* NETPULSE-ONE-LEGION: badge del agente facet caído (la caja
           {/* NETPULSE-ONE-LEGION: badge del agente facet caído (la caja
               plegada nunca vuelve; el device lleva la noticia). */}
               plegada nunca vuelve; el device lleva la noticia). */}
           {device.facet && !device.facet.online && (
           {device.facet && !device.facet.online && (

+ 4 - 0
app/src/data/demo-canon.json

@@ -459,6 +459,8 @@
         0.4,
         0.4,
         0.4
         0.4
       ],
       ],
+      "vlan": 20,
+      "vlanKnown": true,
       "hostname": "nest-mini-estudio",
       "hostname": "nest-mini-estudio",
       "dhcpLease": "renueva en 8 h 20 min",
       "dhcpLease": "renueva en 8 h 20 min",
       "firstSeenMs": 1767484800000,
       "firstSeenMs": 1767484800000,
@@ -495,6 +497,8 @@
         2.3
         2.3
       ],
       ],
       "port": "lan4",
       "port": "lan4",
+      "vlan": 1,
+      "vlanKnown": true,
       "hostname": "diskstation",
       "hostname": "diskstation",
       "dhcpLease": "IP fija (reserva)",
       "dhcpLease": "IP fija (reserva)",
       "firstSeenMs": 1760572800000,
       "firstSeenMs": 1760572800000,

+ 24 - 0
app/src/pages/Devices.tsx

@@ -948,6 +948,18 @@ function DeviceDetail({
         </div>
         </div>
       )}
       )}
       <ConnectedToItem device={device} />
       <ConnectedToItem device={device} />
+      {/* #2178: la VLAN del cliente. Con `vlanKnown` y sin VLAN, la respuesta
+          es "no está en ninguna VLAN conocida", que no es lo mismo que no
+          saberlo (#1757): el hueco calla, el dato habla. */}
+      {(device.vlanKnown || (device.vlan ?? 0) > 0) && (
+        <DetailItem label={t('devices.detail.vlan')}>
+          {device.vlan && device.vlan > 0 ? (
+            <span className="font-mono">{device.vlan}</span>
+          ) : (
+            <span className="text-text-muted">{t('devices.detail.vlanNone')}</span>
+          )}
+        </DetailItem>
+      )}
       {infra && (
       {infra && (
         <DetailItem label={t('devices.detail.infra')}>
         <DetailItem label={t('devices.detail.infra')}>
           <InfraBadge info={infra} />
           <InfraBadge info={infra} />
@@ -1305,6 +1317,18 @@ function ListRow({
               <span className="hidden min-w-0 truncate lg:block" title={manufacturerLabel(device.manufacturer)}>{manufacturerLabel(device.manufacturer)}</span>
               <span className="hidden min-w-0 truncate lg:block" title={manufacturerLabel(device.manufacturer)}>{manufacturerLabel(device.manufacturer)}</span>
               {infra && <InfraBadge info={infra} />}
               {infra && <InfraBadge info={infra} />}
               <TypeBadge type={device.type} className="lg:hidden" />
               <TypeBadge type={device.type} className="lg:hidden" />
+              {/* #2178: la VLAN del cliente cuando una fuente la resuelve (FDB
+                  del bridge o tag= del hipervisor). Va con los badges y no en
+                  la línea del nombre: ahí robaba ancho al nombre. Sin dato no
+                  se pinta nada, que un 0 no es "VLAN 0". */}
+              {device.vlan !== undefined && device.vlan > 0 && (
+                <span
+                  className="shrink-0 rounded border border-border px-1 font-mono text-[10px] text-text-muted"
+                  title={t('devices.detail.vlanTip', { id: device.vlan })}
+                >
+                  {t('devices.detail.vlan')} {device.vlan}
+                </span>
+              )}
             </div>
             </div>
           </div>
           </div>
         </div>
         </div>

+ 4 - 0
server-go/internal/adapters/demo_dataset.go

@@ -357,12 +357,16 @@ func canonDevices() []Device {
 			SignalDbm: iptr(-55), TrafficMbps: 0.4, Online: true,
 			SignalDbm: iptr(-55), TrafficMbps: 0.4, Online: true,
 			Sparkline: []float64{0.3, 0.4, 0.4, 0.5, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4},
 			Sparkline: []float64{0.3, 0.4, 0.4, 0.5, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4},
 			Hostname:  "nest-mini-estudio", DHCPLease: "renueva en 8 h 20 min", FirstSeenMs: seenDaysAgo(240), LastSeenMs: demoSeenBaseMs,
 			Hostname:  "nest-mini-estudio", DHCPLease: "renueva en 8 h 20 min", FirstSeenMs: seenDaysAgo(240), LastSeenMs: demoSeenBaseMs,
+			// #2178: el altavoz vive en la VLAN de IoT.
+			Vlan: 20, VlanKnown: true,
 			Traffic24hRx: "1,4 GB", Traffic24hTx: "88 MB", Adguard: boolp(true), Group: "iot"},
 			Traffic24hRx: "1,4 GB", Traffic24hTx: "88 MB", Adguard: boolp(true), Group: "iot"},
 		{ID: "nas-synology", Name: "NAS Synology", Type: "servidor", Manufacturer: "Synology",
 		{ID: "nas-synology", Name: "NAS Synology", Type: "servidor", Manufacturer: "Synology",
 			IP: "192.168.8.10", MAC: "00:11:32:9C:51:B7", RouterID: "flint2", Band: "cable",
 			IP: "192.168.8.10", MAC: "00:11:32:9C:51:B7", RouterID: "flint2", Band: "cable",
 			SignalDbm: nil, TrafficMbps: 2.3, Online: true, Port: "lan4",
 			SignalDbm: nil, TrafficMbps: 2.3, Online: true, Port: "lan4",
 			Sparkline: []float64{1, 1.5, 2, 2.5, 3, 2.8, 2.4, 2.2, 2.3, 2.3, 2.3, 2.3},
 			Sparkline: []float64{1, 1.5, 2, 2.5, 3, 2.8, 2.4, 2.2, 2.3, 2.3, 2.3, 2.3},
 			Hostname:  "diskstation", DHCPLease: "IP fija (reserva)", FirstSeenMs: seenDaysAgo(320), LastSeenMs: demoSeenBaseMs,
 			Hostname:  "diskstation", DHCPLease: "IP fija (reserva)", FirstSeenMs: seenDaysAgo(320), LastSeenMs: demoSeenBaseMs,
+			// #2178: VLAN resuelta por el FDB del bridge (demo: servidores en la 1).
+			Vlan: 1, VlanKnown: true,
 			Traffic24hRx: "96 GB", Traffic24hTx: "1,1 TB", Adguard: boolp(true), Group: "red"},
 			Traffic24hRx: "96 GB", Traffic24hTx: "1,1 TB", Adguard: boolp(true), Group: "red"},
 		{ID: "galaxy-tab-s9", Name: "Galaxy Tab S9", Type: "tablet", Manufacturer: "Samsung",
 		{ID: "galaxy-tab-s9", Name: "Galaxy Tab S9", Type: "tablet", Manufacturer: "Samsung",
 			IP: "192.168.8.48", MAC: "D6:91:2F:07:B3:55", RouterID: "living", Band: "5 GHz",
 			IP: "192.168.8.48", MAC: "D6:91:2F:07:B3:55", RouterID: "living", Band: "5 GHz",