Refactor wireguard to use a different config dir instead of /etc/wireguard

This commit is contained in:
2026-09-13 13:37:48 +01:00
parent 06cf72b2c9
commit 42224c94d3
10 changed files with 192 additions and 34 deletions
@@ -1,4 +1,5 @@
import { AppData } from "@/src/data/app-data";
import deriveWireguardInterfaceName from "@/src/utils/derive-wireguard-interface-name";
import type {
BUN_SQLITE_WGUI_CLIENTS,
BUN_SQLITE_WGUI_HOSTS,
@@ -7,6 +8,7 @@ import type {
const LISTEN_PORT = 51820;
const IP_TABLES_DIR = `/var/lib/wgui/iptables`;
const HOSTS_CONFIG_DIR = `/var/lib/wgui/hosts`;
type Params = {
host?: BUN_SQLITE_WGUI_HOSTS;
@@ -25,10 +27,14 @@ export default function deriveHostConfig({
host?.wg_ip_address ||
variables?.find((v) => v.key == "main_host_wg_ip_address")?.value;
const interface_name = deriveWireguardInterfaceName({ host_id });
return {
host_id,
interface_name: `wg${host_id}`,
config_path: `/etc/wireguard/wg${host_id}.conf`,
interface_name,
config_path: `${HOSTS_CONFIG_DIR}/${interface_name}.conf`,
systemd_unit_name: `wg-quick@${interface_name}.service`,
address: wg_ip_address ? `${wg_ip_address}/24` : undefined,
listen_port: LISTEN_PORT,
post_up: `${IP_TABLES_DIR}/${host_id}-up.sh`,
@@ -62,6 +62,9 @@ export default function InterfaceConfigSection({
<P noMargin className="font-mono text-[11.5px] text-foreground-light/40 dark:text-foreground-dark/40">
{config.config_path}
</P>
<P noMargin className="font-mono text-[11.5px] text-foreground-light/40 dark:text-foreground-dark/40">
{config.systemd_unit_name}
</P>
</Stack>
<AdminButton
Icon={Copy}