Commit Graph
47 Commits
Author SHA1 Message Date
wiegratz 2e98483b74 docs(lib): add library description 2024-10-24 20:51:06 +02:00
wiegratz abd3156e84 feat(schema)!: add default impl, add doc comments
added default impl for table, chain, rule, set, map, element, flowtable, counter, quota, cthelper, limit, ruleset, metainfoobject, cttimeout.
Default impls replace ::new() functions.

replace family: String by family: NfFamily in flowtable, counter, quota, cthelper, limit
2024-10-24 20:51:06 +02:00
wiegratz 42c399d2d2 feat(schema): qualify limit's per-attribute as time unit enum 2024-10-24 20:09:01 +02:00
wiegratz d8e0c68391 docs(visitor): fix doc comment syntax 2024-10-24 20:09:01 +02:00
Jasper d1cfeddd2d Merge pull request #71 from namib-project/non-exhaustive-statement
Mark Statement as non-exhaustive enum
2024-10-21 12:44:03 +02:00
wiegratz 0108fbfc9e feat: add synproxy statement and list object
also mark some other statements that are missing.
compare with nftables json_parse_stmt:  https://git.netfilter.org/nftables/tree/src/parser_json.c?id=c4c740117f6fbf39dd67dd87635ea8b497718ad7#n2884
2024-10-21 12:19:07 +02:00
wiegratz 87512028d9 feat(stmt)!: mark statement as non-exhaustive
non-exhaustive avoids future breaking changes when statements are added
by forcing users to add a wildcard arm to match on statement.
2024-10-21 12:14:13 +02:00
wiegratz a3209cb2c2 feat(stmt): implement flow statement 2024-10-21 10:55:09 +02:00
wiegratz 617b071330 fix: add doc comment and trait derive to counters 2024-10-19 16:38:47 +02:00
wiegratz 9f109c51e4 fix(stmt): fix named counter
BREAKING CHANGE: Use new enum variants of `Counter`: `Named` and `Anonymous`.
2024-10-06 18:14:32 +02:00
wiegratz 51ccf106da fix: store NfListObjects in heap
BREAKING CHANGE: With enum `NfObject::ListObject`, use `Box::new(NfListObject...)`.
2024-10-06 16:52:49 +02:00
wiegratz 290c5bbb0c docs: fix long doc comments in expr, stmt 2024-10-06 16:46:22 +02:00
wiegratz e13a5ed90d docs: add doc comments for tproxy 2024-07-08 18:51:50 +02:00
Zoruk a557c49936 feat: add support for tproxy 2024-06-25 13:39:58 +02:00
agarof 890098f034 Add common traits to basic enums 2024-04-26 22:09:51 +02:00
wiegratz 16d97fe736 add ruleset flush type 2024-03-16 15:05:41 +00:00
wiegratz 6fe77ae6c7 Merge branch 'args' 2024-03-16 14:59:56 +00:00
Paul Holzinger 6b135baa82 fix get_current_ruleset_raw args parsing
If users supply their own args do not append the list ruleset args.

Fixes #14

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-11 17:35:16 +01:00
Paul Holzinger 312a279fbb add inner header as payload base
nft can also use "ih" for inner header in the raw payload base, see
nft(8) for more info.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-11 16:40:28 +01:00
Paul Holzinger 0deaf7d864 fix payload raw expression
The current code cannot handle the ParloadRaw type, serde is unable to
deserialize the json with a raw payload fields.

This is because serde cannot handle two fields with the same name and I
haven't found a way to make this work like that. Instead we have to use
a untagged enum that share both possible payload values.

Therefore this is an API break: NamedExpression now only contains one
Payload field which contains the Payload enum, the old Payload type is
renamed to PayloadField.

Lastly, export the PayloadRaw fields so they can be used externally.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-11 16:35:25 +01:00
wiegratz 471e9fab77 schema: fix ct helper key name 2024-01-22 12:34:42 +01:00
wiegratz e5fb6d4e48 expr: fix sctp chunks
also adds space-keys test for all keys with spaces
2024-01-22 12:26:50 +01:00
wiegratz fd2bd09ad1 chore: fix clippy warnings 2024-01-22 11:56:31 +01:00
wiegratz 04e29d85e8 Merge branch 'add_missing_things' 2024-01-22 11:36:00 +01:00
Jasper 21b69e72bd Merge pull request #11 from RegalisTechnologies/map
Implement map support
2024-01-19 14:46:12 +01:00
Marcin Osypka e0500fef5e Remove not used ElemCounter struct 2024-01-18 18:56:30 +01:00
Marcin Osypka 3c87c233e9 Add the comment field to a map
The comments can be added to the map.
2024-01-18 18:50:51 +01:00
Marcin Osypka 8a31a720a7 Add comment field to set
The comment field on a set is not present in documentation but it is
working and sometimes convenient to use.
2024-01-18 18:48:35 +01:00
Marcin Osypka 6159989e37 Elem fields should be Option
E.g. for the set:
set test_set {
    typeof ip saddr
    flags interval
    elements = { 10.0.0.0/24 }
}

The json object will look like this:
 "set": {
    "family": "ip",
    "name": "snat_hv",
    "table": "nat",
    "type": "ipv4_addr",
    "handle": 4,
    "flags": [
      "interval"
    ],
    "elem": [
      {
        "elem": {
          "val": {
            "prefix": {
              "addr": "10.0.0.0",
              "len": 24
            }
          },
        }
      }
 }
 There is no timeout, expires and comments fields, they should be
 optional.
2024-01-17 20:14:14 +01:00
Marcin Osypka d1ac323bf9 Implement map support
A Verdict enum was moved from a NamedExpression to an Expression,
placing it in a NamedExpression was a bug. Accroding to
libnftables-json(5) (section VERDICT) a Verdict does not have a
"verdict" key, it is "anonymous". e.g.: { "jump": { "target":
"my_target"}, and not: { "verdict": { "jump": { "target": "my_target"} }
}

Additionally a `Verdict::Jump` and a `Verdict::Goto` data was changed to
a `stmt::JumpTarget` struct from a `String`.

A `Map` and a `Set` use almost the same fields, a map additinally uses a
map field of type `String`.
2024-01-17 19:40:23 +01:00
Marcin Osypka 80561b972d Add Elem counter field
Since nftables 0.9.5  there is a counter per element available
2024-01-17 19:38:31 +01:00
Marcin Osypka 19323421ab Add a missing dynamic SetFlag
The flag is documented in NFT(8) manual (Table 8, set specifications)
2024-01-17 19:36:10 +01:00
Marcin Osypka 45b92e1a76 Add missing ifname SetType
The type can be found on a nftables wiki page (in section "Named sets
Specifications") https://wiki.nftables.org/wiki-nftables/index.php/Sets
2024-01-17 19:17:56 +01:00
Vadim Kaushan 78b001ca02 Fix tcp option key name 2024-01-12 10:08:04 +02:00
jwhb c467bd7428 stmt: declare XT as serde value 2023-08-12 19:32:34 +02:00
jwhb e46af5e1e9 stmt: counter values as usize 2023-08-12 19:32:34 +02:00
jwhb ac3d3b7ab0 expr: implement mapping anonymous sets 2023-08-12 19:32:34 +02:00
bits0rcerer fd01cfe50d return error instead of panic 2023-08-11 10:54:06 +02:00
Noel 4f427820a7 Fix queue JSON serialisation when flag is none 2023-07-07 14:01:56 +02:00
Noel d08001ffb8 Update queue flags to be optional 2023-07-07 12:00:46 +02:00
wiegratz 720d2c75db schema: implement set type, add test for set 2023-03-19 23:38:56 +00:00
Dummyc0m da6bc8b35c add element serialization 2023-03-19 08:44:44 +00:00
wiegratz 9efcdeb562 fix(helper): apply hints from cargo check 2022-12-16 12:29:53 +00:00
Thomas Spellman eeda434ac9 change insert to match add
This change adds the necessary {"rule": ...} json object, similar to how the add command works.
2022-12-15 21:34:43 -08:00
wiegratz a34432e4e8 feat: rename to nftables-rs 2022-10-04 11:39:43 +00:00
wiegratz 12f5e648b4 fix(expr): Range is not NamedExpression 2022-09-30 17:32:33 +00:00
wiegratz e331c6f8ad lib: first commit 2022-09-30 17:32:07 +00:00