fix: when not using dns_records_path, use config dns editor

This commit is contained in:
Aarnav Tale 2025-04-26 17:50:07 -04:00
parent 478c5a5e7f
commit 88f53948b2
No known key found for this signature in database
2 changed files with 19 additions and 1 deletions

View File

@ -77,7 +77,7 @@ export class HeadscaleDNSConfig {
export async function loadHeadscaleDNS(path?: string) {
if (!path) {
return new HeadscaleDNSConfig('no');
return;
}
log.debug('config', 'Loading Headscale DNS configuration file: %s', path);

View File

@ -1,4 +1,5 @@
import { constants, access, readFile, writeFile } from 'node:fs/promises';
import { exit } from 'node:process';
import { setTimeout } from 'node:timers/promises';
import { type } from 'arktype';
import { Document, parseDocument } from 'yaml';
@ -269,6 +270,23 @@ export async function loadHeadscaleConfig(
}
const dns = await loadHeadscaleDNS(dnsPath);
if (dns && !config.dns.extra_records_path) {
log.error(
'config',
'Using separate DNS config file but dns.extra_records_path is not set in Headscale config',
);
log.error(
'config',
'Please set `dns.extra_records_path` in the Headscale config',
);
log.error(
'config',
'Or remove `headscale.dns_records_path` from the Headplane config',
);
exit(1);
}
return new HeadscaleConfig(w ? 'rw' : 'ro', dns, config, document, path);
}