Documentation
¶
Overview ¶
ip is an extension of net/netip that handles IP/Prefix addresses as one Addr value despite notation and IP version (v4/v6) differences.
Index ¶
- type Addr
- func (a Addr) Addr() string
- func (a Addr) Bits() int
- func (a Addr) CIDR() string
- func (a Addr) IP() netip.Addr
- func (a Addr) Is() Version
- func (a Addr) Is4() bool
- func (a Addr) Is6() bool
- func (a Addr) IsInverted() bool
- func (a Addr) IsSingle() bool
- func (a Addr) IsUnspecified() bool
- func (a Addr) IsValid() bool
- func (a Addr) Prefix() netip.Prefix
- func (a Addr) String() string
- func (a Addr) Zone() string
- type Union
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Addr ¶
type Addr struct {
// contains filtered or unexported fields
}
Addr contains IP/CIDR addresses.
func UnspecifiedIPv4 ¶
func UnspecifiedIPv4() Addr
UnspecifiedIPv4 returns an unspecified IPv4 Addr.
func UnspecifiedIPv6 ¶
func UnspecifiedIPv6() Addr
UnspecifiedIPv6 returns an unspecified IPv6 Addr.
func (Addr) IsInverted ¶
IsInverted returns a boolean value for Addr state.
func (Addr) IsUnspecified ¶
IsUnspecified checks if Addr is unspecified.
type Union ¶
type Union struct {
// contains filtered or unexported fields
}
Union combines multiple Addr values.
func (*Union) Consent ¶
Consent returns a boolean of true if the given Addr is not specifically excluded, but included in that Union.
This is not a policy based allow-/blocklist order. It returns false for everything not explicitly included. Priority is set on excludes, not on positions. If you add !0.0.0.0/0 you will deny all IPv4 even if you explicitly added 192.168.1.2 before.
It is an allowlist with excludes approach. Think explicitly of what you want and not want to return true. This enables you to allow 10.0.0.0/8 and deny a host !10.10.10.10 or a subnet !10.10.0.0/16.
Zone value is not part of testing.