Documentation ¶
Index ¶
- Constants
- func AddToSet(fd int, lsa syscall.SockaddrNetlink, setName, entry string)
- func BytesToString(b []byte) string
- func CreateSet(fd int, lsa syscall.SockaddrNetlink, setName string)
- func FlushSet(fd int, lsa syscall.SockaddrNetlink, setName string)
- func NativeEndian() binary.ByteOrder
- func NonZeroTerminated(s string) []byte
- func Uint16Attr(v uint16) []byte
- func Uint32Attr(v uint32) []byte
- func Uint8Attr(v uint8) []byte
- func ZeroTerminated(s string) []byte
- type Manager
- type NetlinkRequest
- type NetlinkRequestData
- type NfGenMsg
- type RtAttr
Constants ¶
const ( IPSET_CMD_CREATE = 2 IPSET_CMD_FLUSH = 4 IPSET_CMD_ADD = 9 IPSET_CMD_DEL = 10 )
Message types and commands
const ( IPSET_ATTR_PROTOCOL = 1 /* 1: Protocol version */ IPSET_ATTR_SETNAME = 2 /* 2: Name of the set */ IPSET_ATTR_TYPENAME = 3 /* 3: Typename */ IPSET_ATTR_REVISION = 4 /* 4: Settype revision */ IPSET_ATTR_FAMILY = 5 /* 5: Settype family */ IPSET_ATTR_DATA = 7 /* 7: Nested attributes */ )
Attributes at command level
const ( IPSET_ATTR_IP = 1 IPSET_ATTR_CIDR = 3 )
CADT specific attributes
const ( IPSET_ATTR_IPADDR_IPV4 = 1 IPSET_ATTR_IPADDR_IPV6 = 2 )
IP specific attributes
const ( NLA_F_NESTED = (1 << 15) NLA_F_NET_BYTEORDER = (1 << 14) )
ATTR flags
const IPSET_MAXNAMELEN = 32
IPSET_MAXNAMELEN The max length of strings including NUL: set and type identifiers
const IPSET_PROTOCOL = 6
IPSET_PROTOCOL The protocol version http://git.netfilter.org/ipset/tree/include/libipset/linux_ip_set.h
const NFNL_SUBSYS_IPSET = 6
NFNL_SUBSYS_IPSET netfilter netlink message types https://github.com/torvalds/linux/blob/9e66317d3c92ddaab330c125dfe9d06eee268aff/include/uapi/linux/netfilter/nfnetlink.h#L56
Variables ¶
This section is empty.
Functions ¶
func AddToSet ¶
func AddToSet(fd int, lsa syscall.SockaddrNetlink, setName, entry string)
AddToSet adds an entry to ipset
func CreateSet ¶
func CreateSet(fd int, lsa syscall.SockaddrNetlink, setName string)
CreateSet create a ipset
func FlushSet ¶
func FlushSet(fd int, lsa syscall.SockaddrNetlink, setName string)
FlushSet flush a ipset
func NativeEndian ¶
NativeEndian get native endianness for the system
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager struct
func NewManager ¶
NewManager returns a Manager
func (*Manager) AddDomainIP ¶
AddDomainIP implements the DNSAnswerHandler function, used to update ipset according to domainSet rule
type NetlinkRequest ¶
type NetlinkRequest struct { syscall.NlMsghdr Data []NetlinkRequestData RawData []byte }
NetlinkRequest .
func NewNetlinkRequest ¶
func NewNetlinkRequest(proto, flags int) *NetlinkRequest
NewNetlinkRequest create a new netlink request from proto and flags Note the Len value will be inaccurate once data is added until the message is serialized
func (*NetlinkRequest) AddData ¶
func (req *NetlinkRequest) AddData(data NetlinkRequestData)
AddData add data to request
func (*NetlinkRequest) AddRawData ¶
func (req *NetlinkRequest) AddRawData(data []byte)
AddRawData adds raw bytes to the end of the NetlinkRequest object during serialization
func (*NetlinkRequest) Serialize ¶
func (req *NetlinkRequest) Serialize() []byte
Serialize the Netlink Request into a byte array
type NetlinkRequestData ¶
NetlinkRequestData .