Skip to content

Commit

Permalink
agama-server: add firewall_zone to connection model
Browse files Browse the repository at this point in the history
It is mapped to connection.zone of NetworkManager dbus API.
  • Loading branch information
cfconrad committed Apr 12, 2024
1 parent 766a871 commit 420bc31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rust/agama-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ pub struct Connection {
pub id: String,
pub uuid: Uuid,
pub mac_address: MacAddress,
pub firewall_zone: Option<String>,
pub ip_config: IpConfig,
pub status: Status,
pub interface: Option<String>,
Expand Down Expand Up @@ -448,6 +449,7 @@ impl Default for Connection {
id: Default::default(),
uuid: Uuid::new_v4(),
mac_address: Default::default(),
firewall_zone: Default::default(),
ip_config: Default::default(),
status: Default::default(),
interface: Default::default(),
Expand Down
9 changes: 9 additions & 0 deletions rust/agama-server/src/network/nm/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub fn connection_to_dbus<'a>(
connection_dbus.insert("master", "".into());
}

if let Some(zone) = &conn.firewall_zone {
connection_dbus.insert("zone", zone.into());
}

result.insert("ipv4", ip_config_to_ipv4_dbus(&conn.ip_config));
result.insert("ipv6", ip_config_to_ipv6_dbus(&conn.ip_config));
result.insert("match", match_config_to_dbus(&conn.match_config));
Expand Down Expand Up @@ -569,6 +573,11 @@ fn base_connection_from_dbus(conn: &OwnedNestedHash) -> Option<Connection> {
base_connection.match_config = match_config_from_dbus(match_config)?;
}

if let Some(zone) = connection.get("zone") {
let zone: &str = zone.downcast_ref()?;
base_connection.firewall_zone = Some(zone.to_string());
}

if let Some(ethernet_config) = conn.get(ETHERNET_KEY) {
base_connection.mac_address = mac_address_from_dbus(ethernet_config)?;
} else if let Some(wireless_config) = conn.get(WIRELESS_KEY) {
Expand Down

0 comments on commit 420bc31

Please sign in to comment.