public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dietmar Maurer <dietmar@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [RFC proxmox 14/22] firewall-api-types: add firewall address types
Date: Thu, 12 Mar 2026 14:24:51 +0100	[thread overview]
Message-ID: <zb5eqwnbsrf7cdqufxyox6fwc52jpxrfyo5iqfam7e2guzrx6p@3yktwmehhvul> (raw)
In-Reply-To: <20260216104401.3959270-15-dietmar@proxmox.com>

On Mon, Feb 16, 2026 at 11:43:52AM +0100, Dietmar Maurer wrote:
> This adds new types for representing firewall address matches:
> 
> - FirewallAddressMatch: enum for IP lists, ipset references, or alias
>   references
> - FirewallAddressList: validated list of address entries with consistent
>   address family
> - FirewallAddressEntry: enum for CIDR or IP range entries
> 
> The implementation includes:
> - Proper encapsulation with constructor and accessor methods
> - Address family validation in FirewallAddressList::new()
> - FromStr implementations for parsing address specifications
> - Integration with existing FirewallIpsetReference and
>   FirewallAliasReference types
> 
> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
> ---
>  proxmox-firewall-api-types/Cargo.toml     |   1 +
>  proxmox-firewall-api-types/src/address.rs | 225 ++++++++++++++++++++++
>  proxmox-firewall-api-types/src/lib.rs     |   3 +
>  3 files changed, 229 insertions(+)
>  create mode 100644 proxmox-firewall-api-types/src/address.rs
> 
> diff --git a/proxmox-firewall-api-types/Cargo.toml b/proxmox-firewall-api-types/Cargo.toml
> index 97b477b8..8b77b522 100644
> --- a/proxmox-firewall-api-types/Cargo.toml
> +++ b/proxmox-firewall-api-types/Cargo.toml
> @@ -22,3 +22,4 @@ serde_plain = { workspace = true }
>  proxmox-schema = { workspace = true, features = ["api-macro"] }
>  proxmox-serde = { workspace = true, features = ["perl"] }
>  proxmox-fixed-string = { workspace = true, optional = true }
> +proxmox-network-types = { workspace = true, features = [ "api-types" ] }
> diff --git a/proxmox-firewall-api-types/src/address.rs b/proxmox-firewall-api-types/src/address.rs
> new file mode 100644
> index 00000000..46166352
> --- /dev/null
> +++ b/proxmox-firewall-api-types/src/address.rs
> @@ -0,0 +1,225 @@
> +use std::fmt;
> +use std::str::FromStr;
> +
> +use super::{FirewallAliasReference, FirewallIpsetReference};
> +
> +use anyhow::{bail, Error};
> +use proxmox_network_types::ip_address::{Cidr, Family, IpRange};
> +use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema};
> +
> +/// A match for source or destination address.
> +#[derive(Clone, Debug, PartialEq)]
> +pub enum FirewallAddressMatch {
> +    /// IP address list match.
> +    Ip(FirewallAddressList),
> +    /// IP set match.
> +    Ipset(FirewallIpsetReference),
> +    /// Alias match.
> +    Alias(FirewallAliasReference),
> +}
> +
> +impl ApiType for FirewallAddressMatch {
> +    const API_SCHEMA: Schema = StringSchema::new(
> +        r#"Restrict source or destination packet address.
> +    This can refer to a single IP address,
> +    an IP set ('+ipsetname') or an IP alias definition. You can also specify
> +    an address range like '20.34.101.207-201.3.9.99', or a list of IP
> +    addresses and networks (entries are separated by comma). Please do not
> +    mix IPv4 and IPv6 addresses inside such lists."#,

The string here contains all the white space, better use a non-raw
string with backslashes to allow for indentation.

> +    )
> +    .format(&ApiStringFormat::VerifyFn(verify_firewall_address_match))
> +    .max_length(512)
> +    .schema();
> +}
> +




  reply	other threads:[~2026-03-12 13:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-16 10:43 [RFC proxmox 00/22] New crate for firewall api types Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 01/22] firewall-api-types: add new " Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 02/22] firewall-api-types: add README.md Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 03/22] firewall-api-types: add firewall policy types Dietmar Maurer
2026-03-12 10:17   ` Wolfgang Bumiller
2026-02-16 10:43 ` [RFC proxmox 04/22] firewall-api-types: add logging types Dietmar Maurer
2026-03-02 12:24   ` Stefan Hanreich
2026-03-05  7:04     ` Dietmar Maurer
2026-03-12 10:22       ` Wolfgang Bumiller
2026-03-12 10:31   ` Wolfgang Bumiller
2026-02-16 10:43 ` [RFC proxmox 05/22] firewall-api-types: add FirewallClusterOptions Dietmar Maurer
2026-03-02 12:27   ` Stefan Hanreich
2026-03-05  7:06     ` Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 06/22] firewall-api-types: add FirewallGuestOptions Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 07/22] firewall-api-types: add FirewallConntrackHelper enum Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 08/22] firewall-api-types: add FirewallNodeOptions struct Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 09/22] firewall-api-types: add FirewallRef type Dietmar Maurer
2026-03-12 10:36   ` Wolfgang Bumiller
2026-03-12 10:41     ` Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 10/22] firewall-api-types: add FirewallPortList types Dietmar Maurer
2026-03-02 12:17   ` Stefan Hanreich
2026-03-05  7:02     ` Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 11/22] firewall-api-types: add FirewallIcmpType Dietmar Maurer
2026-03-12 10:51   ` Wolfgang Bumiller
2026-02-16 10:43 ` [RFC proxmox 12/22] firewall-api-types: add FirewallIpsetReference type Dietmar Maurer
2026-03-02 12:39   ` Stefan Hanreich
2026-02-16 10:43 ` [RFC proxmox 13/22] firewall-api-types: add FirewallAliasReference type Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 14/22] firewall-api-types: add firewall address types Dietmar Maurer
2026-03-12 13:24   ` Wolfgang Bumiller [this message]
2026-02-16 10:43 ` [RFC proxmox 15/22] firewall-api-types: add FirewallRule type Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 16/22] firewall-api-types: use ConfigDigest from proxmox-config-digest crate Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 17/22] firewall-api-types: use COMMENT_SCHEMA from proxmox-schema crate Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 18/22] firewall-api-types: add FirewallRuleUpdater type Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 19/22] firewall-api-types: refactor FirewallRule and add FirewallRuleListEntry Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 20/22] firewall-api-types: add DeletableFirewallRuleProperty enum Dietmar Maurer
2026-02-16 10:43 ` [RFC proxmox 21/22] firewall-api-types: add FirewallAliasEntry API type Dietmar Maurer
2026-02-16 10:44 ` [RFC proxmox 22/22] firewall-api-types: add FirewallIpsetListEntry and FirewallIpsetEntry api types Dietmar Maurer
2026-02-17  6:17 ` [RFC proxmox 00/22] New crate for firewall " Hannes Laimer
2026-02-17  6:39   ` Dietmar Maurer
2026-02-17  8:17     ` Hannes Laimer
2026-03-02 13:55 ` Stefan Hanreich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=zb5eqwnbsrf7cdqufxyox6fwc52jpxrfyo5iqfam7e2guzrx6p@3yktwmehhvul \
    --to=w.bumiller@proxmox.com \
    --cc=dietmar@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal