Browse Source

feat: enhance AWG detection and configuration handling

pull/2102/head
cany748 1 month ago
parent
commit
7dbd6f3b64
  1. 9
      src/server/utils/config.ts
  2. 14
      src/server/utils/wgHelper.ts

9
src/server/utils/config.ts

@ -19,6 +19,15 @@ export const WG_ENV = {
PORT: assertEnv('PORT'), PORT: assertEnv('PORT'),
/** If IPv6 should be disabled */ /** If IPv6 should be disabled */
DISABLE_IPV6: process.env.DISABLE_IPV6 === 'true', 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 = { export const WG_INITIAL_ENV = {

14
src/server/utils/wgHelper.ts

@ -9,9 +9,17 @@ type Options = {
enableIpv6?: boolean; enableIpv6?: boolean;
}; };
const wgExecutable = await exec('modinfo amneziawg') let wgExecutable: 'awg' | 'wg' = 'wg';
.then(() => 'awg' as const)
.catch(() => 'wg' as const); 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 = { export const wg = {
generateServerPeer: ( generateServerPeer: (

Loading…
Cancel
Save