mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-21 12:26:40 +00:00
Merge branch 'dev' into hybrid
This commit is contained in:
39
server/routers/client/targets.ts
Normal file
39
server/routers/client/targets.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { sendToClient } from "../ws";
|
||||
|
||||
export async function addTargets(
|
||||
newtId: string,
|
||||
destinationIp: string,
|
||||
destinationPort: number,
|
||||
protocol: string,
|
||||
port: number | null = null
|
||||
) {
|
||||
const target = `${port ? port + ":" : ""}${
|
||||
destinationIp
|
||||
}:${destinationPort}`;
|
||||
|
||||
await sendToClient(newtId, {
|
||||
type: `newt/wg/${protocol}/add`,
|
||||
data: {
|
||||
targets: [target] // We can only use one target for WireGuard right now
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function removeTargets(
|
||||
newtId: string,
|
||||
destinationIp: string,
|
||||
destinationPort: number,
|
||||
protocol: string,
|
||||
port: number | null = null
|
||||
) {
|
||||
const target = `${port ? port + ":" : ""}${
|
||||
destinationIp
|
||||
}:${destinationPort}`;
|
||||
|
||||
await sendToClient(newtId, {
|
||||
type: `newt/wg/${protocol}/remove`,
|
||||
data: {
|
||||
targets: [target] // We can only use one target for WireGuard right now
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user