mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-01 10:11:27 +02:00
Get exit node every time
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user