go-ipset: github.com/aporeto-inc/go-ipset/ipset Index | Files

package ipset

import "github.com/aporeto-inc/go-ipset/ipset"

Package ipset is a library providing a wrapper to the IPtables ipset userspace utility

Index

Package Files

ipset.go

Constants

const (
    AllSets = ""
)

func DestroyAll Uses

func DestroyAll(prefix string) error

DestroyAll is used to destroy the set. The prefix may be a prefix string or the constant ipset.AllSets to specify that all existing sets should be destroyed Note that attempting to destroy a set that is in use will result in an error being returned.

I use the variadic form here to preserve the original API with no arguments. i.e. DestroyAll() with no arguments will still work.

DestroyAll("") and DestroyAll(ipset.AllSets) are equivalent to DestroyAll()

DestroyAll("prefix") is new functionality Note that the variadic allows for DestroyAll("prefix1", "prefix2") but all arguments after prefix1 are currently ignored

func Init Uses

func Init(name string) error

Init sets up the package with the named ipset or default

func Swap Uses

func Swap(from, to string) error

Swap is used to hot swap two sets on-the-fly. Use with names of existing sets of the same type.

type IPSet Uses

type IPSet struct {
    Name       string
    HashType   string
    HashFamily string
    HashSize   int
    MaxElem    int
    Timeout    int
}

IPSet implements an Interface to an set.

func New Uses

func New(name string, hashtype string, p *Params) (*IPSet, error)

New creates a new set and returns an Interface to it. Example:

testIpset := ipset.New("test", "hash:ip", &ipset.Params{})

func (*IPSet) Add Uses

func (s *IPSet) Add(entry string, timeout int) error

Add is used to add the specified entry to the set. A timeout of 0 means that the entry will be stored permanently in the set.

func (*IPSet) AddOption Uses

func (s *IPSet) AddOption(entry string, option string, timeout int) error

AddOption is used to add the specified entry to the set. A timeout of 0 means that the entry will be stored permanently in the set.

func (*IPSet) Del Uses

func (s *IPSet) Del(entry string) error

Del is used to delete the specified entry from the set.

func (*IPSet) Destroy Uses

func (s *IPSet) Destroy() error

Destroy is used to destroy the set.

func (*IPSet) Flush Uses

func (s *IPSet) Flush() error

Flush is used to flush all entries in the set.

func (*IPSet) List Uses

func (s *IPSet) List() ([]string, error)

List is used to show the contents of a set

func (*IPSet) Refresh Uses

func (s *IPSet) Refresh(entries []string) error

Refresh is used to to overwrite the set with the specified entries. The ipset is updated on the fly by hot swapping it with a temporary set.

func (*IPSet) Test Uses

func (s *IPSet) Test(entry string) (bool, error)

Test is used to check whether the specified entry is in the set or not.

type Params Uses

type Params struct {
    HashFamily string
    HashSize   int
    MaxElem    int
    Timeout    int
}

Params defines optional parameters for creating a new set.

Package ipset imports 8 packages (graph) and is imported by 6 packages. Updated 2020-10-22. Refresh now. Tools for package owners.