Help us shape the future of Go! Take the 2026 Go Developer Survey

ipset

package module
v0.0.0-...-4d5749c Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 7 Imported by: 0

README

go-ipset

These are bindings to libipset3. Currently there is only support for listing sets and adding/removing entries to/from existing sets. If you need a more feature-rich library then take a look at janeczku/go-ipset.

Installation

Install dependencies:

On Debian/Ubuntu execute:

apt install libipset-dev pkg-config

Install go-ipset using the go get command:

go get github.com/digineo/go-ipset

Usage

Create the ipset before:

ipset create myset hash:ip timeout 0

Add the import to your program:

import "github.com/digineo/go-ipset"
List all sets
ipset.ListAll()
List a single set
ipset.List("myset")
Add a single entry to the set
ipset.Add("myset", "192.0.2.23")                  // without timeout
ipset.Add("myset", "192.0.2.23", "timeout", "42") // with timeout
Remove a single entry from the set
ipset.Del("myset", "192.0.2.23")

Documentation

Overview

Package ipset contains bindings to libipset Requirements: apt install ipset-dev

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(setname, address string, args ...string) error

Add adds a new entry to an existing set

func Del

func Del(setname, address string, args ...string) error

Del deletes an entry from an existing set

func Test

func Test(setname, address string, args ...string) error

Test an entry from an existing set

Types

type Header struct {
	Family     string `xml:"family"`
	HashSize   int    `xml:"hashsize"`
	MaxElem    int    `xml:"maxelem"`
	Timeout    int    `xml:"timeout"`
	MemSize    int    `xml:"memsize"`
	References int    `xml:"references"`
	NumEntries int    `xml:"numentries"`
}

Header is the header of an ipset result

type IPSet

type IPSet struct {
	Type     string   `xml:"type"`
	Revision byte     `xml:"revision"`
	Name     string   `xml:"name,attr"`
	Header   Header   `xml:"header"`
	Members  []Member `xml:"members>member"`
}

IPSet represents a returned ipset

func List

func List(setname string) (*IPSet, error)

List returns a single ipset

func ListAll

func ListAll() ([]IPSet, error)

ListAll returns all ipsets

type ListResult

type ListResult struct {
	Sets []IPSet `xml:"ipset"`
}

ListResult is the result of a LIST command

type Member

type Member struct {
	Elem    string `xml:"elem"`
	Timeout int    `xml:"timeout"`
}

Member is the entry of an ipset

Directories

Path Synopsis
cmd
go-ipset command

Jump to

Keyboard shortcuts

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