NameServer: fix generation of SOA record
`unbound` requires that the MNAME lies underneath the zone. That is `primaryNN.nameservers.com.` is not a valid MNAME for a nameserver authoritative over `mydomain.com.`. For that zone, `primaryNN.mydomain.com.` would be a valid MNAME.
This commit is contained in:
parent
0ba63a167d
commit
ab2aa39b06
@ -153,7 +153,7 @@ impl NameServer<Stopped> {
|
|||||||
/// the zone
|
/// the zone
|
||||||
pub fn new(implementation: &Implementation, zone: FQDN, network: &Network) -> Result<Self> {
|
pub fn new(implementation: &Implementation, zone: FQDN, network: &Network) -> Result<Self> {
|
||||||
let ns_count = ns_count();
|
let ns_count = ns_count();
|
||||||
let nameserver = primary_ns(ns_count);
|
let nameserver = primary_ns(ns_count, &zone);
|
||||||
let image = implementation.clone().into();
|
let image = implementation.clone().into();
|
||||||
let container = Container::run(&image, network)?;
|
let container = Container::run(&image, network)?;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ impl NameServer<Stopped> {
|
|||||||
zone: zone.clone(),
|
zone: zone.clone(),
|
||||||
ttl: DEFAULT_TTL,
|
ttl: DEFAULT_TTL,
|
||||||
nameserver: nameserver.clone(),
|
nameserver: nameserver.clone(),
|
||||||
admin: admin_ns(ns_count),
|
admin: admin_ns(ns_count, &zone),
|
||||||
settings: SoaSettings::default(),
|
settings: SoaSettings::default(),
|
||||||
};
|
};
|
||||||
let mut zone_file = ZoneFile::new(soa);
|
let mut zone_file = ZoneFile::new(soa);
|
||||||
@ -439,12 +439,22 @@ pub struct Running {
|
|||||||
child: Child,
|
child: Child,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn primary_ns(ns_count: usize) -> FQDN {
|
fn primary_ns(ns_count: usize, zone: &FQDN) -> FQDN {
|
||||||
FQDN(format!("primary{ns_count}.nameservers.com.")).unwrap()
|
FQDN(format!("primary{ns_count}.{}", expand_zone(zone))).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn admin_ns(ns_count: usize) -> FQDN {
|
fn admin_ns(ns_count: usize, zone: &FQDN) -> FQDN {
|
||||||
FQDN(format!("admin{ns_count}.nameservers.com.")).unwrap()
|
FQDN(format!("admin{ns_count}.{}", expand_zone(zone))).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expand_zone(zone: &FQDN) -> String {
|
||||||
|
if zone == &FQDN::ROOT {
|
||||||
|
"nameservers.com.".to_string()
|
||||||
|
} else if zone.num_labels() == 1 {
|
||||||
|
format!("nameservers.{}", zone.as_str())
|
||||||
|
} else {
|
||||||
|
zone.to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user