Feat: add ability to restart interface (#1740)
add ability to restart interface
This commit is contained in:
5
src/server/api/admin/interface/restart.post.ts
Normal file
5
src/server/api/admin/interface/restart.post.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
await WireGuard.Restart();
|
||||
|
||||
return { success: true };
|
||||
});
|
||||
@@ -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
|
||||
|
||||
@@ -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})`);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user