diff --git a/src/server/utils/config.ts b/src/server/utils/config.ts index 886c0a28..74a77b10 100644 --- a/src/server/utils/config.ts +++ b/src/server/utils/config.ts @@ -19,6 +19,15 @@ export const WG_ENV = { PORT: assertEnv('PORT'), /** If IPv6 should be disabled */ DISABLE_IPV6: process.env.DISABLE_IPV6 === 'true', + /** Override automatic detection */ + AWG: + process.env.AWG === 'true' + ? true + : process.env.AWG === 'false' + ? false + : undefined, + /** TODO: delete on next major version */ + EXPERIMENTAL_AWG: process.env.EXPERIMENTAL_AWG === 'true', }; export const WG_INITIAL_ENV = { diff --git a/src/server/utils/wgHelper.ts b/src/server/utils/wgHelper.ts index aafbd455..11bbf906 100644 --- a/src/server/utils/wgHelper.ts +++ b/src/server/utils/wgHelper.ts @@ -9,9 +9,17 @@ type Options = { enableIpv6?: boolean; }; -const wgExecutable = await exec('modinfo amneziawg') - .then(() => 'awg' as const) - .catch(() => 'wg' as const); +let wgExecutable: 'awg' | 'wg' = 'wg'; + +if (WG_ENV.EXPERIMENTAL_AWG) { + if (WG_ENV.AWG !== undefined) { + wgExecutable = WG_ENV.AWG ? 'awg' : 'wg'; + } else { + wgExecutable = await exec('modinfo amneziawg') + .then(() => 'awg' as const) + .catch(() => 'wg' as const); + } +} export const wg = { generateServerPeer: (