Reviewed-by: Lukas Wagner <l.wag...@proxmox.com> Reviewed-by: Max Carrara <m.carr...@proxmox.com> Co-authored-by: Wolfgang Bumiller <w.bumil...@proxmox.com> Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> --- proxmox-ve-config/src/firewall/types/group.rs | 36 +++++++++++++++++++ proxmox-ve-config/src/firewall/types/mod.rs | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 proxmox-ve-config/src/firewall/types/group.rs
diff --git a/proxmox-ve-config/src/firewall/types/group.rs b/proxmox-ve-config/src/firewall/types/group.rs new file mode 100644 index 0000000..7455268 --- /dev/null +++ b/proxmox-ve-config/src/firewall/types/group.rs @@ -0,0 +1,36 @@ +use anyhow::Error; + +use crate::firewall::types::Rule; + +#[derive(Debug)] +#[cfg_attr(test, derive(Eq, PartialEq))] +pub struct Group { + rules: Vec<Rule>, + comment: Option<String>, +} + +impl Group { + pub const fn new() -> Self { + Self { + rules: Vec::new(), + comment: None, + } + } + + pub fn rules(&self) -> &Vec<Rule> { + &self.rules + } + + pub fn comment(&self) -> Option<&str> { + self.comment.as_deref() + } + + pub fn set_comment(&mut self, comment: Option<String>) { + self.comment = comment; + } + + pub(crate) fn parse_entry(&mut self, line: &str) -> Result<(), Error> { + self.rules.push(line.parse()?); + Ok(()) + } +} diff --git a/proxmox-ve-config/src/firewall/types/mod.rs b/proxmox-ve-config/src/firewall/types/mod.rs index b4a6b12..8fd551e 100644 --- a/proxmox-ve-config/src/firewall/types/mod.rs +++ b/proxmox-ve-config/src/firewall/types/mod.rs @@ -1,5 +1,6 @@ pub mod address; pub mod alias; +pub mod group; pub mod ipset; pub mod log; pub mod port; @@ -8,5 +9,6 @@ pub mod rule_match; pub use address::Cidr; pub use alias::Alias; +pub use group::Group; pub use ipset::Ipset; pub use rule::Rule; -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel