this.fqdn = Fqdn::from(&format!("pve.{}", domain)).unwrap_or_else(|_| domain.clone());
}
- let mut filled = false;
- if let Some(gw) = &info.routes.gateway4 {
- if let Some(iface) = info.interfaces.get(&gw.dev) {
- if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) {
- this.ifname = iface.name.clone();
- this.gateway = gw.gateway;
- this.address = addr.clone();
- filled = true;
- }
- }
- }
- if !filled {
- if let Some(gw) = &info.routes.gateway6 {
+ if let Some(routes) = &info.routes {
+ let mut filled = false;
+ if let Some(gw) = &routes.gateway4 {
if let Some(iface) = info.interfaces.get(&gw.dev) {
- if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6()) {
+ if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) {
this.ifname = iface.name.clone();
this.gateway = gw.gateway;
this.address = addr.clone();
+ filled = true;
+ }
+ }
+ }
+ if !filled {
+ if let Some(gw) = &routes.gateway6 {
+ if let Some(iface) = info.interfaces.get(&gw.dev) {
+ if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6()) {
+ this.ifname = iface.name.clone();
+ this.gateway = gw.gateway;
+ this.address = addr.clone();
+ }
}
}
}
#[derive(Clone, Deserialize)]
pub struct NetworkInfo {
pub dns: Dns,
- pub routes: Routes,
+ pub routes: Option<Routes>,
/// Maps devices to their configuration, if it has a usable configuration.
/// (Contains no entries for devices with only link-local addresses.)