func isDocumentation()

in internal/fields/validate.go [1268:1288]


func isDocumentation(ip net.IP) bool {
	if ip4 := ip.To4(); ip4 != nil {
		// Following RFC 5737, Section 3. Documentation Address Blocks which says:
		//   The blocks 192.0.2.0/24 (TEST-NET-1), 198.51.100.0/24 (TEST-NET-2),
		//   and 203.0.113.0/24 (TEST-NET-3) are provided for use in
		//   documentation.
		// Following RFC 6676, the IPV4 multicast addresses allocated for documentation
		// purposes are 233.252.0.0/24
		return ((ip4[0] == 192 && ip4[1] == 0 && ip4[2] == 2) ||
			(ip4[0] == 198 && ip4[1] == 51 && ip4[2] == 100) ||
			(ip4[0] == 203 && ip4[1] == 0 && ip4[2] == 113) ||
			(ip4[0] == 233 && ip4[1] == 252 && ip4[2] == 0))
	}
	// Following RFC 3849, Section 2. Documentation IPv6 Address Prefix which
	// says:
	//   The prefix allocated for documentation purposes is 2001:DB8::/32
	// Following RFC 9637, a new address block 3fff::/20 is registered for documentation purposes
	return len(ip) == net.IPv6len &&
		(ip[0] == 32 && ip[1] == 1 && ip[2] == 13 && ip[3] == 184) ||
		(ip[0] == 63 && ip[1] == 255 && ip[2] <= 15)
}