Documentation ¶
Index ¶
- func BroadcastAddr(n *net.IPNet) net.IP
- func ContainsNet(net1, net2 *net.IPNet) bool
- func IPLessThan(a, b net.IP) bool
- func IPMax(a, b net.IP) net.IP
- func IPMin(a, b net.IP) net.IP
- func IPv4(a, b, c, d byte) net.IP
- func IPv4Net(a, b, c, d byte, p int) net.IPNet
- func NetSize(n *net.IPNet) *big.Int
- func NetworkAddr(n *net.IPNet) net.IP
- func NewIP(size int) net.IP
- func ParseCIDR(cidr string) (net.IP, *net.IPNet, error)
- func ParseCIDRToNet(cidr string) (*net.IPNet, error)
- func ParseIP(address string) net.IP
- func ParseNet(cidr string) (parsed *net.IPNet, err error)
- type IPRange
- type IPSet
- func (s *IPSet) Contains(ip net.IP) bool
- func (s *IPSet) ContainsNet(net *net.IPNet) bool
- func (s *IPSet) Difference(other *IPSet) (newSet *IPSet)
- func (s *IPSet) GetIPs(limit int) (ips []net.IP)
- func (s *IPSet) GetNetworks() []*net.IPNet
- func (s *IPSet) Insert(ip net.IP)
- func (s *IPSet) InsertNet(net *net.IPNet)
- func (s *IPSet) Intersection(set1 *IPSet) (interSect *IPSet)
- func (s *IPSet) Remove(ip net.IP)
- func (s *IPSet) RemoveNet(net *net.IPNet)
- func (s *IPSet) String() (str []string)
- func (s *IPSet) Union(other *IPSet) (newSet *IPSet)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastAddr ¶
BroadcastAddr returns the last address in the given network, or the broadcast address.
func ContainsNet ¶ added in v1.3.0
ContainsNet returns true if net2 is a subset of net1. To be clear, it returns true if net1 == net2 also.
func IPLessThan ¶ added in v1.4.0
IPLessThan compare two ip addresses true ordered by ipv4 first, then ipv6 later then by section left-most is most significant e.g. 10.0.0.0 10.0.0.1 192.169.0.1 2001:db8::
func IPv4 ¶ added in v1.5.1
IPv4 returns the IP address (in 4-byte form) of the IPv4 address a.b.c.d.
func IPv4Net ¶ added in v1.5.1
IPv4Net returns the IPNet (in 4-byte form) of the IPv4 address a.b.c.d/p.
func NetSize ¶
NetSize returns the size of the given IPNet in terms of the number of addresses. It always includes the network and broadcast addresses.
func NetworkAddr ¶
NetworkAddr returns the first address in the given network, or the network address.
func NewIP ¶
NewIP returns a new IP with the given size. The size must be 4 for IPv4 and 16 for IPv6.
func ParseCIDR ¶ added in v1.2.0
ParseCIDR is like net.ParseCIDR except that it parses IPv4 addresses as 4 byte addresses instead of 16-byte mapped IPv6 addresses. Much like ParseIP.
func ParseCIDRToNet ¶ added in v1.2.0
ParseCIDRToNet is like ParseCIDR except that it only returns one *net.IPNet that unifies the IP address and the mask. It leaves out the network address which ParseCIDR returns. This may be considered an abuse of the IPNet construct as it is documented that IP is supposed to be the "network number". However, the public IPNet interface does not dissallow it and this usage has been spotted in the wild.
Types ¶
type IPRange ¶ added in v1.4.0
IPRange range of ips not necessarily aligned to a power of 2
func IPRangeFromIPNet ¶ added in v1.4.0
IPRangeFromIPNet get an IPRange from an *ip.Net
type IPSet ¶
type IPSet struct {
// contains filtered or unexported fields
}
IPSet is a set of IP addresses
func (*IPSet) ContainsNet ¶
ContainsNet returns true iff this IPSet contains all IPs in the given network
func (*IPSet) Difference ¶
Difference computes the set difference between this IPSet and another one It returns the result as a new set.
func (*IPSet) GetIPs ¶
GetIPs retrieves a slice of the first IPs in the set ordered by address up to the given limit.
func (*IPSet) GetNetworks ¶ added in v1.3.0
GetNetworks retrieves a list of all networks included in the ipTree
func (*IPSet) Intersection ¶
Intersection computes the set intersect between this IPSet and another one It returns a new set which is the intersection.