Use tutorials and feature updates (Google Translate)
steamsv opened this issue · comments
steamsv commented
老哥,这个库咋用,是否有详细教程,能否增加http api 操作?
谢谢老哥,我是个小白,有时间的话,能否接个二开的单,也是golang操作ipset的
nadoo commented
Please see the README file, it's very simple:
package main
import (
"log"
"github.com/nadoo/ipset"
)
func main() {
// must call Init first
if err := ipset.Init(); err != nil {
log.Printf("error in ipset Init: %s", err)
return
}
// default is ipv4 without timeout
ipset.Destroy("myset")
ipset.Create("myset")
ipset.Add("myset", "1.1.1.1")
ipset.Add("myset", "2.2.2.0/24")
// ipv6 and timeout example
// ipset create myset6 hash:net family inet6 timeout 60
ipset.Create("myset6", ipset.OptIPv6(), ipset.OptTimeout(60))
ipset.Flush("myset6")
ipset.Add("myset6", "2022::1", ipset.OptTimeout(10))
ipset.Add("myset6", "2022::1/32")
}
and you can also see how glider uses it:
https://github.com/nadoo/glider/blob/dev/ipset/ipset_linux.go