]> git.proxmox.com Git - proxmox-firewall.git/commit
nftables: add helpers
authorStefan Hanreich <s.hanreich@proxmox.com>
Fri, 29 Mar 2024 09:34:25 +0000 (10:34 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 18 Apr 2024 19:45:39 +0000 (21:45 +0200)
commit3032d75d36bdc86af30946af8b626f9daae3c612
tree284084a2eeb1bd05ea80ab0ae41106f2539525cd
parentc1589cc796dfaa7ae5f069e62cdf8f6303e4ad24
nftables: add helpers

Several objects, statements and expressions in nftables-json require
null values, for instance:

    { "flush": { "ruleset": null }}

For this purpose we define our own Null type, which we can then easily
use for defining types that accept Null as value.

Several keys accept as value either a singular element (string or
object) if there is only one object, but an array if there are
multiple objects. For instance when adding a single element to a set:

           { "element": {
       ...
       "elem": "element1"
           }}

but when adding multiple elements:

           { "element": {
       ...
       "elem": ["element1", "element2"]
           }}

NfVec<T> is a wrapper for Vec<T> that serializes into T iff Vec
contains one element, otherwise it serializes like a Vec would
normally do.

Co-authored-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-nftables/Cargo.toml
proxmox-nftables/src/helper.rs [new file with mode: 0644]
proxmox-nftables/src/lib.rs