diff --git a/rust/agama-server/src/network/model.rs b/rust/agama-server/src/network/model.rs index 8219350f4d..56fcf94826 100644 --- a/rust/agama-server/src/network/model.rs +++ b/rust/agama-server/src/network/model.rs @@ -760,6 +760,7 @@ pub struct IpConfig { pub nameservers: Vec, #[serde(skip_serializing_if = "Vec::is_empty")] pub dns_searchlist: Vec, + pub ignore_auto_dns: bool, pub gateway4: Option, pub gateway6: Option, pub routes4: Option>, diff --git a/rust/agama-server/src/network/nm/dbus.rs b/rust/agama-server/src/network/nm/dbus.rs index 0ab252f004..304288f809 100644 --- a/rust/agama-server/src/network/nm/dbus.rs +++ b/rust/agama-server/src/network/nm/dbus.rs @@ -288,6 +288,7 @@ fn ip_config_to_ipv4_dbus(ip_config: &IpConfig) -> HashMap<&str, zvariant::Value ("address-data", address_data), ("dns-data", dns_data), ("dns-search", ip_config.dns_searchlist.clone().into()), + ("ignore-auto-dns", ip_config.ignore_auto_dns.into()), ("method", ip_config.method4.to_string().into()), ]); @@ -334,6 +335,7 @@ fn ip_config_to_ipv6_dbus(ip_config: &IpConfig) -> HashMap<&str, zvariant::Value ("address-data", address_data), ("dns-data", dns_data), ("dns-search", ip_config.dns_searchlist.clone().into()), + ("ignore-auto-dns", ip_config.ignore_auto_dns.into()), ("method", ip_config.method6.to_string().into()), ]); @@ -682,6 +684,10 @@ fn ip_config_from_dbus(conn: &OwnedNestedHash) -> Option { ip_config.dns_searchlist.append(&mut searchlist); } + if let Some(ignore_auto_dns) = ipv4.get("ignore-auto-dns") { + ip_config.ignore_auto_dns = ignore_auto_dns.try_into().ok()?; + } + if let Some(route_data) = ipv4.get("route-data") { ip_config.routes4 = routes_from_dbus(route_data); } @@ -716,6 +722,10 @@ fn ip_config_from_dbus(conn: &OwnedNestedHash) -> Option { ip_config.dns_searchlist.append(&mut searchlist); } + if let Some(ignore_auto_dns) = ipv6.get("ignore-auto-dns") { + ip_config.ignore_auto_dns = ignore_auto_dns.try_into().ok()?; + } + if let Some(route_data) = ipv6.get("route-data") { ip_config.routes6 = routes_from_dbus(route_data); } @@ -987,6 +997,7 @@ mod test { "dns-search".to_string(), Value::new(vec!["suse.com", "example.com"]).to_owned(), ), + ("ignore-auto-dns".to_string(), Value::new(true).to_owned()), ( "route-data".to_string(), Value::new(route_v4_data).to_owned(), @@ -1073,6 +1084,7 @@ mod test { assert!(ip_config .dns_searchlist .contains(&"example.com".to_string())); + assert!(ip_config.ignore_auto_dns); assert_eq!(ip_config.method4, Ipv4Method::Auto); assert_eq!(ip_config.method6, Ipv6Method::Auto); assert_eq!( @@ -1570,6 +1582,11 @@ mod test { assert_eq!(dns_searchlist.len(), 2); assert!(dns_searchlist.contains(&"suse.com".to_string())); assert!(dns_searchlist.contains(&"suse.de".to_string())); + assert!(!ipv4_dbus + .get("ignore-auto-dns") + .unwrap() + .downcast_ref::() + .unwrap()); let ipv6_dbus = conn_dbus.get("ipv6").unwrap(); let gateway6: &str = ipv6_dbus.get("gateway").unwrap().downcast_ref().unwrap(); @@ -1608,5 +1625,10 @@ mod test { assert_eq!(dns_searchlist.len(), 2); assert!(dns_searchlist.contains(&"suse.com".to_string())); assert!(dns_searchlist.contains(&"suse.de".to_string())); + assert!(!ipv6_dbus + .get("ignore-auto-dns") + .unwrap() + .downcast_ref::() + .unwrap()); } }