Get exit node every time

This commit is contained in:
Owen
2026-07-31 15:17:16 -04:00
parent 4d7a4c809d
commit df7bb2fb57
+14 -6
View File
@@ -1,4 +1,4 @@
import { db, ExitNode, orgs, primaryDb } from "@server/db"; import { db, ExitNode, exitNodes, orgs, primaryDb } from "@server/db";
import { MessageHandler } from "@server/routers/ws"; import { MessageHandler } from "@server/routers/ws";
import { import {
clients, clients,
@@ -311,15 +311,14 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
} }
let clientSubnet = client.exitNodeSubnet; let clientSubnet = client.exitNodeSubnet;
let exitNode: ExitNode | null = null;
if ( if (
exitNodeId && exitNodeId &&
(client.exitNodeId !== exitNodeId || !client.exitNodeSubnet) (client.exitNodeId !== exitNodeId || !client.exitNodeSubnet)
) { ) {
const { exitNode: exitNodeResult, hasAccess } = const { exitNode, hasAccess } = await verifyExitNodeOrgAccess(
await verifyExitNodeOrgAccess(exitNodeId, client.orgId); exitNodeId,
client.orgId
exitNode = exitNodeResult; );
if (!exitNode) { if (!exitNode) {
logger.warn("[handleOlmRegisterMessage] Exit node not found", { logger.warn("[handleOlmRegisterMessage] Exit node not found", {
@@ -451,6 +450,15 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
return; return;
} }
let exitNode: ExitNode | null = null;
if (exitNodeId) {
[exitNode] = await db
.select()
.from(exitNodes)
.where(eq(exitNodes.exitNodeId, exitNodeId))
.limit(1);
}
// NOTE: its important that the client here is the old client and the public key is the new key // NOTE: its important that the client here is the old client and the public key is the new key
await waitForClientRebuildIdle(olm.clientId); await waitForClientRebuildIdle(olm.clientId);