nftables icon indicating copy to clipboard operation
nftables copied to clipboard

feature: Rule methods

Open greenpau opened this issue 4 years ago • 5 comments

@stapelberg, @sbezverk and other maintainers, currently many module's structs have no methods of their own. For example, it would have been nice to have String() method for Rule.

Is it OK to submit a PR for this?

greenpau avatar Aug 01 '20 21:08 greenpau

Regarding the String() method, just to double-check: it would return a human-readable representation of the rule, and wouldn’t be used programmatically, yes? If so, that seems okay to me.

stapelberg avatar Aug 02 '20 17:08 stapelberg

Regarding the String() method, just to double-check: it would return a human-readable representation of the rule, and wouldn’t be used programmatically, yes?

@stapelberg , Yes. I want to be able to see one liner rule, similar to “nft” utility. Today, it takes an “essay” to get a gist of what a rule does! 😄 i am not complaining ... i appreciate the complexity ... i learned from the experience ... however, it would probably make the library easier to consume. In fact, back in March, i failed to use the library because of its use complexity. Then, I stumbled upon a few blog posts and had an epiphany :-)

greenpau avatar Aug 02 '20 19:08 greenpau

It is just Rule does not have any method ... For example ... ‘IsVerdictDrop’, ‘IsVerdictJump’, ‘IsIPv4’, ‘IsIPv6’, etc.

greenpau avatar Aug 02 '20 19:08 greenpau

Sure, in that case adding String() makes sense.

For the other methods, I’m tentatively in favor, but let’s discuss those over a pull request maybe?

In general, this library is pretty low-level, so I don’t want to add too much syntactic sugar.

stapelberg avatar Aug 02 '20 21:08 stapelberg

For the other methods, I’m tentatively in favor, but let’s discuss those over a pull request maybe?

@stapelberg , absolutely!

In general, this library is pretty low-level, so I don’t want to add too much syntactic sugar.

👍

greenpau avatar Aug 03 '20 13:08 greenpau