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 IPDec(ip net.IP)
- func IPInc(ip net.IP)
- func IsIPv4(ip net.IP) bool
- func IsIPv6(ip net.IP) bool
- func IsReservedAddress(addr string) (bool, string)
- func Range2CIDR(first, last net.IP) *net.IPNet
- func RangeHosts(start, end net.IP) []net.IP
- type ASNCache
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.
const ReservedCIDRDescription = "Reserved Network Address Blocks"
ReservedCIDRDescription is the description used for reserved address ranges.
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 IsReservedAddress ¶ added in v3.5.0
IsReservedAddress checks if the addr parameter is within one of the address ranges in the ReservedCIDRs slice.
func Range2CIDR ¶ added in v3.4.0
Range2CIDR turns an IP range into a CIDR.
Types ¶
type ASNCache ¶ added in v3.5.0
ASNCache builds a cache of ASN and netblock information.
func NewASNCache ¶ added in v3.5.0
func NewASNCache() *ASNCache
NewASNCache returns an empty ASNCache for saving and search ASN and netblock information.
func (*ASNCache) AddrSearch ¶ added in v3.5.0
func (c *ASNCache) AddrSearch(addr string) *requests.ASNRequest
AddrSearch returns the cached ASN / netblock info that the addr parameter belongs in, or nil when not found in the cache.
func (*ASNCache) Update ¶ added in v3.5.0
func (c *ASNCache) Update(req *requests.ASNRequest)
Update uses the saves the information in ASNRequest into the ASNCache.