Move up client reject

This commit is contained in:
Owen
2025-04-01 22:49:08 -04:00
parent 8c267489c7
commit 7faf1fba8b

View File

@@ -13,9 +13,12 @@ import { addPeer, deletePeer } from "../newt/peers";
import logger from "@server/logger"; import logger from "@server/logger";
export const handleOlmRegisterMessage: MessageHandler = async (context) => { export const handleOlmRegisterMessage: MessageHandler = async (context) => {
logger.info("Handling register olm message!");
const { message, client: c, sendToClient } = context; const { message, client: c, sendToClient } = context;
const olm = c as Olm; const olm = c as Olm;
logger.info("Handling register olm message!");
const now = new Date().getTime() / 1000;
if (!olm) { if (!olm) {
logger.warn("Olm not found"); logger.warn("Olm not found");
return; return;
@@ -60,6 +63,10 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
}); });
} }
if (client.lastHolePunch && now - client.lastHolePunch > 6) {
logger.warn("Client last hole punch is too old, skipping all sites");
}
// Update the client's public key // Update the client's public key
await db await db
.update(clients) .update(clients)
@@ -81,7 +88,6 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
// Prepare an array to store site configurations // Prepare an array to store site configurations
const siteConfigurations = []; const siteConfigurations = [];
const now = new Date().getTime() / 1000;
// Process each site // Process each site
for (const { sites: site } of sitesData) { for (const { sites: site } of sitesData) {
@@ -105,13 +111,6 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
continue; continue;
} }
if (client.lastHolePunch && now - client.lastHolePunch > 6) {
logger.warn(
"Client last hole punch is too old, skipping all sites"
);
break;
}
// If public key changed, delete old peer from this site // If public key changed, delete old peer from this site
if (pubKeyChanged) { if (pubKeyChanged) {
logger.info( logger.info(