Feat: add ability to restart interface (#1740)

add ability to restart interface
This commit is contained in:
Bernd Storath
2025-03-14 12:19:26 +01:00
committed by GitHub
parent 198b240755
commit bbee7e04ed
7 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
export default definePermissionEventHandler('admin', 'any', async () => {
await WireGuard.Restart();
return { success: true };
});

View File

@@ -193,6 +193,11 @@ class WireGuard {
await wg.down(wgInterface.name).catch(() => {});
}
async Restart() {
const wgInterface = await Database.interfaces.get();
await wg.restart(wgInterface.name);
}
async cronJob() {
const clients = await Database.clients.getAll();
// Expires Feature

View File

@@ -92,6 +92,10 @@ Endpoint = ${userConfig.host}:${userConfig.port}`;
return exec(`wg-quick down ${infName}`);
},
restart: (infName: string) => {
return exec(`wg-quick down ${infName}; wg-quick up ${infName}`);
},
sync: (infName: string) => {
return exec(`wg syncconf ${infName} <(wg-quick strip ${infName})`);
},