From 09b2671759791e2c57ef38ad530c3f6b58979dbf Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 1 Jun 2026 13:57:54 -0700 Subject: [PATCH] Send hp error to olm --- server/routers/olm/error.ts | 8 ++++++++ server/routers/olm/handleOlmRegisterMessage.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/server/routers/olm/error.ts b/server/routers/olm/error.ts index 6ea209cea..15047b94c 100644 --- a/server/routers/olm/error.ts +++ b/server/routers/olm/error.ts @@ -1,4 +1,8 @@ import { sendToClient } from "#dynamic/routers/ws"; +import config from "@server/lib/config"; + +const udpPort = config.getRawConfig().gerbil.clients_start_port; + // Error codes for registration failures export const OlmErrorCodes = { OLM_NOT_FOUND: { @@ -86,6 +90,10 @@ export const OlmErrorCodes = { TERMINATED_BLOCKED: { code: "TERMINATED_BLOCKED", message: "This session was terminated because access was blocked." + }, + HOLEPUNCH_MISSING: { + code: "HOLEPUNCH_MISSING", + message: `Hole punch information is missing. Please ensure your client can reach the server on UDP port ${udpPort} and try registering again.` } } as const; diff --git a/server/routers/olm/handleOlmRegisterMessage.ts b/server/routers/olm/handleOlmRegisterMessage.ts index 7735e4d30..747770bff 100644 --- a/server/routers/olm/handleOlmRegisterMessage.ts +++ b/server/routers/olm/handleOlmRegisterMessage.ts @@ -327,6 +327,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => { `[handleOlmRegisterMessage] Client last hole punch is too old and we have sites to send; skipping this register. The client is failing to hole punch and identify its network address with the server. Can the client reach the server on UDP port ${config.getRawConfig().gerbil.clients_start_port}?`, { orgId: client.orgId, clientId: client.clientId } ); + sendOlmError(OlmErrorCodes.HOLEPUNCH_MISSING, olm.olmId); return; }