ipset

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 8 Imported by: 10

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestroyAll added in v1.0.0

func DestroyAll() error

DestroyAll is used to destroy the set.

func Swap

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.

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

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

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 added in v1.0.0

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

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

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

func (*IPSet) Destroy

func (s *IPSet) Destroy() error

Destroy is used to destroy the set.

func (*IPSet) Flush

func (s *IPSet) Flush() error

Flush is used to flush all entries in the set.

func (*IPSet) List added in v1.0.0

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

List is used to show the contents of a set

func (*IPSet) Refresh

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

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

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

Params defines optional parameters for creating a new set.

Jump to

Keyboard shortcuts

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