Merge branch 'main' into dev

This commit is contained in:
Owen
2026-10-19 11:04:49 -04:00
15 changed files with 883 additions and 205 deletions
+22 -11
View File
@@ -313,6 +313,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
}
let clientSubnet = client.exitNodeSubnet;
let releaseSubnetLock: (() => Promise<void>) | null = null;
if (
exitNodeId &&
(client.exitNodeId !== exitNodeId || !client.exitNodeSubnet)
@@ -340,7 +341,8 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
// TODO: IF WE DO NOT HAVE AN INFERENCE RESOURCE DO WE NEED TO BE HOLDING A SUBNET ON THE CLIENT?
const newSubnet = await getUniqueSubnetForExitNode(exitNode);
const { value: newSubnet, release } =
await getUniqueSubnetForExitNode(exitNode);
if (!newSubnet) {
logger.error(
@@ -352,6 +354,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
}
clientSubnet = newSubnet;
releaseSubnetLock = release;
}
if (
@@ -364,16 +367,21 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
"[handleOlmRegisterMessage] Public key mismatch. Updating public key and clearing session info...",
{ orgId: client.orgId, clientId: client.clientId }
);
// Update the client's public key
await db
.update(clients)
.set({
pubKey: publicKey,
archived: false,
exitNodeId: exitNodeId, // this can be undefined if no exit node was selected, which is fine just means we cant talk to the node or connect to it
exitNodeSubnet: clientSubnet
})
.where(eq(clients.clientId, client.clientId));
try {
// Update the client's public key
await db
.update(clients)
.set({
pubKey: publicKey,
archived: false,
exitNodeId: exitNodeId, // this can be undefined if no exit node was selected, which is fine just means we cant talk to the node or connect to it
exitNodeSubnet: clientSubnet
})
.where(eq(clients.clientId, client.clientId));
} finally {
// only release once the subnet is persisted so no other node can pick it
await releaseSubnetLock?.();
}
// set isRelay to false for all of the client's sites to reset the connection metadata
await db
@@ -396,6 +404,9 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
);
}
// safety net in case a subnet was locked but the update above was skipped (release is idempotent)
await releaseSubnetLock?.();
if (client.pubKey && client.pubKey !== publicKey && client.exitNodeId) {
// test the old client to see if its different then remove
logger.info("Public key mismatch. Deleting old peer...");