fix(dns): Fixed Soa records

This commit is contained in:
2025-05-30 19:54:48 +00:00
parent 71183b35c0
commit 74692c4aa5
4 changed files with 50 additions and 184 deletions

View File

@ -79,7 +79,7 @@ export interface IDcRouterOptions {
/**
* DNS records to register
* Must be within the defined dnsScopes (or receive warning)
* Only need A, CNAME, TXT, MX records (NS and SOA are auto-generated)
* Only need A, CNAME, TXT, MX records (NS records auto-generated, SOA handled by smartdns)
* Can use `useIngressProxy: false` to expose real server IP (defaults to true)
*/
dnsRecords?: Array<{
@ -788,6 +788,7 @@ export class DcRouter {
httpsPort: 443, // Required but won't bind due to manual mode
manualHttpsMode: true, // Enable manual HTTPS socket handling
dnssecZone: primaryNameserver,
primaryNameserver: primaryNameserver, // Automatically generates correct SOA records
// For now, use self-signed cert until we integrate with Let's Encrypt
httpsKey: '',
httpsCert: ''
@ -937,7 +938,8 @@ export class DcRouter {
}
/**
* Generate authoritative DNS records (NS and SOA) for all domains in dnsScopes
* Generate authoritative DNS records (NS only) for all domains in dnsScopes
* SOA records are now automatically generated by smartdns with primaryNameserver setting
*/
private async generateAuthoritativeRecords(): Promise<Array<{name: string; type: string; value: string; ttl?: number}>> {
const records: Array<{name: string; type: string; value: string; ttl?: number}> = [];
@ -946,9 +948,7 @@ export class DcRouter {
return records;
}
const primaryNameserver = this.options.dnsNsDomains[0];
// Generate NS and SOA records for each domain in scopes
// Generate NS records for each domain in scopes
for (const domain of this.options.dnsScopes) {
// Add NS records for all nameservers
for (const nsDomain of this.options.dnsNsDomains) {
@ -960,17 +960,11 @@ export class DcRouter {
});
}
// Add SOA record with first nameserver as primary
const soaValue = `${primaryNameserver} hostmaster.${domain} ${Date.now()} 7200 3600 1209600 3600`;
records.push({
name: domain,
type: 'SOA',
value: soaValue,
ttl: 3600
});
// SOA records are now automatically generated by smartdns DnsServer
// with the primaryNameserver configuration option
}
logger.log('info', `Generated ${records.length} authoritative records for ${this.options.dnsScopes.length} domains`);
logger.log('info', `Generated ${records.length} NS records for ${this.options.dnsScopes.length} domains`);
return records;
}