pub dns_server: IpAddr,
}
+impl NetworkOptions {
+ const DEFAULT_DOMAIN: &str = "example.invalid";
+}
+
impl Default for NetworkOptions {
fn default() -> Self {
let fqdn = format!(
- "{}.example.invalid",
- crate::current_product().default_hostname()
+ "{}.{}",
+ crate::current_product().default_hostname(),
+ Self::DEFAULT_DOMAIN
);
// TODO: Retrieve automatically
Self {
this.dns_server = *ip;
}
- if let Some(domain) = &info.dns.domain {
- let hostname = crate::current_product().default_hostname();
- if let Ok(fqdn) = Fqdn::from(&format!("{hostname}.{domain}")) {
- this.fqdn = fqdn;
- }
+ let hostname = info
+ .hostname
+ .as_deref()
+ .unwrap_or_else(|| crate::current_product().default_hostname());
+ let domain = info.dns.domain.as_deref().unwrap_or(Self::DEFAULT_DOMAIN);
+
+ if let Ok(fqdn) = Fqdn::from(&format!("{hostname}.{domain}")) {
+ this.fqdn = fqdn;
}
if let Some(routes) = &info.routes {
/// (Contains no entries for devices with only link-local addresses.)
#[serde(default)]
pub interfaces: HashMap<String, Interface>,
+
+ /// The hostname of this machine, if set by the DHCP server.
+ pub hostname: Option<String>,
}
#[derive(Clone, Deserialize)]