go-ipset provides basic bindings for the ipset kernel utility.
go get github.com/gmccue/go-ipset
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.
}err := ipset.Add("my_set", "127.0.0.1")
if err != nil {
// Your custom error handling here.
}if err != nil {
// Your custom error handling here.
}err := ipset.Save("my_set", "/tmp/my_set.txt")
if err != nil {
// Your custom error handling here.
}err := ipset.Restore("/tmp/my_set.txt")
if err != nil {
// Your custom error handling here.
}