ipset

package
v0.6.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2018 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPSET_CMD_CREATE = 2
	IPSET_CMD_FLUSH  = 4
	IPSET_CMD_ADD    = 9
	IPSET_CMD_DEL    = 10
)

Message types and commands

View Source
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

View Source
const (
	IPSET_ATTR_IP   = 1
	IPSET_ATTR_CIDR = 3
)

CADT specific attributes

View Source
const (
	IPSET_ATTR_IPADDR_IPV4 = 1
	IPSET_ATTR_IPADDR_IPV6 = 2
)

IP specific attributes

View Source
const (
	NLA_F_NESTED        = (1 << 15)
	NLA_F_NET_BYTEORDER = (1 << 14)
)

ATTR flags

View Source
const IPSET_MAXNAMELEN = 32

IPSET_MAXNAMELEN The max length of strings including NUL: set and type identifiers

View Source
const IPSET_PROTOCOL = 6

IPSET_PROTOCOL The protocol version http://git.netfilter.org/ipset/tree/include/libipset/linux_ip_set.h

View Source
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 BytesToString

func BytesToString(b []byte) string

BytesToString .

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

func NativeEndian() binary.ByteOrder

NativeEndian get native endianness for the system

func NonZeroTerminated

func NonZeroTerminated(s string) []byte

NonZeroTerminated .

func Uint16Attr

func Uint16Attr(v uint16) []byte

Uint16Attr .

func Uint32Attr

func Uint32Attr(v uint32) []byte

Uint32Attr .

func Uint8Attr

func Uint8Attr(v uint8) []byte

Uint8Attr .

func ZeroTerminated

func ZeroTerminated(s string) []byte

ZeroTerminated .

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager struct

func NewManager

func NewManager(mainSet string, rules []*rule.Config) (*Manager, error)

NewManager returns a Manager

func (*Manager) AddDomainIP

func (m *Manager) AddDomainIP(domain, ip string) error

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

type NetlinkRequestData interface {
	Len() int
	Serialize() []byte
}

NetlinkRequestData .

type NfGenMsg

type NfGenMsg struct {
	// contains filtered or unexported fields
}

NfGenMsg .

func NewNfGenMsg

func NewNfGenMsg(nfgenFamily, version, resID int) *NfGenMsg

NewNfGenMsg .

func (*NfGenMsg) Len

func (m *NfGenMsg) Len() int

Len .

func (*NfGenMsg) Serialize

func (m *NfGenMsg) Serialize() []byte

Serialize .

type RtAttr

type RtAttr struct {
	syscall.RtAttr
	Data []byte
	// contains filtered or unexported fields
}

RtAttr Extend RtAttr to handle data and children

func NewRtAttr

func NewRtAttr(attrType int, data []byte) *RtAttr

NewRtAttr Create a new Extended RtAttr object

func NewRtAttrChild

func NewRtAttrChild(parent *RtAttr, attrType int, data []byte) *RtAttr

NewRtAttrChild Create a new RtAttr obj anc add it as a child of an existing object

func (*RtAttr) Len

func (a *RtAttr) Len() int

Len .

func (*RtAttr) Serialize

func (a *RtAttr) Serialize() []byte

Serialize the RtAttr into a byte array This can't just unsafe.cast because it must iterate through children.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL