add peers to exit node

This commit is contained in:
Owen
2026-08-04 15:36:40 -04:00
parent 2bf426bc22
commit ec5a2b0cbe
+14 -1
View File
@@ -28,6 +28,7 @@ import {
verifyExitNodeOrgAccess
} from "#dynamic/lib/exitNodes";
import { getUniqueSubnetForExitNode } from "@server/lib/exitNodes";
import { addPeer } from "../gerbil/peers";
const HOLEPUNCH_STALE_CHAIN_THRESHOLD = 18;
const HOLEPUNCH_STALE_CHAIN_TTL_SECONDS = 1800;
@@ -393,6 +394,18 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
);
}
if (clientSubnet && exitNodeId) {
try {
// add the peer to the exit node so it can connect
await addPeer(exitNodeId, {
publicKey: publicKey,
allowedIps: [clientSubnet]
});
} catch (error) {
logger.error(`Failed to add peer to exit node: ${error}`);
}
}
let staleHolePunchChainCount: number | undefined;
const hasChainId =
chainId !== undefined && chainId !== null && String(chainId) !== "";
@@ -490,7 +503,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
endpoint: `${exitNode.endpoint}:${exitNode.listenPort}`,
publicKey: exitNode.publicKey,
serverIP: exitNode.address.split("/")[0],
tunnelIP: client.exitNodeSubnet.split("/")[0]
tunnelIP: `${client.exitNodeSubnet.split("/")[0]}/${exitNode.address.split("/")[1]}` // we need to use the exit node's subnet mask here because the client will be using the exit node's subnet mask for its routing table so we can address it
}
: undefined,
chainId: chainId