github.com/yaling888/clash@v1.53.0/component/ipset/ipset_linux.go (about)

     1  //go:build linux
     2  
     3  package ipset
     4  
     5  import (
     6  	"net/netip"
     7  
     8  	"github.com/vishvananda/netlink"
     9  )
    10  
    11  // Test whether the ip is in the set or not
    12  func Test(setName string, ip netip.Addr) (bool, error) {
    13  	return netlink.IpsetTest(setName, &netlink.IPSetEntry{
    14  		IP: ip.AsSlice(),
    15  	})
    16  }
    17  
    18  // Verify dumps a specific ipset to check if we can use the set normally
    19  func Verify(setName string) error {
    20  	_, err := netlink.IpsetList(setName)
    21  	return err
    22  }