Improve wg-ui host setup: IP availability checks and current-user install script

- setup-main-host-button: live availability status, grab-next-subnet helper, error/success feedback
- setup-wireguard-host: harden generated shell scripts with set -e
- check-private-ip-address-availability: add user access check, drop manual body validation
- setup-main-host: pass host object with wg_ip_address
- install-wg-ui.sh: run service as the invoking user (root or sudo) instead of a dedicated wgui user, and skip systemd/OpenRC daemon setup when NODE_ENV=development
This commit is contained in:
2026-09-13 11:43:26 +01:00
parent 86eb3a0b05
commit ad94385bcb
5 changed files with 295 additions and 112 deletions
@@ -1,3 +1,4 @@
import checkUserAccess from "@/src/functions/backend/auth/check-user-access";
import userAuth from "@/src/functions/backend/auth/user-auth";
import checkPrivateIPAvailability from "@/src/functions/backend/setup/check-private-ip-availability";
import type { ApiReqParams } from "@/src/types";
@@ -11,7 +12,7 @@ export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
params,
) => {
const req = params.req;
const body = params.body as ApiReqParams | undefined;
const body = params.body as ApiReqParams;
if (req.method !== "POST") {
return {
@@ -30,17 +31,13 @@ export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
}
try {
const ip_address = body?.ip_address;
if (!ip_address) {
throw new Error(`No IP address passed!`);
}
return await checkPrivateIPAvailability({ ip_address });
return await checkPrivateIPAvailability({
ip_address: body?.ip_address || "",
});
} catch (error: any) {
return {
success: false,
msg: error.message,
};
}
};
};
+3 -1
View File
@@ -41,7 +41,9 @@ export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
}
return await setupWireguardHost({
wg_subnet_ip: body.ip_address,
host: {
wg_ip_address: body.ip_address,
},
});
} catch (error: any) {
return {