diff --git a/app/utils/config/headscale.ts b/app/utils/config/headscale.ts index 1d0b777..1401617 100644 --- a/app/utils/config/headscale.ts +++ b/app/utils/config/headscale.ts @@ -182,6 +182,18 @@ export async function loadConfig(path?: string) { const data = await readFile(path, 'utf8') configYaml = parseDocument(data) + if (process.env.HEADSCALE_CONFIG_UNSTRICT === 'true') { + config = configYaml.toJSON() as HeadscaleConfig + console.log('Loaded Headscale configuration in non-strict mode') + console.log('By using this mode you forfeit GitHub issue support') + console.log('This is very dangerous and comes with a few caveats:') + console.log('- Headplane could very easily crash') + console.log('- Headplane could break your Headscale installation') + console.log('- The UI could throw random errors/show incorrect data') + console.log('') + return config + } + try { config = await HeadscaleConfig.parseAsync(configYaml.toJSON()) } catch (error) { @@ -245,7 +257,10 @@ export async function patchConfig(partial: Record) { configYaml.setIn(path, value) } - config = await HeadscaleConfig.parseAsync(configYaml.toJSON()) + config = process.env.HEADSCALE_CONFIG_UNSTRICT === 'true' + ? configYaml.toJSON() as HeadscaleConfig + : (await HeadscaleConfig.parseAsync(configYaml.toJSON())) + const path = resolve(process.env.CONFIG_FILE ?? '/etc/headscale/config.yaml') await writeFile(path, configYaml.toString(), 'utf8') } diff --git a/docs/Configuration.md b/docs/Configuration.md index e9a10a0..d6a6df4 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -13,6 +13,7 @@ You can configure Headplane using environment variables. - **`PORT`**: The port to bind the server to (default: `3000`). - **`CONFIG_FILE`**: The path to the Headscale `config.yaml` (default: `/etc/headscale/config.yaml`). - **`ACL_FILE`**: The path to the ACL file (default: `/etc/headscale/acl_policy.json`, not needed if you have `acl_policy_path` in your config). +- **`HEADSCALE_CONFIG_UNSTRICT`**: This will disable the strict configuration loader (default: `false`). #### Docker Integration The Docker integration allows Headplane to manage the Headscale docker container.