README

netaddr Test Status Go Reference

What

This is a package containing a new IP address type for Go.

See its docs: https://pkg.go.dev/inet.af/netaddr

Status

This package is mature, optimized, and used heavily in production at Tailscale. However, API stability is not yet guaranteed.

netaddr is intended to be a core, low-level package. We take code review, testing, dependencies, and performance seriously, similar to Go's standard library or the golang.org/x repos.

Motivation

See https://tailscale.com/blog/netaddr-new-ip-type-for-go/ for a long blog post about why we made a new IP address package.

Other links:

Testing

In addition to regular Go tests, netaddr uses fuzzing. The corpus is stored separately, in a submodule, to minimize the impact on everyone else.

To use:

$ git submodule update --init
$ go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
$ go-fuzz-build && go-fuzz
Expand ▾ Collapse ▴

Documentation

Overview

    Package netaddr contains a IP address type that's in many ways better than the Go standard library's net.IP type. Building on that IP type, the package also contains IPPrefix, IPPort, IPRange, and IPSet types.

    Notably, this package's IP type takes less memory, is immutable, comparable (supports == and being a map key), and more. See https://github.com/inetaf/netaddr for background.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type IP

    type IP struct {
    	// contains filtered or unexported fields
    }

      IP represents an IPv4 or IPv6 address (with or without a scoped addressing zone), similar to Go's net.IP or net.IPAddr.

      Unlike net.IP or net.IPAddr, the netaddr.IP is a comparable value type (it supports == and can be a map key) and is immutable. Its memory representation is 24 bytes on 64-bit machines (the same size as a Go slice header) for both IPv4 and IPv6 address.

      func FromStdIP

      func FromStdIP(std net.IP) (ip IP, ok bool)

        FromStdIP returns an IP from the standard library's IP type.

        If std is invalid, ok is false.

        FromStdIP implicitly unmaps IPv6-mapped IPv4 addresses. That is, if len(std) == 16 and contains an IPv4 address, only the IPv4 part is returned, without the IPv6 wrapper. This is the common form returned by the standard library's ParseIP: https://play.golang.org/p/qdjylUkKWxl. To convert a standard library IP without the implicit unmapping, use FromStdIPRaw.

        func FromStdIPRaw

        func FromStdIPRaw(std net.IP) (ip IP, ok bool)

          FromStdIPRaw returns an IP from the standard library's IP type. If std is invalid, ok is false. Unlike FromStdIP, FromStdIPRaw does not do an implicit Unmap if len(std) == 16 and contains an IPv6-mapped IPv4 address.

          func IPFrom16

          func IPFrom16(addr [16]byte) IP

            IPFrom16 returns the IP address given by the bytes in addr, unmapping any v6-mapped IPv4 address.

            It is equivalent to calling IPv6Raw(addr).Unmap().

            func IPv4

            func IPv4(a, b, c, d uint8) IP

              IPv4 returns the IP of the IPv4 address a.b.c.d.

              func IPv6LinkLocalAllNodes

              func IPv6LinkLocalAllNodes() IP

                IPv6LinkLocalAllNodes returns the IPv6 link-local all nodes multicast address ff02::1.

                func IPv6Raw

                func IPv6Raw(addr [16]byte) IP

                  IPv6Raw returns the IPv6 address given by the bytes in addr, without an implicit Unmap call to unmap any v6-mapped IPv4 address.

                  func IPv6Unspecified

                  func IPv6Unspecified() IP

                    IPv6Unspecified returns the IPv6 unspecified address ::.

                    func MustParseIP

                    func MustParseIP(s string) IP

                      MustParseIP calls ParseIP(s) and panics on error. It is intended for use in tests with hard-coded strings.

                      func ParseIP

                      func ParseIP(s string) (IP, error)

                        ParseIP parses s as an IP address, returning the result. The string s can be in dotted decimal ("192.0.2.1"), IPv6 ("2001:db8::68"), or IPv6 with a scoped addressing zone ("fe80::1cc0:3e8c:119f:c2e1%ens18").

                        func (IP) As16

                        func (ip IP) As16() [16]byte

                          As16 returns the IP address in its 16 byte representation. IPv4 addresses are returned in their v6-mapped form. IPv6 addresses with zones are returned without their zone (use the Zone method to get it). The ip zero value returns all zeroes.

                          func (IP) As4

                          func (ip IP) As4() [4]byte

                            As4 returns an IPv4 or IPv4-in-IPv6 address in its 4 byte representation. If ip is the IP zero value or an IPv6 address, As4 panics. Note that 0.0.0.0 is not the zero value.

                            func (IP) BitLen

                            func (ip IP) BitLen() uint8

                              BitLen returns the number of bits in the IP address: 32 for IPv4 or 128 for IPv6. For the zero value (see IP.IsZero), it returns 0. For IP4-mapped IPv6 addresses, it returns 128.

                              func (IP) Compare

                              func (ip IP) Compare(ip2 IP) int

                                Compare returns an integer comparing two IPs. The result will be 0 if ip==ip2, -1 if ip < ip2, and +1 if ip > ip2. The definition of "less than" is the same as the IP.Less method.

                                func (IP) IPAddr

                                func (ip IP) IPAddr() *net.IPAddr

                                  IPAddr returns the net.IPAddr representation of an IP. The returned value is always non-nil, but the IPAddr.IP will be nil if ip is the zero value. If ip contains a zone identifier, IPAddr.Zone is populated.

                                  func (IP) Is4

                                  func (ip IP) Is4() bool

                                    Is4 reports whether ip is an IPv4 address.

                                    It returns false for IP4-mapped IPv6 addresses. See IP.Unmap.

                                    func (IP) Is4in6

                                    func (ip IP) Is4in6() bool

                                      Is4in6 reports whether ip is an IPv4-mapped IPv6 address.

                                      func (IP) Is6

                                      func (ip IP) Is6() bool

                                        Is6 reports whether ip is an IPv6 address, including IPv4-mapped IPv6 addresses.

                                        func (IP) IsInterfaceLocalMulticast

                                        func (ip IP) IsInterfaceLocalMulticast() bool

                                          IsInterfaceLocalMulticast reports whether ip is an IPv6 interface-local multicast address. If ip is the zero value or an IPv4 address, it will return false.

                                          func (IP) IsLinkLocalMulticast

                                          func (ip IP) IsLinkLocalMulticast() bool

                                            IsLinkLocalMulticast reports whether ip is a link-local multicast address. If ip is the zero value, it will return false.

                                            func (IP) IsLinkLocalUnicast

                                            func (ip IP) IsLinkLocalUnicast() bool

                                              IsLinkLocalUnicast reports whether ip is a link-local unicast address. If ip is the zero value, it will return false.

                                              func (IP) IsLoopback

                                              func (ip IP) IsLoopback() bool

                                                IsLoopback reports whether ip is a loopback address. If ip is the zero value, it will return false.

                                                func (IP) IsMulticast

                                                func (ip IP) IsMulticast() bool

                                                  IsMulticast reports whether ip is a multicast address. If ip is the zero value, it will return false.

                                                  func (IP) IsZero

                                                  func (ip IP) IsZero() bool

                                                    IsZero reports whether ip is the zero value of the IP type. The zero value is not a valid IP address of any type.

                                                    Note that "0.0.0.0" and "::" are not the zero value.

                                                    func (IP) Less

                                                    func (ip IP) Less(ip2 IP) bool

                                                      Less reports whether ip sorts before ip2. IP addresses sort first by length, then their address. IPv6 addresses with zones sort just after the same address without a zone.

                                                      func (IP) MarshalText

                                                      func (ip IP) MarshalText() ([]byte, error)

                                                        MarshalText implements the encoding.TextMarshaler interface, The encoding is the same as returned by String, with one exception: If ip is the zero value, the encoding is the empty string.

                                                        func (*IP) Netmask

                                                        func (ip *IP) Netmask(mask []byte) (IPPrefix, error)

                                                          Netmask applies a bit mask to IP, producing an IPPrefix. If IP is the zero value, a zero-value IPPrefix and a nil error are returned. If the netmask length is not 4 for IPv4 or 16 for IPv6, an error is returned. If the netmask is non-contiguous, an error is returned.

                                                          func (IP) Next

                                                          func (ip IP) Next() IP

                                                            Next returns the IP following ip. If there is none, it returns the IP zero value.

                                                            func (IP) Prefix

                                                            func (ip IP) Prefix(bits uint8) (IPPrefix, error)

                                                              Prefix applies a CIDR mask of leading bits to IP, producing an IPPrefix of the specified length. If IP is the zero value, a zero-value IPPrefix and a nil error are returned. If bits is larger than 32 for an IPv4 address or 128 for an IPv6 address, an error is returned.

                                                              func (IP) Prior

                                                              func (ip IP) Prior() IP

                                                                Prior returns the IP before ip. If there is none, it returns the IP zero value.

                                                                func (IP) String

                                                                func (ip IP) String() string

                                                                  String returns the string form of the IP address ip. It returns one of 4 forms:

                                                                  - "invalid IP", if ip is the zero value
                                                                  - IPv4 dotted decimal ("192.0.2.1")
                                                                  - IPv6 ("2001:db8::1")
                                                                  - IPv6 with zone ("fe80:db8::1%eth0")
                                                                  

                                                                  Note that unlike the Go standard library's IP.String method, IP4-mapped IPv6 addresses do not format as dotted decimals.

                                                                  func (IP) Unmap

                                                                  func (ip IP) Unmap() IP

                                                                    Unmap returns ip with any IPv4-mapped IPv6 address prefix removed.

                                                                    That is, if ip is an IPv6 address wrapping an IPv4 adddress, it returns the wrapped IPv4 address. Otherwise it returns ip, regardless of its type.

                                                                    func (*IP) UnmarshalText

                                                                    func (ip *IP) UnmarshalText(text []byte) error

                                                                      UnmarshalText implements the encoding.TextUnmarshaler interface. The IP address is expected in a form accepted by ParseIP. It returns an error if *ip is not the IP zero value.

                                                                      func (IP) WithZone

                                                                      func (ip IP) WithZone(zone string) IP

                                                                        WithZone returns an IP that's the same as ip but with the provided zone. If zone is empty, the zone is removed. If ip is an IPv4 address it's returned unchanged.

                                                                        func (IP) Zone

                                                                        func (ip IP) Zone() string

                                                                          Zone returns ip's IPv6 scoped addressing zone, if any.

                                                                          type IPPort

                                                                          type IPPort struct {
                                                                          	IP   IP
                                                                          	Port uint16
                                                                          }

                                                                            IPPort is an IP & port number.

                                                                            It's meant to be used as a value type.

                                                                            func FromStdAddr

                                                                            func FromStdAddr(stdIP net.IP, port int, zone string) (_ IPPort, ok bool)

                                                                              FromStdAddr maps the components of a standard library TCPAddr or UDPAddr into an IPPort.

                                                                              func MustParseIPPort

                                                                              func MustParseIPPort(s string) IPPort

                                                                                MustParseIPPort calls ParseIPPort(s) and panics on error. It is intended for use in tests with hard-coded strings.

                                                                                func ParseIPPort

                                                                                func ParseIPPort(s string) (IPPort, error)

                                                                                  ParseIPPort parses s as an IPPort.

                                                                                  It doesn't do any name resolution, and ports must be numeric.

                                                                                  func (IPPort) IsZero

                                                                                  func (p IPPort) IsZero() bool

                                                                                    IsZero reports whether p is its zero value.

                                                                                    func (IPPort) MarshalText

                                                                                    func (p IPPort) MarshalText() ([]byte, error)

                                                                                      MarshalText implements the encoding.TextMarshaler interface. The encoding is the same as returned by String, with one exception: if p.IP is the zero value, the encoding is the empty string.

                                                                                      func (IPPort) String

                                                                                      func (p IPPort) String() string

                                                                                      func (IPPort) TCPAddr

                                                                                      func (p IPPort) TCPAddr() *net.TCPAddr

                                                                                        TCPAddr returns a standard library net.TCPAddr from p. The returned value is always non-nil. If p.IP is the zero value, then TCPAddr.IP is nil.

                                                                                        func (IPPort) UDPAddr

                                                                                        func (p IPPort) UDPAddr() *net.UDPAddr

                                                                                          UDPAddr returns a standard library net.UDPAddr from p. The returned value is always non-nil. If p.IP is the zero value, then UDPAddr.IP is nil.

                                                                                          UDPAddr necessarily does two allocations. If you have an existing UDPAddr already allocated, see UDPAddrAt.

                                                                                          func (IPPort) UDPAddrAt

                                                                                          func (p IPPort) UDPAddrAt(at *net.UDPAddr) *net.UDPAddr

                                                                                            UDPAddrAt is like UDPAddr, but reuses the provided UDPAddr, which must be non-nil. If at.IP has a capacity of 16, UDPAddrAt is allocation-free. It returns at to facilitate using this method as a wrapper.

                                                                                            func (*IPPort) UnmarshalText

                                                                                            func (p *IPPort) UnmarshalText(text []byte) error

                                                                                              UnmarshalText implements the encoding.TextUnmarshaler interface. The IPPort is expected in a form accepted by ParseIPPort. It returns an error if *p is not the IPPort zero value.

                                                                                              type IPPrefix

                                                                                              type IPPrefix struct {
                                                                                              	IP   IP
                                                                                              	Bits uint8
                                                                                              }

                                                                                                IPPrefix is an IP address prefix (CIDR) representing an IP network.

                                                                                                The first Bits of IP are specified, the remaining bits match any address. The range of Bits is [0,32] for IPv4 or [0,128] for IPv6.

                                                                                                func FromStdIPNet

                                                                                                func FromStdIPNet(std *net.IPNet) (prefix IPPrefix, ok bool)

                                                                                                  FromStdIPNet returns an IPPrefix from the standard library's IPNet type. If std is invalid, ok is false.

                                                                                                  func MustParseIPPrefix

                                                                                                  func MustParseIPPrefix(s string) IPPrefix

                                                                                                    MustParseIPPrefix calls ParseIPPrefix(s) and panics on error. It is intended for use in tests with hard-coded strings.

                                                                                                    func ParseIPPrefix

                                                                                                    func ParseIPPrefix(s string) (IPPrefix, error)

                                                                                                      ParseIPPrefix parses s as an IP address prefix. The string can be in the form "192.168.1.0/24" or "2001::db8::/32", the CIDR notation defined in RFC 4632 and RFC 4291.

                                                                                                      Note that masked address bits are not zeroed. Use Masked for that.

                                                                                                      func (IPPrefix) Contains

                                                                                                      func (p IPPrefix) Contains(ip IP) bool

                                                                                                        Contains reports whether the network p includes ip.

                                                                                                        An IPv4 address will not match an IPv6 prefix. A v6-mapped IPv6 address will not match an IPv4 prefix. A zero-value IP will not match any prefix.

                                                                                                        func (IPPrefix) IPNet

                                                                                                        func (p IPPrefix) IPNet() *net.IPNet

                                                                                                          IPNet returns the net.IPNet representation of an IPPrefix. The returned value is always non-nil. Any zone identifier is dropped in the conversion.

                                                                                                          func (IPPrefix) IsSingleIP

                                                                                                          func (p IPPrefix) IsSingleIP() bool

                                                                                                            IsSingleIP reports whether p contains exactly one IP.

                                                                                                            func (IPPrefix) IsZero

                                                                                                            func (p IPPrefix) IsZero() bool

                                                                                                              IsZero reports whether p is its zero value.

                                                                                                              func (IPPrefix) MarshalText

                                                                                                              func (p IPPrefix) MarshalText() ([]byte, error)

                                                                                                                MarshalText implements the encoding.TextMarshaler interface, The encoding is the same as returned by String, with one exception: If p is the zero value, the encoding is the empty string.

                                                                                                                func (IPPrefix) Masked

                                                                                                                func (p IPPrefix) Masked() IPPrefix

                                                                                                                  Masked returns p in its canonical form, with bits of p.IP not in p.Bits masked off. If p is zero or otherwise invalid, Masked returns the zero value.

                                                                                                                  func (IPPrefix) Overlaps

                                                                                                                  func (p IPPrefix) Overlaps(o IPPrefix) bool

                                                                                                                    Overlaps reports whether p and o overlap at all.

                                                                                                                    If p and o are of different address families or either have a zero IP, it reports false. Like the Contains method, a prefix with a v6-mapped IPv4 IP is still treated as an IPv6 mask.

                                                                                                                    If either has a Bits of zero, it returns true.

                                                                                                                    func (IPPrefix) Range

                                                                                                                    func (p IPPrefix) Range() IPRange

                                                                                                                      Range returns the inclusive range of IPs that p covers.

                                                                                                                      If p is zero or otherwise invalid, Range returns the zero value.

                                                                                                                      func (IPPrefix) String

                                                                                                                      func (p IPPrefix) String() string

                                                                                                                        String returns the CIDR notation of p: "<ip>/<bits>".

                                                                                                                        func (*IPPrefix) UnmarshalText

                                                                                                                        func (p *IPPrefix) UnmarshalText(text []byte) error

                                                                                                                          UnmarshalText implements the encoding.TextUnmarshaler interface. The IP address is expected in a form accepted by ParseIPPrefix. It returns an error if *p is not the IPPrefix zero value.

                                                                                                                          func (IPPrefix) Valid

                                                                                                                          func (p IPPrefix) Valid() bool

                                                                                                                            Valid reports whether whether p.Bits has a valid range for p.IP. If p.IP is zero, Valid returns false.

                                                                                                                            type IPRange

                                                                                                                            type IPRange struct {
                                                                                                                            	// From is the initial IP address in the range.
                                                                                                                            	From IP
                                                                                                                            
                                                                                                                            	// To is the final IP address in the range.
                                                                                                                            	To IP
                                                                                                                            }

                                                                                                                              IPRange represents an inclusive range of IP addresses from the same address family.

                                                                                                                              The From and To IPs are inclusive bounds, both included in the range.

                                                                                                                              To be valid, the From and To values be non-zero, have matching address families (IPv4 vs IPv6), be in the same IPv6 zone (if any), and From must be less than or equal to To. An invalid range may be ignored.

                                                                                                                              func ParseIPRange

                                                                                                                              func ParseIPRange(s string) (IPRange, error)

                                                                                                                                ParseIPRange parses a range out of two IPs separated by a hyphen.

                                                                                                                                It returns an error if the range is not valid.

                                                                                                                                func (IPRange) AppendPrefixes

                                                                                                                                func (r IPRange) AppendPrefixes(dst []IPPrefix) []IPPrefix

                                                                                                                                  AppendPrefixes is an append version of IPRange.Prefixes. It appends the IPPrefix entries that cover r to dst.

                                                                                                                                  func (IPRange) Contains

                                                                                                                                  func (r IPRange) Contains(addr IP) bool

                                                                                                                                    Contains reports whether the range r includes addr.

                                                                                                                                    An invalid range always reports false.

                                                                                                                                    func (IPRange) Overlaps

                                                                                                                                    func (r IPRange) Overlaps(o IPRange) bool

                                                                                                                                      Overlaps reports whether p and o overlap at all.

                                                                                                                                      If p and o are of different address families or either are invalid, it reports false.

                                                                                                                                      func (IPRange) Prefix

                                                                                                                                      func (r IPRange) Prefix() (p IPPrefix, ok bool)

                                                                                                                                        Prefix returns r as an IPPrefix, if it can be presented exactly as such. If r is not valid or is not exactly equal to one prefix, ok is false.

                                                                                                                                        func (IPRange) Prefixes

                                                                                                                                        func (r IPRange) Prefixes() []IPPrefix

                                                                                                                                          Prefixes returns the set of IPPrefix entries that covers r.

                                                                                                                                          If either of r's bounds are invalid, in the wrong order, or if they're of different address families, then Prefixes returns nil.

                                                                                                                                          Prefixes necessarily allocates. See AppendPrefixes for a version that uses memory you provide.

                                                                                                                                          func (IPRange) String

                                                                                                                                          func (r IPRange) String() string

                                                                                                                                            String returns a string representation of the range.

                                                                                                                                            For a valid range, the form is "From-To" with a single hyphen separating the IPs, the same format recognized by ParseIPRange.

                                                                                                                                            func (IPRange) Valid

                                                                                                                                            func (r IPRange) Valid() bool

                                                                                                                                              Valid reports whether r.From and r.To are both non-zero and obey the documented requirements: address families match, same IPv6 zone, and From is less than or equal to To.

                                                                                                                                              type IPSet

                                                                                                                                              type IPSet struct {
                                                                                                                                              	// contains filtered or unexported fields
                                                                                                                                              }

                                                                                                                                                IPSet represents a set of IP addresses.

                                                                                                                                                IPSet is safe for concurrent use. The zero value is a valid value representing a set of no IPs. Use IPSetBuilder to construct IPSets.

                                                                                                                                                Example
                                                                                                                                                Output:
                                                                                                                                                
                                                                                                                                                Ranges:
                                                                                                                                                  10.1.0.0 - 10.255.255.255
                                                                                                                                                  fed0::400 - fed0::4ff
                                                                                                                                                Prefixes:
                                                                                                                                                  10.1.0.0/16
                                                                                                                                                  10.2.0.0/15
                                                                                                                                                  10.4.0.0/14
                                                                                                                                                  10.8.0.0/13
                                                                                                                                                  10.16.0.0/12
                                                                                                                                                  10.32.0.0/11
                                                                                                                                                  10.64.0.0/10
                                                                                                                                                  10.128.0.0/9
                                                                                                                                                  fed0::400/120
                                                                                                                                                

                                                                                                                                                func (*IPSet) Contains

                                                                                                                                                func (s *IPSet) Contains(ip IP) bool

                                                                                                                                                  Contains reports whether ip is in s.

                                                                                                                                                  func (*IPSet) ContainsPrefix

                                                                                                                                                  func (s *IPSet) ContainsPrefix(p IPPrefix) bool

                                                                                                                                                    ContainsPrefix reports whether all IPs in p are in s.

                                                                                                                                                    func (*IPSet) ContainsRange

                                                                                                                                                    func (s *IPSet) ContainsRange(r IPRange) bool

                                                                                                                                                      ContainsRange reports whether all IPs in r are in s.

                                                                                                                                                      func (*IPSet) Equal

                                                                                                                                                      func (s *IPSet) Equal(o *IPSet) bool

                                                                                                                                                        Equal reports whether s and o represent the same set of IP addresses.

                                                                                                                                                        func (*IPSet) Overlaps

                                                                                                                                                        func (s *IPSet) Overlaps(b *IPSet) bool

                                                                                                                                                          Overlaps reports whether any IP in b is also in s.

                                                                                                                                                          func (*IPSet) OverlapsPrefix

                                                                                                                                                          func (s *IPSet) OverlapsPrefix(p IPPrefix) bool

                                                                                                                                                            OverlapsPrefix reports whether any IP in p is also in s.

                                                                                                                                                            func (*IPSet) OverlapsRange

                                                                                                                                                            func (s *IPSet) OverlapsRange(r IPRange) bool

                                                                                                                                                              OverlapsRange reports whether any IP in r is also in s.

                                                                                                                                                              func (*IPSet) Prefixes

                                                                                                                                                              func (s *IPSet) Prefixes() []IPPrefix

                                                                                                                                                                Prefixes returns the minimum and sorted set of IP prefixes that covers s.

                                                                                                                                                                func (*IPSet) Ranges

                                                                                                                                                                func (s *IPSet) Ranges() []IPRange

                                                                                                                                                                  Ranges returns the minimum and sorted set of IP ranges that covers s.

                                                                                                                                                                  func (*IPSet) RemoveFreePrefix

                                                                                                                                                                  func (s *IPSet) RemoveFreePrefix(bitLen uint8) (p IPPrefix, newSet *IPSet, ok bool)

                                                                                                                                                                    RemoveFreePrefix splits s into a Prefix of length bitLen and a new IPSet with that prefix removed.

                                                                                                                                                                    If no contiguous prefix of length bitLen exists in s, RemoveFreePrefix returns ok=false.

                                                                                                                                                                    type IPSetBuilder

                                                                                                                                                                    type IPSetBuilder struct {
                                                                                                                                                                    	// contains filtered or unexported fields
                                                                                                                                                                    }

                                                                                                                                                                      IPSetBuilder builds an immutable IPSet.

                                                                                                                                                                      The zero value is a valid value representing a set of no IPs.

                                                                                                                                                                      The Add and Remove methods add or remove IPs to/from the set. Removals only affect the current membership of the set, so in general Adds should be called first. Input ranges may overlap in any way.

                                                                                                                                                                      func (*IPSetBuilder) Add

                                                                                                                                                                      func (s *IPSetBuilder) Add(ip IP)

                                                                                                                                                                        Add adds ip to s.

                                                                                                                                                                        func (*IPSetBuilder) AddPrefix

                                                                                                                                                                        func (s *IPSetBuilder) AddPrefix(p IPPrefix)

                                                                                                                                                                          AddPrefix adds all IPs in p to s.

                                                                                                                                                                          func (*IPSetBuilder) AddRange

                                                                                                                                                                          func (s *IPSetBuilder) AddRange(r IPRange)

                                                                                                                                                                            AddRange adds r to s. If r is not Valid, AddRange does nothing.

                                                                                                                                                                            func (*IPSetBuilder) AddSet

                                                                                                                                                                            func (s *IPSetBuilder) AddSet(b *IPSet)

                                                                                                                                                                              AddSet adds all IPs in b to s.

                                                                                                                                                                              func (*IPSetBuilder) Clone

                                                                                                                                                                              func (s *IPSetBuilder) Clone() *IPSetBuilder

                                                                                                                                                                                Clone returns a copy of s that shares no memory with s.

                                                                                                                                                                                func (*IPSetBuilder) Complement

                                                                                                                                                                                func (s *IPSetBuilder) Complement()

                                                                                                                                                                                  Complement updates s to contain the complement of its current contents.

                                                                                                                                                                                  func (*IPSetBuilder) IPSet

                                                                                                                                                                                  func (s *IPSetBuilder) IPSet() *IPSet

                                                                                                                                                                                    IPSet returns an immutable IPSet representing the current state of s. The builder remains usable after calling IPSet.

                                                                                                                                                                                    func (*IPSetBuilder) Intersect

                                                                                                                                                                                    func (s *IPSetBuilder) Intersect(b *IPSet)

                                                                                                                                                                                      Intersect updates s to the set intersection of s and b.

                                                                                                                                                                                      func (*IPSetBuilder) Remove

                                                                                                                                                                                      func (s *IPSetBuilder) Remove(ip IP)

                                                                                                                                                                                        Remove removes ip from s.

                                                                                                                                                                                        func (*IPSetBuilder) RemovePrefix

                                                                                                                                                                                        func (s *IPSetBuilder) RemovePrefix(p IPPrefix)

                                                                                                                                                                                          RemovePrefix removes all IPs in p from s.

                                                                                                                                                                                          func (*IPSetBuilder) RemoveRange

                                                                                                                                                                                          func (s *IPSetBuilder) RemoveRange(r IPRange)

                                                                                                                                                                                            RemoveRange removes all IPs in r from s.

                                                                                                                                                                                            func (*IPSetBuilder) RemoveSet

                                                                                                                                                                                            func (s *IPSetBuilder) RemoveSet(b *IPSet)

                                                                                                                                                                                              RemoveSet removes all IPs in o from s.