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

ipset

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: GPL-3.0 Imports: 1 Imported by: 14

README

ipset

Go Report Card GitHub tag PkgGoDev

ipset package for Go via netlink socket.

Usage

Your code:
package main

import (
	"log"

	"github.com/nadoo/ipset"
)

func main() {
	err := ipset.Init()
	if err != nil {
		log.Printf("error in ipset Init: %s", err)
		return
	}

	ipset.Create("myset")

	ipset.Add("myset", "1.1.1.1")
	ipset.Flush("myset")

	ipset.Add("myset", "192.168.1.0/24")
	ipset.Del("myset", "192.168.1.0/24")

	ipset.Add("myset", "2.2.2.2")
}
Result:

ipset list myset

Name: myset
Type: hash:net
Revision: 1
Header: family inet hashsize 1024 maxelem 65536
Size in memory: 408
References: 0
Number of entries: 1
Members:
2.2.2.2
  • glider: a forward proxy with ipset management features powered by this package.
  • dnsmasq: ipset implementation reference from dnsmasq.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(setName, entry string) (err error)

Add adds an entry to the named set. entry could be: "1.1.1.1" or "192.168.1.0/24".

func Create

func Create(setName string) (err error)

Create creates a new set.

func Del

func Del(setName, entry string) (err error)

Del deletes an entry from the named set.

func Flush

func Flush(setName string) (err error)

Flush flushes a named set.

func Init added in v0.2.0

func Init() (err error)

Init prepares a netlink socket of ipset.

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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