Update hosts form

This commit is contained in:
2026-09-20 13:48:35 +01:00
parent a9ebd8fb75
commit 3c1d2b61f6
20 changed files with 308 additions and 66 deletions
@@ -15,6 +15,7 @@ import manageWireguardHost from "./manage-wireguard-host";
import grabHostDirnames from "./grab-host-dir-names";
import grabClientDirnames from "./grab-client-dir-names";
import buildHostIptablesScripts from "./build-host-iptables-scripts";
import { AppData } from "@/src/data/app-data";
const { WIREGUARD_PRIVATE_KEY_FILE_NAME, WIREGUARD_PUBLIC_KEY_FILE_NAME } =
grabDirNames();
@@ -100,7 +101,8 @@ export default async function setupWireguardHost({
rules_by_client_id.set(rule.client_id, existing_rules);
}
const TARGET_INTERFACE = host?.interface || await grabHostNetworkInterface();
const TARGET_INTERFACE =
host?.interface || (await grabHostNetworkInterface());
const HOST_WG_IP =
host?.wg_ip_address ||
variables?.find((v) => v.key == "main_host_wg_ip_address")?.value ||
@@ -246,7 +248,7 @@ export default async function setupWireguardHost({
sh += `cat > ${INTERFACE_NAME}.conf << EOF\n`;
sh += `[Interface]\n`;
sh += `Address = ${HOST_WG_IP}/24\n`;
sh += `ListenPort = 51820\n`;
sh += `ListenPort = ${host?.listen_port || AppData["DefaultWGListenPort"]}\n`;
sh += `PrivateKey = ${HOST_PRIVATE_KEY}\n`;
sh += `PostUp = ${POST_UP_PATH}\n`;
sh += `PostDown = ${POST_DOWN_PATH}\n`;
@@ -284,6 +286,13 @@ export default async function setupWireguardHost({
const exec = execSync(sh, { encoding: "utf-8" });
if (!is_update_after_client_setup) {
execSync(
`ip link set ${INTERFACE_NAME} down 2>/dev/null; ip link del ${INTERFACE_NAME} 2>/dev/null; true`,
{ encoding: "utf-8" },
);
}
const manage_res = manageWireguardHost({
host_id: HOST_ID,
action: "restart",