namib-project / nftables-rs

Safe abstraction for nftables JSON API (libnftables-json).
https://crates.io/crates/nftables
Apache License 2.0
23 stars 13 forks source link

get_current_ruleset_raw purpose useage of args unlcear #14

Closed Luap99 closed 5 months ago

Luap99 commented 5 months ago

I am not sure how args are supped to be used with get_current_ruleset(), I like to dump all the rule for a specifc table name which can be done with something like nft -j list table inet <table name> however due the args parsing it is impossible to supply this as the default args are allays appended, see https://github.com/namib-project/nftables-rs/blob/173d1bdc002627e223f128b0d210aa281051ecab/src/helper.rs#L46-L53

This code can never work because -j is a option and must be set before any args. Also the list ruleset part does not make sense in this case. I think the code should a always add -j first and then only add "list", "ruleset" if args are None. If args are set they should be added after -j.

Luap99 commented 5 months ago

I am willing to open a PR if you think this is the right approach.

jwhb commented 5 months ago

Good catch. Your analysis on the issue is absolutely correct.

Thanks for the fix!