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>
82 lines
1.8 KiB
Go
82 lines
1.8 KiB
Go
// Code generated by "enumer -type=Protocol -linecomment -text"; DO NOT EDIT.
|
|
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
_ProtocolName_0 = "icmp"
|
|
_ProtocolName_1 = "tcp"
|
|
_ProtocolName_2 = "udp"
|
|
_ProtocolName_3 = "icmpv6"
|
|
)
|
|
|
|
var (
|
|
_ProtocolIndex_0 = [...]uint8{0, 4}
|
|
_ProtocolIndex_1 = [...]uint8{0, 3}
|
|
_ProtocolIndex_2 = [...]uint8{0, 3}
|
|
_ProtocolIndex_3 = [...]uint8{0, 6}
|
|
)
|
|
|
|
func (i Protocol) String() string {
|
|
switch {
|
|
case i == 1:
|
|
return _ProtocolName_0
|
|
case i == 6:
|
|
return _ProtocolName_1
|
|
case i == 17:
|
|
return _ProtocolName_2
|
|
case i == 58:
|
|
return _ProtocolName_3
|
|
default:
|
|
return fmt.Sprintf("Protocol(%d)", i)
|
|
}
|
|
}
|
|
|
|
var _ProtocolValues = []Protocol{1, 6, 17, 58}
|
|
|
|
var _ProtocolNameToValueMap = map[string]Protocol{
|
|
_ProtocolName_0[0:4]: 1,
|
|
_ProtocolName_1[0:3]: 6,
|
|
_ProtocolName_2[0:3]: 17,
|
|
_ProtocolName_3[0:6]: 58,
|
|
}
|
|
|
|
// ProtocolString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func ProtocolString(s string) (Protocol, error) {
|
|
if val, ok := _ProtocolNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to Protocol values", s)
|
|
}
|
|
|
|
// ProtocolValues returns all values of the enum
|
|
func ProtocolValues() []Protocol {
|
|
return _ProtocolValues
|
|
}
|
|
|
|
// IsAProtocol returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i Protocol) IsAProtocol() bool {
|
|
for _, v := range _ProtocolValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for Protocol
|
|
func (i Protocol) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for Protocol
|
|
func (i *Protocol) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = ProtocolString(string(text))
|
|
return err
|
|
}
|