Switch to update

This commit is contained in:
Owen
2025-11-20 16:08:03 -05:00
parent 9420b41e39
commit 7ac27b3883
2 changed files with 46 additions and 13 deletions

View File

@@ -86,3 +86,33 @@ export async function removeRemoteSubnets(
}
});
}
export async function updateRemoteSubnets(
clientId: number,
siteId: number,
remoteSubnets: {
oldRemoteSubnets: string[],
newRemoteSubnets: string[]
},
olmId?: string
) {
if (!olmId) {
const [olm] = await db
.select()
.from(olms)
.where(eq(olms.clientId, clientId))
.limit(1);
if (!olm) {
throw new Error(`Olm with ID ${clientId} not found`);
}
olmId = olm.olmId;
}
await sendToClient(olmId, {
type: `olm/wg/peer/update-remote-subnets`,
data: {
siteId: siteId,
...remoteSubnets
}
});
}