change ipset type to hash:net
This commit is contained in:
parent
3e42d0deb0
commit
b446b5969f
2
group.go
2
group.go
@ -22,7 +22,7 @@ type Group struct {
|
||||
|
||||
func (g *Group) AddIPv4(address net.IP, ttl time.Duration) error {
|
||||
ttlSeconds := uint32(ttl.Seconds())
|
||||
return g.ipset.Add(address, &ttlSeconds)
|
||||
return g.ipset.AddIP(address, &ttlSeconds)
|
||||
}
|
||||
|
||||
func (g *Group) DelIPv4(address net.IP) error {
|
||||
|
@ -11,7 +11,7 @@ type IPSet struct {
|
||||
SetName string
|
||||
}
|
||||
|
||||
func (r *IPSet) Add(addr net.IP, timeout *uint32) error {
|
||||
func (r *IPSet) AddIP(addr net.IP, timeout *uint32) error {
|
||||
err := netlink.IpsetAdd(r.SetName, &netlink.IPSetEntry{
|
||||
IP: addr,
|
||||
Timeout: timeout,
|
||||
@ -63,7 +63,7 @@ func (nh *NetfilterHelper) IPSet(name string) (*IPSet, error) {
|
||||
}
|
||||
|
||||
defaultTimeout := uint32(300)
|
||||
err = netlink.IpsetCreate(ipset.SetName, "hash:ip", netlink.IpsetCreateOptions{
|
||||
err = netlink.IpsetCreate(ipset.SetName, "hash:net", netlink.IpsetCreateOptions{
|
||||
Timeout: &defaultTimeout,
|
||||
})
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user