Fix: wg-easy threshold not properly computed (#3574)

pull/3576/head
Conner Hnatiuk 5 months ago committed by GitHub
parent 19c3ac0d7e
commit 67a69a5878
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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,

@ -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;
}

Loading…
Cancel
Save