mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 01:55:10 +02:00
Fix relay ws message
This commit is contained in:
parent
11cdfa7557
commit
1baa02de89
2 changed files with 43 additions and 25 deletions
|
@ -49,4 +49,30 @@ export async function deletePeer(siteId: number, publicKey: string) {
|
|||
});
|
||||
|
||||
logger.info(`Deleted peer ${publicKey} from newt ${newt.newtId}`);
|
||||
}
|
||||
|
||||
export async function updatePeer(siteId: number, publicKey: string, peer: {
|
||||
allowedIps?: string[];
|
||||
endpoint?: string;
|
||||
}) {
|
||||
const [site] = await db.select().from(sites).where(eq(sites.siteId, siteId)).limit(1);
|
||||
if (!site) {
|
||||
throw new Error(`Exit node with ID ${siteId} not found`);
|
||||
}
|
||||
|
||||
// get the newt on the site
|
||||
const [newt] = await db.select().from(newts).where(eq(newts.siteId, siteId)).limit(1);
|
||||
if (!newt) {
|
||||
throw new Error(`Newt not found for site ${siteId}`);
|
||||
}
|
||||
|
||||
sendToClient(newt.newtId, {
|
||||
type: 'newt/wg/peer/update',
|
||||
data: {
|
||||
publicKey,
|
||||
...peer
|
||||
}
|
||||
});
|
||||
|
||||
logger.info(`Updated peer ${publicKey} on newt ${newt.newtId}`);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue