Documentation ¶
Index ¶
- Constants
- Variables
- func AllHosts(cidr *net.IPNet) []net.IP
- func CIDRSubset(cidr *net.IPNet, addr string, num int) []net.IP
- func FirstLast(cidr *net.IPNet) (net.IP, net.IP)
- func IPv6NibbleFormat(ip string) string
- func IsIPv4(ip net.IP) bool
- func IsIPv6(ip net.IP) bool
- func Range2CIDR(first, last net.IP) *net.IPNet
- func RangeHosts(start, end net.IP) []net.IP
- func ReverseIP(ip string) string
Constants ¶
const IPv4RE = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.]){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
IPv4RE is a regular expression that will match an IPv4 address.
Variables ¶
var ReservedCIDRs = []string{
"192.168.0.0/16",
"172.16.0.0/12",
"10.0.0.0/8",
"127.0.0.0/8",
"224.0.0.0/4",
"240.0.0.0/4",
"100.64.0.0/10",
"198.18.0.0/15",
"169.254.0.0/16",
"192.88.99.0/24",
"192.0.0.0/24",
"192.0.2.0/24",
"192.94.77.0/24",
"192.94.78.0/24",
"192.52.193.0/24",
"192.12.109.0/24",
"192.31.196.0/24",
"192.0.0.0/29",
}
ReservedCIDRs includes all the networks that are reserved for special use.
Functions ¶
func AllHosts ¶
AllHosts returns a slice containing all the IP addresses within the CIDR provided by the parameter. This implementation was obtained/modified from the following: https://gist.github.com/kotakanbe/d3059af990252ba89a82
func CIDRSubset ¶
CIDRSubset returns a subset of the IP addresses contained within the cidr parameter with num elements around the addr element.
func IPv6NibbleFormat ¶
IPv6NibbleFormat expects an IPv6 address in the ip parameter and returns the address in nibble format.
func Range2CIDR ¶
Range2CIDR turns an IP range into a CIDR.
func RangeHosts ¶
RangeHosts returns all the IP addresses (inclusive) between the start and stop addresses provided by the parameters.
Types ¶
This section is empty.