Documentation
¶
Overview ¶
A library for managing IP and port nftables sets
Index ¶
- Constants
- type ManagedSet
- type Set
- type SetData
- func AddressRangeStringToSetData(startString string, endString string) (SetData, error)
- func AddressStringToSetData(addressString string) (SetData, error)
- func AddressStringsToSetData(addressStrings []string) ([]SetData, error)
- func IPNetToSetData(net *net.IPNet) (SetData, error)
- func IPNetsToSetData(nets []*net.IPNet) ([]SetData, error)
- func IPToSetData(ip net.IP) (SetData, error)
- func IPsToSetData(ips []net.IP) ([]SetData, error)
- func PortRangeStringToSetData(startString string, endString string) (SetData, error)
- func PortStringToSetData(portString string) (SetData, error)
- func PortStringsToSetData(portStrings []string) ([]SetData, error)
- func PrefixStringToSetData(prefixString string) (SetData, error)
- type SetUpdateFunc
Constants ¶
const ( // https://datatracker.ietf.org/doc/html/rfc5737#section-3 InitIPv4 = "192.0.2.1" // https://datatracker.ietf.org/doc/html/rfc5156#section-2.6 InitIPv6 = "2001:0db8:85a3:1:1:8a2e:0370:7334" InitPort = "1" )
Constants used temporarily while initialzing a set
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ManagedSet ¶
Represents a set managed by the manager goroutine
func ManagerInit ¶ added in v0.0.2
func ManagerInit(c *nftables.Conn, set Set, f SetUpdateFunc, interval time.Duration, logger logger.Logger) (ManagedSet, error)
Create a set manager
type Set ¶
type Set struct {
Set *nftables.Set
// SetData representation of each of the
// items currently in the set
CurrentSetData map[SetData]struct{}
Mu *sync.Mutex
}
Set represents an nftables a set on a given table
func New ¶
func New(c *nftables.Conn, table *nftables.Table, name string, keyType nftables.SetDatatype) (Set, error)
Create a new set on a table with a given key type
func (*Set) ClearAndAddElements ¶
Remove all elements from the set and then add a list of elements
type SetData ¶
type SetData struct {
Port int
PortRangeStart int
PortRangeEnd int
Address netip.Addr
AddressRangeStart netip.Addr
AddressRangeEnd netip.Addr
Prefix netip.Prefix
}
SetData is a struct that is used to create elements of a given set based on the key type of the set
func AddressRangeStringToSetData ¶
Convert a string address range to the SetData type
func AddressStringToSetData ¶
Convert a string address to the SetData type
func AddressStringsToSetData ¶
Convert a list of string addresses to the SetData type
func IPNetToSetData ¶
Convert net.IPNet to the SetData type
func IPNetsToSetData ¶
Convert a list of net.IPNet to the SetData type
func IPsToSetData ¶
Convert a list of net.IP to the SetData type
func PortRangeStringToSetData ¶
Convert a string port range to the SetData type
func PortStringToSetData ¶
Convert a string port to the SetData type
func PortStringsToSetData ¶
Convert a list string ports to the SetData type
func PrefixStringToSetData ¶
Convert a string prefix/CIDR to the SetData type