From 4999c92f8e02a905afbfebf130ad754b73a2d710 Mon Sep 17 00:00:00 2001 From: ceramicwhite Date: Mon, 30 Oct 2023 23:22:48 -0700 Subject: [PATCH] Add port_forwarded field to Gluetun widget --- docs/widgets/services/gluetun.md | 2 +- public/locales/en/common.json | 3 ++- src/widgets/gluetun/component.jsx | 9 ++++++--- src/widgets/gluetun/widget.js | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/widgets/services/gluetun.md b/docs/widgets/services/gluetun.md index 89d0057b..99cd0b29 100644 --- a/docs/widgets/services/gluetun.md +++ b/docs/widgets/services/gluetun.md @@ -5,7 +5,7 @@ description: Gluetun Widget Configuration Requires [HTTP control server options](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md) to be enabled. -Allowed fields: `["public_ip", "region", "country"]`. +Allowed fields: `["public_ip", "region", "country", "port_forwarded"]`. ```yaml widget: diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 3a3f88f1..a21fc26b 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -511,7 +511,8 @@ "gluetun": { "public_ip": "Public IP", "region": "Region", - "country": "Country" + "country": "Country", + "port_forwarded": "Port Forwarded" }, "hdhomerun": { "channels": "Channels", diff --git a/src/widgets/gluetun/component.jsx b/src/widgets/gluetun/component.jsx index c4ec14fb..47df8f31 100644 --- a/src/widgets/gluetun/component.jsx +++ b/src/widgets/gluetun/component.jsx @@ -6,17 +6,19 @@ export default function Component({ service }) { const { widget } = service; const { data: gluetunData, error: gluetunError } = useWidgetAPI(widget, "ip"); + const { data: portForwardedData, error: portForwardedError } = useWidgetAPI(widget, "port_forwarded"); - if (gluetunError) { - return ; + if (gluetunError || portForwardedError) { + return ; } - if (!gluetunData) { + if (!gluetunData || !portForwardedData) { return ( + ); } @@ -26,6 +28,7 @@ export default function Component({ service }) { + ); } diff --git a/src/widgets/gluetun/widget.js b/src/widgets/gluetun/widget.js index 013ea1ca..fbc209e0 100644 --- a/src/widgets/gluetun/widget.js +++ b/src/widgets/gluetun/widget.js @@ -9,6 +9,10 @@ const widget = { endpoint: "publicip/ip", validate: ["public_ip", "region", "country"], }, + port_forwarded: { + endpoint: "openvpn/portforwarded", + validate: ["port"], + }, }, };