mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 22:13:39 +01:00
Fix: wg-easy threshold not properly computed (#3574)
This commit is contained in:
parent
19c3ac0d7e
commit
67a69a5878
@ -28,7 +28,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const enabled = infoData.filter((item) => item.enabled).length;
|
const enabled = infoData.filter((item) => item.enabled).length;
|
||||||
const disabled = infoData.length - enabled;
|
const disabled = infoData.length - enabled;
|
||||||
const connectionThreshold = widget.threshold ?? 2 * 60 * 1000;
|
const connectionThreshold = (widget.threshold ?? 2) * 60 * 1000;
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
const connected = infoData.filter(
|
const connected = infoData.filter(
|
||||||
(item) => currentTime - new Date(item.latestHandshakeAt) < connectionThreshold,
|
(item) => currentTime - new Date(item.latestHandshakeAt) < connectionThreshold,
|
||||||
|
@ -21,14 +21,21 @@ async function login(widget, service) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
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="))
|
.find((cookie) => cookie.startsWith("connect.sid="))
|
||||||
.split(";")[0]
|
.split(";")[0]
|
||||||
.replace("connect.sid=", "");
|
.replace("connect.sid=", "");
|
||||||
cache.put(`${sessionSIDCacheKey}.${service}`, connectSidCookie);
|
cache.put(`${sessionSIDCacheKey}.${service}`, connectSidCookie);
|
||||||
return connectSidCookie;
|
return connectSidCookie;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Error logging into wg-easy`);
|
logger.error(`Error logging into wg-easy, error: ${e}`);
|
||||||
cache.del(`${sessionSIDCacheKey}.${service}`);
|
cache.del(`${sessionSIDCacheKey}.${service}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user