package module
Version: v2.2.1 Latest Latest

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 7 Imported by: 6



CircleCI Codecov Go Report Card




View Source
const (

	// Message types and commands
	CmdProtocol messageType //  1: Return protocol version
	CmdCreate               //  2: Create a new (empty) set
	CmdDestroy              //  3: Destroy a (empty) set
	CmdFlush                //  4: Remove all elements from a set
	CmdRename               //  5: Rename a set
	CmdSwap                 //  6: Swap two sets
	CmdList                 //  7: List sets
	CmdSave                 //  8: Save sets
	CmdAdd                  //  9: Add an element to a set
	CmdDel                  // 10: Delete an element from a set
	CmdTest                 // 11: Test an element in a set
	CmdHeader               // 12: Get set header data only
	CmdType                 // 13: Get set type
View Source
const (
	SetAttrIPAddrIPV4 uint16
View Source
const (
	Protocol = 6


This section is empty.


This section is empty.


type AttributeType

type AttributeType int
const (

	// Attributes at command level
	AttrProtocol    AttributeType //  1: Protocol version
	AttrSetName                   //  2: Name of the set
	AttrTypeName                  //  3: Typename
	AttrRevision                  //  4: Settype revision
	AttrFamily                    //  5: Settype family
	AttrFlags                     //  6: Flags at command level
	AttrData                      //  7: Nested attributes
	AttrADT                       //  8: Multiple data containers
	AttrLineNo                    //  9: Restore lineno
	AttrProtocolMin               // 10: Minimal supported version number

	AttrRevisionMin = AttrProtocolMin
	AttrSetName2    = AttrTypeName
const (

	// CADT specific attributes
	AttrIP         AttributeType //  1:
	AttrIPTo                     //  2:
	AttrCidr                     //  3:
	AttrPort                     //  4:
	AttrPortTo                   //  5:
	AttrTimeout                  //  6:
	AttrProto                    //  7:
	AttrCadtFlags                //  8:
	AttrCadtLineNo               //  9:
	AttrMark                     // 10:
	AttrMarkMask                 // 11:
	AttrCadtMax    = 16
const (

	// Create-only specific attributes.
	AttrGc       AttributeType // 17:
	AttrHashSize               // 18:
	AttrMaxElem                // 19:
	AttrNetmask                // 20:
	AttrProbes                 // 21:
	AttrResize                 // 22:
	AttrSize                   // 23:

	// Kernel-only
	AttrElements   // 24:
	AttrReferences // 25:
	AttrMemSize    // 26:
const (

	// ADT specific attributes
	AttrEther AttributeType

type Attributes

type Attributes []netfilter.Attribute

type BasePolicy

type BasePolicy struct {
	Protocol *UInt8Box

type CadtFlags

type CadtFlags uint32
const (
	Before CadtFlags = 1 << iota

type Conn

type Conn struct {
	Family netfilter.ProtoFamily
	Conn   connector

Conn represents a Netlink connection to the Netfilter subsystem and implements all Ipset actions.

func Dial

func Dial(family netfilter.ProtoFamily, config *netlink.Config) (*Conn, error)

Dial opens a new Netfilter Netlink connection and returns it wrapped in a Conn structure that implements the Ipset API.

func (*Conn) Add

func (c *Conn) Add(name string, entries ...*Entry) error

func (*Conn) Close added in v2.2.1

func (c *Conn) Close() error

func (*Conn) Create

func (c *Conn) Create(setName, typeName string, revision uint8, family netfilter.ProtoFamily, options ...CreateDataOption) error

Create creates a new set, returning an error if the set already exists.

func (*Conn) Delete

func (c *Conn) Delete(name string, entries ...*Entry) error

func (*Conn) Destroy

func (c *Conn) Destroy(name string) error

func (*Conn) DestroyAll

func (c *Conn) DestroyAll() error

func (*Conn) Flush

func (c *Conn) Flush(name string) error

func (*Conn) FlushAll

func (c *Conn) FlushAll() error

func (*Conn) Header

func (c *Conn) Header(name string) (p *HeaderPolicy, err error)

func (*Conn) ListAll

func (c *Conn) ListAll() ([]SetPolicy, error)

func (*Conn) Protocol

func (c *Conn) Protocol() (*ProtocolResponsePolicy, error)

func (*Conn) Rename

func (c *Conn) Rename(from, to string) error

func (*Conn) Replace added in v2.1.0

func (c *Conn) Replace(setName, typeName string, revision uint8, family netfilter.ProtoFamily, options ...CreateDataOption) error

Replace replaces a given set if it already exists, creating a new one otherwise.

func (*Conn) Swap

func (c *Conn) Swap(from, to string) error

func (*Conn) Test

func (c *Conn) Test(name string, options ...EntryOption) error

func (*Conn) Type

func (c *Conn) Type(name string, family netfilter.ProtoFamily) (*TypeResponsePolicy, error)

type CreateData

type CreateData struct {
	CadtFlags *UInt32Box
	HashSize  *UInt32Box
	MarkMask  *UInt32Box
	MaxElem   *UInt32Box
	NetMask   *UInt8Box
	Probes    *UInt8Box
	Proto     *UInt8Box
	Resize    *UInt8Box
	Size      *UInt32Box
	Timeout   *UInt32SecondsDurationBox

func (*CreateData) IsSet

func (d *CreateData) IsSet() bool

type CreateDataOption

type CreateDataOption func(d *CreateData)

func CreateDataCadtFlags

func CreateDataCadtFlags(v uint32) CreateDataOption

func CreateDataHashSize

func CreateDataHashSize(v uint32) CreateDataOption

func CreateDataMarkMask

func CreateDataMarkMask(v uint32) CreateDataOption

func CreateDataMaxElem

func CreateDataMaxElem(v uint32) CreateDataOption

func CreateDataNetMask

func CreateDataNetMask(v uint8) CreateDataOption

func CreateDataProbes

func CreateDataProbes(v uint8) CreateDataOption

func CreateDataProto

func CreateDataProto(v uint8) CreateDataOption

func CreateDataResize

func CreateDataResize(v uint8) CreateDataOption

func CreateDataSize

func CreateDataSize(v uint32) CreateDataOption

func CreateDataTimeout

func CreateDataTimeout(v time.Duration) CreateDataOption

type CreatePolicy

type CreatePolicy struct {

	Data *CreateData

type Entries

type Entries []*Entry

func (Entries) IsSet

func (e Entries) IsSet() bool

type Entry

type Entry struct {
	Bytes     *UInt64Box
	CadtFlags *UInt32Box
	Cidr2     *UInt8Box
	Cidr      *UInt8Box
	Comment   *NullStringBox
	Ether     *HardwareAddrBox
	Iface     *NullStringBox
	IP2To     *IPAddrBox
	IP2       *IPAddrBox
	IPTo      *IPAddrBox
	IP        *IPAddrBox
	Lineno    *NetUInt32Box
	Mark      *UInt32Box
	Packets   *UInt64Box
	PortTo    *UInt16Box
	Port      *UInt16Box
	Proto     *UInt8Box
	Skbmark   *UInt64Box
	Skbprio   *UInt32Box
	Skbqueue  *UInt16Box
	Timeout   *UInt32SecondsDurationBox

func NewEntry

func NewEntry(setters ...EntryOption) *Entry

func (*Entry) IsSet

func (e *Entry) IsSet() bool

type EntryAddDelPolicy

type EntryAddDelPolicy struct {

	LineNo *NetUInt32Box

	Entries Entries

type EntryOption

type EntryOption func(*Entry)

func EntryBytes

func EntryBytes(v uint64) EntryOption

func EntryCadtFlags

func EntryCadtFlags(v uint32) EntryOption

func EntryCidr

func EntryCidr(v uint8) EntryOption

func EntryCidr2

func EntryCidr2(v uint8) EntryOption

func EntryComment

func EntryComment(v string) EntryOption

func EntryEther

func EntryEther(v net.HardwareAddr) EntryOption

func EntryIP

func EntryIP(v net.IP) EntryOption

func EntryIP2

func EntryIP2(v net.IP) EntryOption

func EntryIP2To

func EntryIP2To(v net.IP) EntryOption

func EntryIPTo

func EntryIPTo(v net.IP) EntryOption

func EntryIface

func EntryIface(v string) EntryOption

func EntryLineno

func EntryLineno(v uint32) EntryOption

func EntryMark

func EntryMark(v uint32) EntryOption

func EntryPackets

func EntryPackets(v uint64) EntryOption

func EntryPort

func EntryPort(v uint16) EntryOption

func EntryPortTo

func EntryPortTo(v uint16) EntryOption

func EntryProto

func EntryProto(v uint8) EntryOption

func EntrySkbMark

func EntrySkbMark(v uint64) EntryOption

func EntrySkbPrio

func EntrySkbPrio(v uint32) EntryOption

func EntrySkbQueue

func EntrySkbQueue(v uint16) EntryOption

func EntryTimeout

func EntryTimeout(v time.Duration) EntryOption

type HardwareAddrBox

type HardwareAddrBox struct{ Value net.HardwareAddr }

Hardware Address

func NewHardwareAddrBox

func NewHardwareAddrBox(v net.HardwareAddr) *HardwareAddrBox

func (*HardwareAddrBox) Get

func (b *HardwareAddrBox) Get() net.HardwareAddr

func (*HardwareAddrBox) IsSet

func (b *HardwareAddrBox) IsSet() bool

type HeaderPolicy

type HeaderPolicy struct {

	TypeName *NullStringBox
	Revision *UInt8Box
	Family   *UInt8Box

type IPAddrBox

type IPAddrBox struct{ Value net.IP }

IP Address

func NewIPAddrBox

func NewIPAddrBox(v net.IP) *IPAddrBox

func (*IPAddrBox) Get

func (b *IPAddrBox) Get() net.IP

func (*IPAddrBox) IsSet

func (b *IPAddrBox) IsSet() bool

type MovePolicy

type MovePolicy struct {

	To *NullStringBox

type NamePolicy

type NamePolicy struct {

	Name *NullStringBox

type NetUInt32Box

type NetUInt32Box struct{ UInt32Box }

Uint32 in Network Byte Order

func NewNetUInt32Box

func NewNetUInt32Box(v uint32) *NetUInt32Box

func (*NetUInt32Box) IsSet

func (b *NetUInt32Box) IsSet() bool

type NullStringBox

type NullStringBox struct{ Value string }

Null-Byte terminated string

func NewNullStringBox

func NewNullStringBox(v string) *NullStringBox

func (*NullStringBox) Get

func (b *NullStringBox) Get() string

func (*NullStringBox) IsSet

func (b *NullStringBox) IsSet() bool

func (*NullStringBox) String

func (b *NullStringBox) String() string

type ProtocolResponsePolicy

type ProtocolResponsePolicy struct {

	ProtocolMin *UInt8Box

type SetPolicy

type SetPolicy struct {

	Entries Entries

type TestPolicy

type TestPolicy struct {

	Entry *Entry

type TypePolicy

type TypePolicy struct {

	TypeName *NullStringBox
	Family   *UInt8Box

type TypeResponsePolicy

type TypeResponsePolicy struct {

	Revision    *UInt8Box
	RevisionMin *UInt8Box

type UInt16Box

type UInt16Box struct{ Value uint16 }


func NewUInt16Box

func NewUInt16Box(v uint16) *UInt16Box

func (*UInt16Box) Get

func (b *UInt16Box) Get() uint16

func (*UInt16Box) IsSet

func (b *UInt16Box) IsSet() bool

func (*UInt16Box) String

func (b *UInt16Box) String() string

type UInt32Box

type UInt32Box struct{ Value uint32 }


func NewUInt32Box

func NewUInt32Box(v uint32) *UInt32Box

func (*UInt32Box) Get

func (b *UInt32Box) Get() uint32

func (*UInt32Box) IsSet

func (b *UInt32Box) IsSet() bool

func (*UInt32Box) String

func (b *UInt32Box) String() string

type UInt32SecondsDurationBox added in v2.2.0

type UInt32SecondsDurationBox struct{ time.Duration }

UInt32SecondsDurationBox implements a netlink field that stores a duration in seconds with network byte order and 32bit width.

func NewUInt32SecondsDurationBox added in v2.2.0

func NewUInt32SecondsDurationBox(d time.Duration) *UInt32SecondsDurationBox

func (*UInt32SecondsDurationBox) Get added in v2.2.0

func (*UInt32SecondsDurationBox) IsSet added in v2.2.0

func (b *UInt32SecondsDurationBox) IsSet() bool

type UInt64Box

type UInt64Box struct{ Value uint64 }


func NewUInt64Box

func NewUInt64Box(v uint64) *UInt64Box

func (*UInt64Box) Get

func (b *UInt64Box) Get() uint64

func (*UInt64Box) IsSet

func (b *UInt64Box) IsSet() bool

func (*UInt64Box) String

func (b *UInt64Box) String() string

type UInt8Box

type UInt8Box struct{ Value uint8 }


func NewUInt8Box

func NewUInt8Box(v uint8) *UInt8Box

func (*UInt8Box) Get

func (b *UInt8Box) Get() uint8

func (*UInt8Box) IsSet

func (b *UInt8Box) IsSet() bool

func (*UInt8Box) String

func (b *UInt8Box) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL