6c0d8e91fa
* Add INIT_ALLOWED_IPS env var Implement INIT_ALLOWED_IPS env var like the INIT_DNS to preset the global Allowed IPs field. * Docs: Add INIT_ALLOWED_IPS var to unattended setup table * Make UserConfigService.update param partial Update UserConfigService.update() to accept any subset of the updatable fields. Remove the unnecessary userConfig object from DBService.initialSetup() * formatting fix * format on linux On windows prettier get confused by global conf... common windows things
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import debug from 'debug';
|
|
import packageJson from '@@/package.json';
|
|
|
|
export const RELEASE = 'v' + packageJson.version;
|
|
|
|
export const SERVER_DEBUG = debug('Server');
|
|
|
|
export const OLD_ENV = {
|
|
/** @deprecated Only for migration purposes */
|
|
PASSWORD: process.env.PASSWORD,
|
|
/** @deprecated Only for migration purposes */
|
|
PASSWORD_HASH: process.env.PASSWORD_HASH,
|
|
};
|
|
|
|
const OVERRIDE_AUTO_AWG = process.env.OVERRIDE_AUTO_AWG?.toLowerCase();
|
|
|
|
export const WG_ENV = {
|
|
/** UI is hosted on HTTP instead of HTTPS */
|
|
INSECURE: process.env.INSECURE === 'true',
|
|
/** Port the UI is listening on */
|
|
PORT: assertEnv('PORT'),
|
|
/** If IPv6 should be disabled */
|
|
DISABLE_IPV6: process.env.DISABLE_IPV6 === 'true',
|
|
/** Override automatic detection */
|
|
OVERRIDE_AUTO_AWG:
|
|
OVERRIDE_AUTO_AWG === ('wg' as const) ||
|
|
OVERRIDE_AUTO_AWG === ('awg' as const)
|
|
? OVERRIDE_AUTO_AWG
|
|
: undefined,
|
|
/** TODO: delete on next major version */
|
|
EXPERIMENTAL_AWG: process.env.EXPERIMENTAL_AWG === 'true',
|
|
};
|
|
|
|
export const WG_INITIAL_ENV = {
|
|
ENABLED: process.env.INIT_ENABLED === 'true',
|
|
USERNAME: process.env.INIT_USERNAME,
|
|
PASSWORD: process.env.INIT_PASSWORD,
|
|
DNS: process.env.INIT_DNS?.split(',').map((x) => x.trim()),
|
|
IPV4_CIDR: process.env.INIT_IPV4_CIDR,
|
|
IPV6_CIDR: process.env.INIT_IPV6_CIDR,
|
|
ALLOWED_IPS: process.env.INIT_ALLOWED_IPS?.split(',').map((x) => x.trim()),
|
|
HOST: process.env.INIT_HOST,
|
|
PORT: process.env.INIT_PORT
|
|
? Number.parseInt(process.env.INIT_PORT, 10)
|
|
: undefined,
|
|
};
|
|
|
|
function assertEnv<T extends string>(env: T) {
|
|
const val = process.env[env];
|
|
|
|
if (!val) {
|
|
throw new Error(`Missing environment variable: ${env}`);
|
|
}
|
|
|
|
return val;
|
|
}
|