Refactor wireguard to use a different config dir instead of /etc/wireguard
This commit is contained in:
@@ -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`,
|
||||
|
||||
Reference in New Issue
Block a user