mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-25 22:41:10 +02:00
Many changes to the nftables backend which will be used in the follow-up PR with #4421. 1. Add support for chain policy: drop/accept. 2. Properly handle match on all IPs in the set (`0.0.0.0/0` like). 3. Implement conntrack state matching. 4. Implement multiple ifname matching in a single rule. 5. Implement anonymous counters. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
// Code generated by "enumer -type=ConntrackState -linecomment -text"; DO NOT EDIT.
|
|
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
_ConntrackStateName_0 = "invalidestablished"
|
|
_ConntrackStateName_1 = "related"
|
|
_ConntrackStateName_2 = "new"
|
|
)
|
|
|
|
var (
|
|
_ConntrackStateIndex_0 = [...]uint8{0, 7, 18}
|
|
_ConntrackStateIndex_1 = [...]uint8{0, 7}
|
|
_ConntrackStateIndex_2 = [...]uint8{0, 3}
|
|
)
|
|
|
|
func (i ConntrackState) String() string {
|
|
switch {
|
|
case 1 <= i && i <= 2:
|
|
i -= 1
|
|
return _ConntrackStateName_0[_ConntrackStateIndex_0[i]:_ConntrackStateIndex_0[i+1]]
|
|
case i == 4:
|
|
return _ConntrackStateName_1
|
|
case i == 8:
|
|
return _ConntrackStateName_2
|
|
default:
|
|
return fmt.Sprintf("ConntrackState(%d)", i)
|
|
}
|
|
}
|
|
|
|
var _ConntrackStateValues = []ConntrackState{1, 2, 4, 8}
|
|
|
|
var _ConntrackStateNameToValueMap = map[string]ConntrackState{
|
|
_ConntrackStateName_0[0:7]: 1,
|
|
_ConntrackStateName_0[7:18]: 2,
|
|
_ConntrackStateName_1[0:7]: 4,
|
|
_ConntrackStateName_2[0:3]: 8,
|
|
}
|
|
|
|
// ConntrackStateString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func ConntrackStateString(s string) (ConntrackState, error) {
|
|
if val, ok := _ConntrackStateNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to ConntrackState values", s)
|
|
}
|
|
|
|
// ConntrackStateValues returns all values of the enum
|
|
func ConntrackStateValues() []ConntrackState {
|
|
return _ConntrackStateValues
|
|
}
|
|
|
|
// IsAConntrackState returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i ConntrackState) IsAConntrackState() bool {
|
|
for _, v := range _ConntrackStateValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for ConntrackState
|
|
func (i ConntrackState) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for ConntrackState
|
|
func (i *ConntrackState) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = ConntrackStateString(string(text))
|
|
return err
|
|
}
|