Documentation ¶
Overview ¶
Package set A library for managing IP and port nftables sets
Index ¶
- func GenerateElements(keyType nftables.SetDatatype, list []SetData) ([]nftables.SetElement, error)
- func GenerateElementsFromIPv4Address(ipAddresses []string, timeout ...time.Duration) ([]nftables.SetElement, error)
- func GenerateElementsFromIPv6Address(ipAddresses []string, timeout ...time.Duration) ([]nftables.SetElement, error)
- func GenerateElementsFromPort(ports []string, timeout ...time.Duration) ([]nftables.SetElement, error)
- func NetipAddrPortToSetData(addrport netip.AddrPort, timeout ...time.Duration) (SetData, SetData, error)
- func NetipAddrPortsToSetData(addrports []netip.AddrPort, timeout ...time.Duration) ([]SetData, []SetData, error)
- type Set
- type SetData
- func AddressRangeStringToSetData(startString string, endString string, timeout ...time.Duration) (SetData, error)
- func AddressStringToSetData(addressString string, timeout ...time.Duration) (SetData, error)
- func AddressStringsToSetData(addressStrings []string, timeout ...time.Duration) ([]SetData, error)
- func NetIPNetToSetData(net *net.IPNet, timeout ...time.Duration) (SetData, error)
- func NetIPNetsToSetData(nets []*net.IPNet, timeout ...time.Duration) ([]SetData, error)
- func NetIPToSetData(ip net.IP, timeout ...time.Duration) (SetData, error)
- func NetIPsToSetData(ips []net.IP, timeout ...time.Duration) ([]SetData, error)
- func NetipAddrToSetData(ip netip.Addr, timeout ...time.Duration) (SetData, error)
- func NetipAddrsToSetData(ips []netip.Addr, timeout ...time.Duration) ([]SetData, error)
- func NetipPrefixToSetData(prefix netip.Prefix, timeout ...time.Duration) (SetData, error)
- func NetipPrefixesToSetData(prefixes []netip.Prefix, timeout ...time.Duration) ([]SetData, error)
- func PortRangeStringToSetData(startString string, endString string, timeout ...time.Duration) (SetData, error)
- func PortStringToSetData(portString string, timeout ...time.Duration) (SetData, error)
- func PortStringsToSetData(portStrings []string, timeout ...time.Duration) ([]SetData, error)
- func PrefixStringToSetData(prefixString string, timeout ...time.Duration) (SetData, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateElements ¶
func GenerateElements(keyType nftables.SetDatatype, list []SetData) ([]nftables.SetElement, error)
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
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
func (*Set) UpdateElements ¶
Compares incoming set elements with existing set elements and adds/removes the differences.
First return value is true if the set was modified, false if there were no updates. The second and third return values indicate the number of values added and removed from the set, respectively.
type SetData ¶
type SetData struct { Port uint16 PortRangeStart uint16 PortRangeEnd uint16 Address netip.Addr AddressRangeStart netip.Addr AddressRangeEnd netip.Addr Prefix netip.Prefix Timeout time.Duration }
SetData is a struct that is used to create elements of a given set based on the key type of the set
func AddressRangeStringToSetData ¶
func AddressRangeStringToSetData(startString string, endString string, timeout ...time.Duration) (SetData, error)
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 NetIPNetToSetData ¶
Convert net.IPNet to the SetData type
func NetIPNetsToSetData ¶
Convert a list of net.IPNet to the SetData type
func NetIPToSetData ¶
Convert net.IP to the SetData type
func NetIPsToSetData ¶
Convert a list of net.IP to the SetData type
func NetipAddrToSetData ¶
Convert netip.Addr to SetData type
func NetipAddrsToSetData ¶
Convert a list of netip.Addr to SetData type
func NetipPrefixToSetData ¶
Convert netip.Prefix to SetData type
func NetipPrefixesToSetData ¶
Convert a list of netip.Prefix to SetData type
func PortRangeStringToSetData ¶
func PortRangeStringToSetData(startString string, endString string, timeout ...time.Duration) (SetData, error)
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