google / google/nftables

Hook and Priority cannot be directly compared with predefined values

Open
#318 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
1.4k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

Hi,

When obtaining chains using methods such as `ListChains`, the `hookFromMsg` method directly returns a new pointer, which prevents it from being directly compared with defined values in the package (e.g., `ChainHookPrerouting` or `ChainPriorityNATDest`). In actual use, it is necessary to first determine whether this pointer is nil, then dereference the pointer and check if they are the same. To be honest, this is quite cumbersome. For this, I think we could add some small features:

* Add an `Equals(*ChainXXX) bool` method for `*ChainHook` and `*ChainPriority` types.
* Modify the logic of `hookFromMsg` to directly return the defined value instead of creating a new pointer.
* Implement both of the above solutions to facilitate the determination of custom values (e.g., `Priority`).

What do you think?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.