From 67a69a5878eea0b85407eec59e3743dd4edc53d5 Mon Sep 17 00:00:00 2001 From: Conner Hnatiuk <46903591+ConnerWithAnE@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:52:58 -0600 Subject: [PATCH] Fix: wg-easy threshold not properly computed (#3574) --- src/widgets/wgeasy/component.jsx | 2 +- src/widgets/wgeasy/proxy.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/widgets/wgeasy/component.jsx b/src/widgets/wgeasy/component.jsx index 0289d48c4..624002c4f 100644 --- a/src/widgets/wgeasy/component.jsx +++ b/src/widgets/wgeasy/component.jsx @@ -28,7 +28,7 @@ export default function Component({ service }) { const enabled = infoData.filter((item) => item.enabled).length; const disabled = infoData.length - enabled; - const connectionThreshold = widget.threshold ?? 2 * 60 * 1000; + const connectionThreshold = (widget.threshold ?? 2) * 60 * 1000; const currentTime = new Date(); const connected = infoData.filter( (item) => currentTime - new Date(item.latestHandshakeAt) < connectionThreshold, diff --git a/src/widgets/wgeasy/proxy.js b/src/widgets/wgeasy/proxy.js index ec733475e..63338f138 100644 --- a/src/widgets/wgeasy/proxy.js +++ b/src/widgets/wgeasy/proxy.js @@ -21,14 +21,21 @@ async function login(widget, service) { }); try { - const connectSidCookie = responseHeaders["set-cookie"] + const connectSidCookie = responseHeaders["set-cookie"]; + if (!connectSidCookie) { + const sid = cache.get(`${sessionSIDCacheKey}.${service}`); + if (sid) { + return sid; + } + } + connectSidCookie = connectSidCookie .find((cookie) => cookie.startsWith("connect.sid=")) .split(";")[0] .replace("connect.sid=", ""); cache.put(`${sessionSIDCacheKey}.${service}`, connectSidCookie); return connectSidCookie; } catch (e) { - logger.error(`Error logging into wg-easy`); + logger.error(`Error logging into wg-easy, error: ${e}`); cache.del(`${sessionSIDCacheKey}.${service}`); return null; }