mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-05 12:10:52 +02:00
add peers to exit node
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
|||||||
verifyExitNodeOrgAccess
|
verifyExitNodeOrgAccess
|
||||||
} from "#dynamic/lib/exitNodes";
|
} from "#dynamic/lib/exitNodes";
|
||||||
import { getUniqueSubnetForExitNode } from "@server/lib/exitNodes";
|
import { getUniqueSubnetForExitNode } from "@server/lib/exitNodes";
|
||||||
|
import { addPeer } from "../gerbil/peers";
|
||||||
|
|
||||||
const HOLEPUNCH_STALE_CHAIN_THRESHOLD = 18;
|
const HOLEPUNCH_STALE_CHAIN_THRESHOLD = 18;
|
||||||
const HOLEPUNCH_STALE_CHAIN_TTL_SECONDS = 1800;
|
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;
|
let staleHolePunchChainCount: number | undefined;
|
||||||
const hasChainId =
|
const hasChainId =
|
||||||
chainId !== undefined && chainId !== null && String(chainId) !== "";
|
chainId !== undefined && chainId !== null && String(chainId) !== "";
|
||||||
@@ -490,7 +503,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
|||||||
endpoint: `${exitNode.endpoint}:${exitNode.listenPort}`,
|
endpoint: `${exitNode.endpoint}:${exitNode.listenPort}`,
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
serverIP: exitNode.address.split("/")[0],
|
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,
|
: undefined,
|
||||||
chainId: chainId
|
chainId: chainId
|
||||||
|
|||||||
Reference in New Issue
Block a user