From cf90312089c6f1cd91c460c68b93922f79365eec Mon Sep 17 00:00:00 2001 From: Oleh Astappiev Date: Mon, 17 Feb 2025 02:10:16 +0100 Subject: [PATCH] Fixhancement: add an option to fritzbox widget to display IPv6 (#4778) Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> --- docs/widgets/services/fritzbox.md | 2 +- public/locales/en/common.json | 4 +++- src/widgets/fritzbox/component.jsx | 4 ++++ src/widgets/fritzbox/proxy.js | 11 ++++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/widgets/services/fritzbox.md b/docs/widgets/services/fritzbox.md index 8cf7deea..258b094b 100644 --- a/docs/widgets/services/fritzbox.md +++ b/docs/widgets/services/fritzbox.md @@ -13,7 +13,7 @@ Home Network > Network > Network Settings > Access Settings in the Home Network Credentials are not needed and, as such, you may want to consider using `http` instead of `https` as those requests are significantly faster. -Allowed fields (limited to a max of 4): `["connectionStatus", "uptime", "maxDown", "maxUp", "down", "up", "received", "sent", "externalIPAddress"]`. +Allowed fields (limited to a max of 4): `["connectionStatus", "uptime", "maxDown", "maxUp", "down", "up", "received", "sent", "externalIPAddress", "externalIPv6Address", "externalIPv6Prefix"]`. ```yaml widget: diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 0674d6be..9e390867 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -148,7 +148,9 @@ "up": "Up", "received": "Received", "sent": "Sent", - "externalIPAddress": "Ext. IP" + "externalIPAddress": "Ext. IP", + "externalIPv6Address": "Ext. IPv6", + "externalIPv6Prefix": "Ext. IPv6-Prefix" }, "caddy": { "upstreams": "Upstreams", diff --git a/src/widgets/fritzbox/component.jsx b/src/widgets/fritzbox/component.jsx index c3ea1bf6..cacd74c2 100644 --- a/src/widgets/fritzbox/component.jsx +++ b/src/widgets/fritzbox/component.jsx @@ -37,6 +37,8 @@ export default function Component({ service }) { + + ); } @@ -52,6 +54,8 @@ export default function Component({ service }) { + + ); } diff --git a/src/widgets/fritzbox/proxy.js b/src/widgets/fritzbox/proxy.js index d1a66d97..20521560 100644 --- a/src/widgets/fritzbox/proxy.js +++ b/src/widgets/fritzbox/proxy.js @@ -70,14 +70,21 @@ export default async function fritzboxProxyHandler(req, res) { const requestLinkProperties = ["maxDown", "maxUp"].some((field) => serviceWidget.fields.includes(field)); const requestAddonInfos = ["down", "up", "received", "sent"].some((field) => serviceWidget.fields.includes(field)); const requestExternalIPAddress = ["externalIPAddress"].some((field) => serviceWidget.fields.includes(field)); + const requestExternalIPv6Address = ["externalIPv6Address"].some((field) => serviceWidget.fields.includes(field)); + const requestExternalIPv6Prefix = ["externalIPv6Prefix"].some((field) => serviceWidget.fields.includes(field)); await Promise.all([ + // as per http://fritz.box:49000/igddesc.xml specifications (fritz.box is a hostname of your router) requestStatusInfo ? requestEndpoint(apiBaseUrl, "WANIPConnection", "GetStatusInfo") : null, requestLinkProperties ? requestEndpoint(apiBaseUrl, "WANCommonInterfaceConfig", "GetCommonLinkProperties") : null, requestAddonInfos ? requestEndpoint(apiBaseUrl, "WANCommonInterfaceConfig", "GetAddonInfos") : null, requestExternalIPAddress ? requestEndpoint(apiBaseUrl, "WANIPConnection", "GetExternalIPAddress") : null, + requestExternalIPv6Address + ? requestEndpoint(apiBaseUrl, "WANIPConnection", "X_AVM_DE_GetExternalIPv6Address") + : null, + requestExternalIPv6Prefix ? requestEndpoint(apiBaseUrl, "WANIPConnection", "X_AVM_DE_GetIPv6Prefix") : null, ]) - .then(([statusInfo, linkProperties, addonInfos, externalIPAddress]) => { + .then(([statusInfo, linkProperties, addonInfos, externalIPAddress, externalIPv6Address, externalIPv6Prefix]) => { res.status(200).json({ connectionStatus: statusInfo?.NewConnectionStatus || "Unconfigured", uptime: statusInfo?.NewUptime || 0, @@ -88,6 +95,8 @@ export default async function fritzboxProxyHandler(req, res) { received: addonInfos?.NewX_AVM_DE_TotalBytesReceived64 || 0, sent: addonInfos?.NewX_AVM_DE_TotalBytesSent64 || 0, externalIPAddress: externalIPAddress?.NewExternalIPAddress || null, + externalIPv6Address: externalIPv6Address?.NewExternalIPv6Address || null, + externalIPv6Prefix: externalIPv6Prefix?.NewIPv6Prefix || null, }); }) .catch((error) => {