From 1fc97158885414f45273a6da4adcd39c260ca242 Mon Sep 17 00:00:00 2001 From: Kevin L'Hereec Date: Fri, 17 Jul 2026 11:57:09 +0200 Subject: [PATCH] fix: display IPv6 address in device table and disable wassup provider - Home.vue: add getIpAddress() with IPv4/IPv6 fallback chain (TR-098, TR-181) hoisted regex constants, prefer interface index 1, format IPv6 with brackets - config/references.json: disable wassup provider (mock URL unreachable) --- config/references.json | 2 +- inertia/pages/Home.vue | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/config/references.json b/config/references.json index d697208..075ce4c 100644 --- a/config/references.json +++ b/config/references.json @@ -3,7 +3,7 @@ { "name": "wassup", "type": "wassup", - "enabled": true, + "enabled": false, "url": "http://wassup-mock:9999", "timeout": 3000, "trigger": ["BOOT", "BOOTSTRAP"], diff --git a/inertia/pages/Home.vue b/inertia/pages/Home.vue index 1576597..c5ad335 100644 --- a/inertia/pages/Home.vue +++ b/inertia/pages/Home.vue @@ -56,6 +56,46 @@ function getPropertyValue(props: any[], name: string): string { return prop?.value ?? '' } +// Hoisted regex constants — compiled once, not on every call +const RE_IPV4 = /^Device\.IP\.Interface\.\d+\.IPv4Address\.\d+\.IPAddress$/ +const RE_IPV6 = /^Device\.IP\.Interface\.\d+\.IPv6Address\.\d+\.IPAddress$/ + +function getIpAddress(parameters: any[], properties: any[]): string { + // Priority 1 : TR-098 ExternalIPAddress (reuse existing helpers to avoid duplication) + const tr098Paths = [ + 'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress', + 'Device.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress', + ] + for (const path of tr098Paths) { + const v = getParameterValue(parameters, path) || getPropertyValue(properties, path) + if (v) return v + } + + // Priority 2 : TR-181 IPv4 — prefer index 1, then any index + const ipv4Exact = + getParameterValue(parameters, 'Device.IP.Interface.1.IPv4Address.1.IPAddress') || + getPropertyValue(properties, 'Device.IP.Interface.1.IPv4Address.1.IPAddress') + if (ipv4Exact) return ipv4Exact + + const ipv4Any = + parameters?.find((p: any) => RE_IPV4.test(p.name) && p.value) || + properties?.find((p: any) => RE_IPV4.test(p.name) && p.value) + if (ipv4Any) return ipv4Any.value + + // Priority 3 : TR-181 IPv6 — prefer index 1, then any index (displayed with brackets) + const ipv6Exact = + getParameterValue(parameters, 'Device.IP.Interface.1.IPv6Address.1.IPAddress') || + getPropertyValue(properties, 'Device.IP.Interface.1.IPv6Address.1.IPAddress') + if (ipv6Exact) return `[${ipv6Exact}]` + + const ipv6Any = + parameters?.find((p: any) => RE_IPV6.test(p.name) && p.value) || + properties?.find((p: any) => RE_IPV6.test(p.name) && p.value) + if (ipv6Any) return `[${ipv6Any.value}]` + + return '—' +} + function goToDevice(identifier: string) { router.visit(`/devices/${encodeURIComponent(identifier)}`) } @@ -141,7 +181,7 @@ async function deleteSelected() { {{ device.deviceId?.manufacturer }} {{ device.deviceId?.productClass }} {{ device.deviceId?.serialNumber }} - {{ getParameterValue(device.parameters, 'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress') || getPropertyValue(device.properties, 'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress') || getParameterValue(device.parameters, 'Device.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress') || getPropertyValue(device.properties, 'Device.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress') || getParameterValue(device.parameters, 'Device.IP.Interface.1.IPv4Address.1.IPAddress') || getPropertyValue(device.properties, 'Device.IP.Interface.1.IPv4Address.1.IPAddress') || '—' }} + {{ getIpAddress(device.parameters, device.properties) }} {{ getPropertyValue(device.properties, 'InternetGatewayDevice.DeviceInfo.SoftwareVersion') || getPropertyValue(device.properties, 'Device.DeviceInfo.SoftwareVersion') || '—' }}