diff --git a/docs/widgets/services/wgeasy.md b/docs/widgets/services/wgeasy.md index c5442081c..eb562c5a9 100644 --- a/docs/widgets/services/wgeasy.md +++ b/docs/widgets/services/wgeasy.md @@ -11,10 +11,17 @@ Note: by default `["connected", "enabled", "total"]` are displayed. To detect if a device is connected the time since the last handshake is queried. `threshold` is the time to wait in minutes since the last handshake to consider a device connected. Default is 2 minutes. +| Wg-Easy API Version | Homepage Widget Version | +| ------------------- | ----------------------- | +| < v15 | 1 (default) | +| >= v15 | 2 | + ```yaml widget: type: wgeasy url: http://wg.easy.or.ip + version: 2 # optional, default is 1 + username: yourwgusername # required for v15 and above password: yourwgeasypassword threshold: 2 # optional ``` diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 17703bbc6..3e343cbdf 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -497,7 +497,9 @@ export function cleanServiceGroups(groups) { if (snapshotHost) widget.snapshotHost = snapshotHost; if (snapshotPath) widget.snapshotPath = snapshotPath; } - if (["beszel", "glances", "immich", "komga", "mealie", "pfsense", "pihole", "speedtest"].includes(type)) { + if ( + ["beszel", "glances", "immich", "komga", "mealie", "pfsense", "pihole", "speedtest", "wgeasy"].includes(type) + ) { if (version) widget.version = parseInt(version, 10); } if (type === "glances") { diff --git a/src/utils/proxy/handlers/credentialed.js b/src/utils/proxy/handlers/credentialed.js index da92de29f..6eb4f9a95 100644 --- a/src/utils/proxy/handlers/credentialed.js +++ b/src/utils/proxy/handlers/credentialed.js @@ -101,7 +101,11 @@ export default async function credentialedProxyHandler(req, res, map) { headers.Cookie = `authenticated=${widget.key}`; } } else if (widget.type === "wgeasy") { - headers.Authorization = widget.password; + if (widget.username && widget.password) { + headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`; + } else { + headers.Authorization = widget.password; + } } else if (widget.type === "gitlab") { headers["PRIVATE-TOKEN"] = widget.key; } else if (widget.type === "speedtest") { diff --git a/src/widgets/wgeasy/component.jsx b/src/widgets/wgeasy/component.jsx index 829b120d7..338d94cc1 100644 --- a/src/widgets/wgeasy/component.jsx +++ b/src/widgets/wgeasy/component.jsx @@ -6,7 +6,9 @@ import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { widget } = service; - const { data: infoData, error: infoError } = useWidgetAPI(widget, "client"); + const endpoint = widget.version === 2 ? "clientv2" : "client"; + + const { data: infoData, error: infoError } = useWidgetAPI(widget, endpoint); if (!widget.fields) { widget.fields = ["connected", "enabled", "total"]; diff --git a/src/widgets/wgeasy/widget.js b/src/widgets/wgeasy/widget.js index c85c26920..a80351370 100644 --- a/src/widgets/wgeasy/widget.js +++ b/src/widgets/wgeasy/widget.js @@ -8,6 +8,9 @@ const widget = { client: { endpoint: "wireguard/client", }, + clientv2: { + endpoint: "client", + }, }, };