Documentation
¶
Overview ¶
A library for managing IP and port nftables sets
Index ¶
- func NetipAddrPortToSetData(addrport netip.AddrPort) (SetData, SetData, error)
- func NetipAddrPortsToSetData(addrports []netip.AddrPort) ([]SetData, []SetData, error)
- type ManagedSet
- type Set
- type SetData
- func AddressBytesToSetData(start []byte, end []byte) (SetData, error)
- func AddressRangeStringToSetData(startString string, endString string) (SetData, error)
- func AddressStringToSetData(addressString string) (SetData, error)
- func AddressStringsToSetData(addressStrings []string) ([]SetData, error)
- func NetIPNetToSetData(net *net.IPNet) (SetData, error)
- func NetIPNetsToSetData(nets []*net.IPNet) ([]SetData, error)
- func NetIPToSetData(ip net.IP) (SetData, error)
- func NetIPsToSetData(ips []net.IP) ([]SetData, error)
- func NetipAddrToSetData(ip netip.Addr) (SetData, error)
- func NetipAddrsToSetData(ips []netip.Addr) ([]SetData, error)
- func NetipPrefixToSetData(prefix netip.Prefix) (SetData, error)
- func NetipPrefixesToSetData(prefixes []netip.Prefix) ([]SetData, error)
- func PortBytesToSetData(start []byte, end []byte) (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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NetipAddrPortToSetData ¶ added in v0.0.5
Convert netip.AddrPort to SetData type, returns a address and a port
Types ¶
type ManagedSet ¶
type ManagedSet struct {
// contains filtered or unexported fields
}
Represents a set managed by the manager goroutine
func ManagerInit ¶ added in v0.0.2
func ManagerInit(set Set, f SetUpdateFunc, interval time.Duration, logger logger.Logger, metrics m.Metrics) (ManagedSet, error)
Create a set manager. Passing a nil metrics object is safe and will result in the "NoOp" client being used.
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 // contains filtered or unexported fields }
SetData is a struct that is used to create elements of a given set based on the key type of the set
func AddressBytesToSetData ¶ added in v0.0.14
Convert start and end address bytes to SetData type
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 NetIPNetToSetData ¶ added in v0.0.5
Convert net.IPNet to the SetData type
func NetIPNetsToSetData ¶ added in v0.0.5
Convert a list of net.IPNet to the SetData type
func NetIPToSetData ¶ added in v0.0.5
Convert net.IP to the SetData type
func NetIPsToSetData ¶ added in v0.0.5
Convert a list of net.IP to the SetData type
func NetipAddrToSetData ¶ added in v0.0.5
Convert netip.Addr to SetData type
func NetipAddrsToSetData ¶ added in v0.0.5
Convert a list of netip.Addr to SetData type
func NetipPrefixToSetData ¶ added in v0.0.5
Convert netip.Prefix to SetData type
func NetipPrefixesToSetData ¶ added in v0.0.5
Convert a list of netip.Prefix to SetData type
func PortBytesToSetData ¶ added in v0.0.14
Convert start and end port bytes to 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