ipset

package
v0.0.0-...-4b288b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	V4Name = "%s-v4"
	V6Name = "%s-v6"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IPSet

type IPSet struct {
	V4Name string
	V6Name string
	Prefix string
	Deps   NetlinkIpsetDeps
}

func NewIPSet

func NewIPSet(name string, v6 bool, deps NetlinkIpsetDeps) (IPSet, error)

TODO this should actually create v6 and v6 subsets of type `hash:ip`, add them both to a superset of type `list:set` - we can then query the superset directly in iptables (with the same rule), and iptables will be smart enough to pick the correct underlying set (v4 or v6, based on context), reducing the # of rules we need.

BUT netlink lib doesn't support adding things to `list:set` types yet, and current tagged release doesn't support creating `list:set` types yet (is in main branch tho). So this will actually create 2 underlying ipsets, one for v4 and one for v6

func (*IPSet) AddIP

func (m *IPSet) AddIP(ip netip.Addr, ipProto uint8, comment string, replace bool) error

func (*IPSet) ClearEntriesWithComment

func (m *IPSet) ClearEntriesWithComment(comment string) error

func (*IPSet) ClearEntriesWithIP

func (m *IPSet) ClearEntriesWithIP(ip netip.Addr) error

func (*IPSet) ClearEntriesWithIPAndComment

func (m *IPSet) ClearEntriesWithIPAndComment(ip netip.Addr, comment string) (string, error)

func (*IPSet) DeleteIP

func (m *IPSet) DeleteIP(ip netip.Addr, ipProto uint8) error

func (*IPSet) DestroySet

func (m *IPSet) DestroySet() error

func (*IPSet) Flush

func (m *IPSet) Flush() error

func (*IPSet) ListEntriesByIP

func (m *IPSet) ListEntriesByIP() ([]netip.Addr, error)

type MockedIpsetDeps

type MockedIpsetDeps struct {
	mock.Mock
}

func FakeNLDeps

func FakeNLDeps() *MockedIpsetDeps

type NetlinkIpsetDeps

type NetlinkIpsetDeps interface {
	// contains filtered or unexported methods
}

func RealNlDeps

func RealNlDeps() NetlinkIpsetDeps

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL