mirror of https://github.com/wg-easy/wg-easy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
681 B
25 lines
681 B
import { InterfaceCidrUpdateSchema } from '#db/repositories/interface/types';
|
|
|
|
export default definePermissionEventHandler(
|
|
'admin',
|
|
'any',
|
|
async ({ event }) => {
|
|
const data = await readValidatedBody(
|
|
event,
|
|
validateZod(InterfaceCidrUpdateSchema, event)
|
|
);
|
|
|
|
// Remove overridden fields from the update data
|
|
const updateData = { ...data };
|
|
if (WG_OVERRIDE_ENV.IPV4_CIDR !== undefined) {
|
|
delete updateData.ipv4Cidr;
|
|
}
|
|
if (WG_OVERRIDE_ENV.IPV6_CIDR !== undefined) {
|
|
delete updateData.ipv6Cidr;
|
|
}
|
|
|
|
await Database.interfaces.updateCidr(updateData);
|
|
await WireGuard.saveConfig();
|
|
return { success: true };
|
|
}
|
|
);
|
|
|