Documentation ¶
Index ¶
- Constants
- type AttributeType
- type Attributes
- type BasePolicy
- type CadtFlags
- type Conn
- func (c *Conn) Add(name string, entries ...*Entry) error
- func (c *Conn) Close() error
- func (c *Conn) Create(setName, typeName string, revision uint8, family netfilter.ProtoFamily, ...) error
- func (c *Conn) Delete(name string, entries ...*Entry) error
- func (c *Conn) Destroy(name string) error
- func (c *Conn) DestroyAll() error
- func (c *Conn) Flush(name string) error
- func (c *Conn) FlushAll() error
- func (c *Conn) Header(name string) (p *HeaderPolicy, err error)
- func (c *Conn) ListAll() ([]SetPolicy, error)
- func (c *Conn) Protocol() (*ProtocolResponsePolicy, error)
- func (c *Conn) Rename(from, to string) error
- func (c *Conn) Replace(setName, typeName string, revision uint8, family netfilter.ProtoFamily, ...) error
- func (c *Conn) Swap(from, to string) error
- func (c *Conn) Test(name string, options ...EntryOption) error
- func (c *Conn) Type(name string, family netfilter.ProtoFamily) (*TypeResponsePolicy, error)
- type CreateData
- type CreateDataOption
- func CreateDataCadtFlags(v uint32) CreateDataOption
- func CreateDataHashSize(v uint32) CreateDataOption
- func CreateDataMarkMask(v uint32) CreateDataOption
- func CreateDataMaxElem(v uint32) CreateDataOption
- func CreateDataNetMask(v uint8) CreateDataOption
- func CreateDataProbes(v uint8) CreateDataOption
- func CreateDataProto(v uint8) CreateDataOption
- func CreateDataResize(v uint8) CreateDataOption
- func CreateDataSize(v uint32) CreateDataOption
- func CreateDataTimeout(v time.Duration) CreateDataOption
- type CreatePolicy
- type Entries
- type Entry
- type EntryAddDelPolicy
- type EntryOption
- func EntryBytes(v uint64) EntryOption
- func EntryCadtFlags(v uint32) EntryOption
- func EntryCidr(v uint8) EntryOption
- func EntryCidr2(v uint8) EntryOption
- func EntryComment(v string) EntryOption
- func EntryEther(v net.HardwareAddr) EntryOption
- func EntryIP(v net.IP) EntryOption
- func EntryIP2(v net.IP) EntryOption
- func EntryIP2To(v net.IP) EntryOption
- func EntryIPTo(v net.IP) EntryOption
- func EntryIface(v string) EntryOption
- func EntryLineno(v uint32) EntryOption
- func EntryMark(v uint32) EntryOption
- func EntryPackets(v uint64) EntryOption
- func EntryPort(v uint16) EntryOption
- func EntryPortTo(v uint16) EntryOption
- func EntryProto(v uint8) EntryOption
- func EntrySkbMark(v uint64) EntryOption
- func EntrySkbPrio(v uint32) EntryOption
- func EntrySkbQueue(v uint16) EntryOption
- func EntryTimeout(v time.Duration) EntryOption
- type HardwareAddrBox
- type HeaderPolicy
- type IPAddrBox
- type MovePolicy
- type NamePolicy
- type NetUInt32Box
- type NullStringBox
- type ProtocolResponsePolicy
- type SetPolicy
- type TestPolicy
- type TypePolicy
- type TypeResponsePolicy
- type UInt16Box
- type UInt32Box
- type UInt32SecondsDurationBox
- type UInt64Box
- type UInt8Box
Constants ¶
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 SetAttrIPAddrIPV6 )
View Source
const (
Protocol = 6
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 AttrMax 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 AttrName AttrNameRef AttrIP2 AttrCidr2 AttrIP2To AttrIface AttrBytes AttrPackets AttrComment AttrSkbMark AttrSkbPrio AttrSkbQueue )
type Attributes ¶
type BasePolicy ¶
type BasePolicy struct {
Protocol *UInt8Box
}
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 ¶
Dial opens a new Netfilter Netlink connection and returns it wrapped in a Conn structure that implements the Ipset API.
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) DestroyAll ¶
func (*Conn) Protocol ¶
func (c *Conn) Protocol() (*ProtocolResponsePolicy, 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) 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 { HeaderPolicy Data *CreateData }
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
type EntryAddDelPolicy ¶
type EntryAddDelPolicy struct { NamePolicy 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 { NamePolicy TypeName *NullStringBox Revision *UInt8Box Family *UInt8Box }
type MovePolicy ¶
type MovePolicy struct { NamePolicy To *NullStringBox }
type NamePolicy ¶
type NamePolicy struct { BasePolicy 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 { BasePolicy ProtocolMin *UInt8Box }
type SetPolicy ¶
type SetPolicy struct { HeaderPolicy Entries Entries }
type TestPolicy ¶
type TestPolicy struct { NamePolicy Entry *Entry }
type TypePolicy ¶
type TypePolicy struct { BasePolicy TypeName *NullStringBox Family *UInt8Box }
type TypeResponsePolicy ¶
type TypeResponsePolicy struct { TypePolicy Revision *UInt8Box RevisionMin *UInt8Box }
type UInt32SecondsDurationBox ¶ added in v2.2.0
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 (b *UInt32SecondsDurationBox) Get() time.Duration
func (*UInt32SecondsDurationBox) IsSet ¶ added in v2.2.0
func (b *UInt32SecondsDurationBox) IsSet() bool
Click to show internal directories.
Click to hide internal directories.