mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-11 21:26:37 +00:00
Move up client reject
This commit is contained in:
@@ -13,9 +13,12 @@ import { addPeer, deletePeer } from "../newt/peers";
|
||||
import logger from "@server/logger";
|
||||
|
||||
export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||
logger.info("Handling register olm message!");
|
||||
const { message, client: c, sendToClient } = context;
|
||||
const olm = c as Olm;
|
||||
logger.info("Handling register olm message!");
|
||||
|
||||
const now = new Date().getTime() / 1000;
|
||||
|
||||
if (!olm) {
|
||||
logger.warn("Olm not found");
|
||||
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
|
||||
await db
|
||||
.update(clients)
|
||||
@@ -81,7 +88,6 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||
|
||||
// Prepare an array to store site configurations
|
||||
const siteConfigurations = [];
|
||||
const now = new Date().getTime() / 1000;
|
||||
|
||||
// Process each site
|
||||
for (const { sites: site } of sitesData) {
|
||||
@@ -105,13 +111,6 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||
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 (pubKeyChanged) {
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user