Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(transparent-proxy): improvements in table builders (#10870)
- Add Multiport module validation to `Functionality` struct This commit enhances the `Functionality` struct by incorporating validation for the Multiport module. This update allows the system to determine whether the Multiport module is supported, enabling more efficient handling of port exclusions. - Add `NewValueOrRangeList` function This commit introduces the `NewValueOrRangeList` function, which provides a flexible and type-safe way to create a `ValueOrRangeList` from different input types. This function supports input as a slice of `uint16`, a single `uint16` value, or a string, allowing for more versatile and efficient handling of port and value ranges. - Refactor logic for inserting rules at specific positions This refactoring removes the need to manage rule positions externally. Now, the `rules.NewInsertRule` function is used to directly create rules that need to be inserted at specific positions within the chain. This change simplifies the code and reduces the complexity of managing rule positions manually. Key changes: - Replaced manual position tracking with `rules.NewInsertRule` function. - Simplified rule insertion logic by handling positioning within the rule builders. - Rename `rules.NewRule` to `rules.NewAppendRule` This commit refactors the function name `rules.NewRule` to `rules.NewAppendRule` to better reflect its purpose of creating rules that are appended to the end of an existing chain. This change improves code readability and clarity, making it more evident when a rule is being appended versus inserted. Key Changes: - Renamed `rules.NewRule` to `rules.NewAppendRule` for clarity. - Updated all occurrences of `rules.NewRule` in the codebase to the new name. - Enhance `Address` and `Source` functions to handle empty parameters This commit improves the `Address` and `Source` functions to handle cases where empty parameters are passed. This change helps prevent the creation of invalid or empty parameters that could lead to runtime errors or unexpected behavior in the iptables rule generation process. Key Changes: - Modified `Address` function to return `nil` if the input address is an empty string. - Updated `Source` function to return `nil` if the input parameter is `nil`. - These changes ensure that the functions gracefully handle empty inputs and do not create invalid parameters. - Refactor: Use `ProtocolL4` abstraction instead of hardcoded strings This commit replaces the hardcoded "tcp" and "udp" strings with the `ProtocolL4` abstraction. By using the `ProtocolL4` type, the code becomes more maintainable and reduces the risk of errors related to protocol string mismatches. - Introduced the `ProtocolL4` type to represent Layer 4 protocols (TCP and UDP). - Updated all instances of hardcoded "tcp" and "udp" strings to use the `ProtocolL4` constants (`ProtocolTCP` and `ProtocolUDP`). - Implemented the `ParseProtocolL4` function to convert strings to `ProtocolL4` types, ensuring consistent protocol handling throughout the codebase. Signed-off-by: Bart Smykla <[email protected]>
- Loading branch information