Browse Source

temp

pull/1666/head
Bernd Storath 6 months ago
parent
commit
1efbc08a29
  1. 2
      src/app/components/ClientCard/OneTimeLink.vue
  2. 1
      src/app/pages/setup/4.vue
  3. 1
      src/app/pages/setup/migrate.vue
  4. 6
      src/server/utils/WireGuard.ts
  5. 5
      src/shared/utils/time.ts

2
src/app/components/ClientCard/OneTimeLink.vue

@ -13,7 +13,7 @@ const timer = ref<NodeJS.Timeout | null>(null);
const { localeProperties } = useI18n(); const { localeProperties } = useI18n();
onMounted(() => { onMounted(() => {
timer.value = setInterval(() => { timer.value = setIntervalImmediately(() => {
if (props.client.oneTimeLink === null) { if (props.client.oneTimeLink === null) {
return; return;
} }

1
src/app/pages/setup/4.vue

@ -50,6 +50,7 @@ const _submit = useSubmit(
await navigateTo('/setup/success'); await navigateTo('/setup/success');
} }
}, },
noSuccessToast: true,
} }
); );

1
src/app/pages/setup/migrate.vue

@ -42,6 +42,7 @@ const _submit = useSubmit(
await navigateTo('/setup/success'); await navigateTo('/setup/success');
} }
}, },
noSuccessToast: true,
} }
); );

6
src/server/utils/WireGuard.ts

@ -180,12 +180,11 @@ class WireGuard {
// TODO: handle as worker_thread // TODO: handle as worker_thread
async startCronJob() { async startCronJob() {
await this.cronJob().catch((err) => { setIntervalImmediately(() => {
this.cronJob().catch((err) => {
WG_DEBUG('Running Cron Job failed.'); WG_DEBUG('Running Cron Job failed.');
console.error(err); console.error(err);
}); });
setTimeout(() => {
this.startCronJob();
}, 60 * 1000); }, 60 * 1000);
} }
@ -214,7 +213,6 @@ class WireGuard {
client.oneTimeLink !== null && client.oneTimeLink !== null &&
new Date() > new Date(client.oneTimeLink.expiresAt) new Date() > new Date(client.oneTimeLink.expiresAt)
) { ) {
console.log(client);
WG_DEBUG(`Client ${client.id} One Time Link expired.`); WG_DEBUG(`Client ${client.id} One Time Link expired.`);
await Database.oneTimeLinks.delete(client.oneTimeLink.id); await Database.oneTimeLinks.delete(client.oneTimeLink.id);
} }

5
src/shared/utils/time.ts

@ -8,3 +8,8 @@ export function isPeerConnected(client: { latestHandshakeAt: Date | null }) {
// connected if last handshake was less than 10 minutes ago // connected if last handshake was less than 10 minutes ago
return lastHandshakeMs < 1000 * 60 * 10; return lastHandshakeMs < 1000 * 60 * 10;
} }
export function setIntervalImmediately(func: () => void, interval: number) {
func();
return setInterval(func, interval);
}

Loading…
Cancel
Save