Refactor main host setup
This commit is contained in:
@@ -1,27 +1,18 @@
|
||||
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_VARIABLES,
|
||||
} from "@/db/types/db";
|
||||
import type { BUN_SQLITE_WGUI_CLIENTS } from "@/db/types/db";
|
||||
import type { BUN_SQLITE_WGUI_HOSTS_JOIN } from "@/src/types/sql-joins";
|
||||
|
||||
type Params = {
|
||||
host?: BUN_SQLITE_WGUI_HOSTS_JOIN;
|
||||
variables?: BUN_SQLITE_WGUI_VARIABLES[];
|
||||
clients?: BUN_SQLITE_WGUI_CLIENTS[];
|
||||
};
|
||||
|
||||
export default function deriveHostConfig({ host, variables, clients }: Params) {
|
||||
const host_id = host?.id || AppData["WireguardHostID"];
|
||||
export default function deriveHostConfig({ host, clients }: Params) {
|
||||
const host_id = host?.id || AppData["WireguardMainHostID"];
|
||||
|
||||
const wg_ip_address =
|
||||
host?.wg_ip_address ||
|
||||
variables?.find((v) => v.key == "main_host_wg_ip_address")?.value;
|
||||
|
||||
const public_key =
|
||||
host?.public_key ||
|
||||
variables?.find((v) => v.key == "main_host_wg_public_key")?.value;
|
||||
const wg_ip_address = host?.wg_ip_address;
|
||||
const public_key = host?.public_key;
|
||||
|
||||
const interface_name = deriveWireguardInterfaceName({ host_id });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user