Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> --- proxmox-ve-config/src/firewall/types/address.rs | 10 ++++++++++ proxmox-ve-config/src/firewall/types/ipset.rs | 14 ++++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/proxmox-ve-config/src/firewall/types/address.rs b/proxmox-ve-config/src/firewall/types/address.rs index 4baafa7..9f4ad02 100644 --- a/proxmox-ve-config/src/firewall/types/address.rs +++ b/proxmox-ve-config/src/firewall/types/address.rs @@ -11,6 +11,16 @@ pub enum Family { V6, } +impl Family { + pub fn is_ipv4(&self) -> bool { + *self == Self::V4 + } + + pub fn is_ipv6(&self) -> bool { + *self == Self::V6 + } +} + impl fmt::Display for Family { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { diff --git a/proxmox-ve-config/src/firewall/types/ipset.rs b/proxmox-ve-config/src/firewall/types/ipset.rs index e8131b5..7511490 100644 --- a/proxmox-ve-config/src/firewall/types/ipset.rs +++ b/proxmox-ve-config/src/firewall/types/ipset.rs @@ -132,6 +132,20 @@ pub struct IpsetEntry { pub comment: Option<String>, } +impl IpsetEntry { + pub fn new( + address: impl Into<IpsetAddress>, + nomatch: bool, + comment: impl Into<Option<String>>, + ) -> IpsetEntry { + IpsetEntry { + nomatch, + address: address.into(), + comment: comment.into(), + } + } +} + impl<T: Into<IpsetAddress>> From<T> for IpsetEntry { fn from(value: T) -> Self { Self { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel