Skip to content

Latest commit

 

History

History
61 lines (50 loc) · 1.35 KB

README.md

File metadata and controls

61 lines (50 loc) · 1.35 KB

go-ipset

Build Status GoDoc

go-ipset provides basic bindings for the ipset kernel utility.

Installation

go get github.com/gmccue/go-ipset

Usage

The following are some basic usage examples for go-iptables. For more information, please checkout the godoc.

import "github.com/gmccue/ipset"

// Construct a new ipset instance
ipset, err := ipset.New()
if err != nil {
    // Your custom error handling here.
}

// Create a new set
err := ipset.Create("my_set", "hash:ip")
if err != nil {
    // Your custom error handling here.
}

Adding an entry to an ipset

err := ipset.Add("my_set", "127.0.0.1")
if err != nil {
    // Your custom error handling here.
}

Removing an entry from an ipset

if err != nil {
    // Your custom error handling here.
}

Save your ipset to a file

err := ipset.Save("my_set", "/tmp/my_set.txt")
if err != nil {
    // Your custom error handling here.
}

Restore your ipset from a file

err := ipset.Restore("/tmp/my_set.txt")
if err != nil {
    // Your custom error handling here.
}