26
type NetlinkIpsetDeps interface {
27
ipsetIPPortCreate(name string) error
28
destroySet(name string) error
29
addIP(name string, ip netip.Addr, ipProto uint8, comment string, replace bool) error
30
deleteIP(name string, ip netip.Addr, ipProto uint8) error
31
flush(name string) error
32
clearEntriesWithComment(name, comment string) error
33
clearEntriesWithIP(name string, ip netip.Addr) error
34
listEntriesByIP(name string) ([]netip.Addr, error)
37
func NewIPSet(name string, deps NetlinkIpsetDeps) (IPSet, error) {
42
err := deps.ipsetIPPortCreate(name)
46
func (m *IPSet) DestroySet() error {
47
return m.Deps.destroySet(m.Name)
50
func (m *IPSet) AddIP(ip netip.Addr, ipProto uint8, comment string, replace bool) error {
51
return m.Deps.addIP(m.Name, ip, ipProto, comment, replace)
54
func (m *IPSet) DeleteIP(ip netip.Addr, ipProto uint8) error {
55
return m.Deps.deleteIP(m.Name, ip, ipProto)
58
func (m *IPSet) Flush() error {
59
return m.Deps.flush(m.Name)
62
func (m *IPSet) ClearEntriesWithComment(comment string) error {
63
return m.Deps.clearEntriesWithComment(m.Name, comment)
66
func (m *IPSet) ClearEntriesWithIP(ip netip.Addr) error {
67
return m.Deps.clearEntriesWithIP(m.Name, ip)
70
func (m *IPSet) ListEntriesByIP() ([]netip.Addr, error) {
71
return m.Deps.listEntriesByIP(m.Name)