mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-25 14:26:39 +00:00
Switch to update
This commit is contained in:
@@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user