Documentation ¶
Overview ¶
Package ipset is a library providing a wrapper to the IPtables ipset userspace utility
Index ¶
- Constants
- func DestroyAll(prefix string) error
- func Init(name string) error
- func Swap(from, to string) error
- type IPSet
- func (s *IPSet) Add(entry string, timeout int) error
- func (s *IPSet) AddOption(entry string, option string, timeout int) error
- func (s *IPSet) Del(entry string) error
- func (s *IPSet) Destroy() error
- func (s *IPSet) Flush() error
- func (s *IPSet) List() ([]string, error)
- func (s *IPSet) ListTerse() ([]string, error)
- func (s *IPSet) Refresh(entries []string) error
- func (s *IPSet) Statistics() (stats Stats, err error)
- func (s *IPSet) Test(entry string) (bool, error)
- type Params
- type Stats
Constants ¶
const (
AllSets = ""
)
Variables ¶
This section is empty.
Functions ¶
func DestroyAll ¶ added in v1.0.0
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
Types ¶
type IPSet ¶
type IPSet struct { Name string HashType string HashFamily string HashSize int MaxElem int Timeout int }
IPSet implements an Interface to an set.
func New ¶
New creates a new set and returns an Interface to it. Example:
testIpset := ipset.New("test", "hash:ip", &ipset.Params{})
func (*IPSet) Add ¶
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 ¶ added in v1.0.0
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) ListTerse ¶ added in v1.8.3
ListTerse is used to show the name and statistics for a set
func (*IPSet) Refresh ¶
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) Statistics ¶ added in v1.8.3
Statistics returns the details of the set in a Stats data structure. The details are obtained by parsing the output of `ipset -l list set_name` command. Here is the (line oriented) format of the output:
Name: set_name Type: hash:ip Revision: 4 Header: family inet hashsize 1024 maxelem 65536 timeout 0 Size in memory: 296 References: 2 Number of entries: 1