mirror of https://github.com/wg-easy/wg-easy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
447 B
15 lines
447 B
export function isPeerConnected(client: { latestHandshakeAt: Date | null }) {
|
|
if (!client.latestHandshakeAt) {
|
|
return false;
|
|
}
|
|
|
|
const lastHandshakeMs = Date.now() - client.latestHandshakeAt.getTime();
|
|
|
|
// connected if last handshake was less than 10 minutes ago
|
|
return lastHandshakeMs < 1000 * 60 * 10;
|
|
}
|
|
|
|
export function setIntervalImmediately(func: () => void, interval: number) {
|
|
func();
|
|
return setInterval(func, interval);
|
|
}
|
|
|