Test if this address is allocated for private networks.

        Returns:
            A boolean, True if the address is reserved per
            iana-ipv4-special-registry.
328566
def is_private(self):
        
        return (self in IPv4Network('0.0.0.0/8') or
                self in IPv4Network('10.0.0.0/8') or
                self in IPv4Network('127.0.0.0/8') or
                self in IPv4Network('169.254.0.0/16') or
                self in IPv4Network('172.16.0.0/12') or
                self in IPv4Network('192.0.0.0/29') or
                self in IPv4Network('192.0.0.170/31') or
                self in IPv4Network('192.0.2.0/24') or
                self in IPv4Network('192.168.0.0/16') or
                self in IPv4Network('198.18.0.0/15') or
                self in IPv4Network('198.51.100.0/24') or
                self in IPv4Network('203.0.113.0/24') or
                self in IPv4Network('240.0.0.0/4') or
                self in IPv4Network('255.255.255.255/32'))
1278656
def random_public_ip(self):
        
        randomip = random_ip()
        while self.is_reserved_ip(randomip):
            randomip = random_ip()
        return randomip
1337393
public boolean accessDenied(InetAddress remoteAddr) {

        String hostname = null; //F184719

        // check the inclusion lists first to see if the client matches
        if (includeAccess.getActive() || includeAccessNames.getActive()) {
            boolean closeSocket = true;

            if (includeAccess.getActive()) {
                if (remoteAddr instanceof Inet6Address) {
                    if (includeAccess.findInList6(remoteAddr.getAddress())) {
                        closeSocket = false;
                    }
                } else {
                    if (includeAccess.findInList(remoteAddr.getAddress())) {
                        closeSocket = false;
                    }
                }
            }

            if (closeSocket && includeAccessNames.getActive()) {
                // look at hostnames to check inclusion

                hostname = remoteAddr.getHostName();
                if (caseInsensitiveHostnames && (hostname != null)) {
                    hostname = hostname.toLowerCase();
                }

                if (includeAccessNames.findInList(hostname)) {
                    closeSocket = false;
                }
            }

            if (closeSocket) {
                // close the excluded socket connection
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    Tr.event(tc, "Address and host name not in include list, address: " + remoteAddr.getHostAddress() + " host name: " + remoteAddr.getHostName());
                return true;
            }
        }

        if (excludeAccess.getActive() || excludeAccessNames.getActive()) {
            boolean closeSocket = false;

            if (excludeAccess.getActive()) {
                if (remoteAddr instanceof Inet6Address) {
                    if (excludeAccess.findInList6(remoteAddr.getAddress())) {
                        // close the excluded socket connection
                        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                            Tr.event(tc, "Address (IPv6) in exclude list, address: " + remoteAddr.getHostAddress());
                        return true;
                    }
                } else {
                    if (excludeAccess.findInList(remoteAddr.getAddress())) {
                        // close the excluded socket connection
                        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                            Tr.event(tc, "Address in exclude list, address: " + remoteAddr.getHostAddress());
                        return true;
                    }
                }
            }

            if (closeSocket == false && excludeAccessNames.getActive()) {
                // look at hostnames to check exclusion

                hostname = remoteAddr.getHostName();
                if (caseInsensitiveHostnames && (hostname != null)) {
                    hostname = hostname.toLowerCase();
                }
                if (excludeAccessNames.findInList(hostname)) {
                    // close the excluded socket connection
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                        Tr.event(tc, "Host name in exclude list, host name: " + remoteAddr.getHostName());
                    return true;
                }
            }
        } // end if(there are excludes to check)

        return false;
    }
149445
def is_reserved(ip):
    
    if ip_between(ip, "0.0.0.0", "0.255.255.255"):
        return True
    elif ip_between(ip, "10.0.0.0", "10.255.255.255"):
        return True
    elif ip_between(ip, "100.64.0.0", "100.127.255.255"):
        return True
    elif ip_between(ip, "127.0.0.0", "127.255.255.255"):
        return True
    elif ip_between(ip, "169.254.0.0", "169.254.255.255"):
        return True
    elif ip_between(ip, "172.16.0.0", "172.31.255.255"):
        return True
    elif ip_between(ip, "192.0.0.0", "192.0.0.255"):
        return True
    elif ip_between(ip, "192.0.2.0", "192.0.2.255"):
        return True
    elif ip_between(ip, "192.88.99.0", "192.88.99.255"):
        return True
    elif ip_between(ip, "192.168.0.0", "192.168.255.255"):
        return True
    elif ip_between(ip, "198.18.0.0", "198.19.255.255"):
        return True
    elif ip_between(ip, "198.51.100.0", "198.51.100.255"):
        return True
    elif ip_between(ip, "203.0.113.0", "203.0.113.255"):
        return True
    elif ip_between(ip, "224.0.0.0", "255.255.255.255"):
        return True
    else:
        return False
66073
public function isPubliclyRoutable(): bool
    {
        try {
            $ip = IpUtilsFactory::getAddress($this->host);

            if ($ip->isPrivate()) {
                return false;
            }

            if ($ip->isLoopback()) {
                return false;
            }

            if ($ip instanceof IPv4 && $this->isIpv4InUnroutableRange($ip)) {
                return false;
            }

            return true;
        } catch (\UnexpectedValueException $unexpectedValueException) {
            return true;
        }
    }
237736
def ip4_address(self):
        
        if self._ip4_address is None and self.network is not None:
            self._ip4_address = self._get_ip_address(
                libvirt.VIR_IP_ADDR_TYPE_IPV4)

        return self._ip4_address
427013
def is_rfc1918(ip):
    
    if ip_between(ip, "10.0.0.0", "10.255.255.255"):
        return True
    elif ip_between(ip, "172.16.0.0", "172.31.255.255"):
        return True
    elif ip_between(ip, "192.168.0.0", "192.168.255.255"):
        return True
    else:
        return False
859982
def is_ipaddress(hostname):
    
    if six.PY3 and isinstance(hostname, bytes):
        # IDN A-label bytes are ASCII compatible.
        hostname = hostname.decode('ascii')

    families = [socket.AF_INET]
    if hasattr(socket, 'AF_INET6'):
        families.append(socket.AF_INET6)

    for af in families:
        try:
            inet_pton(af, hostname)
        except (socket.error, ValueError, OSError):
            pass
        else:
            return True
    return False
937062
private boolean isIPAddress(@Nonnull String address) {
        return (InetAddressUtils.isIPv4Address(address) || InetAddressUtils.isIPv6Address(address));
    }
1347473
private static boolean isIPv4MappedAddress(final byte[] addr) {
    if (addr.length < INADDR16SZ) {
      return false;
    }
    return addr[0] == 0x00 && addr[1] == 0x00 && addr[2] == 0x00 && addr[3] == 0x00
        && addr[4] == 0x00 && addr[5] == 0x00 && addr[6] == 0x00 && addr[7] == 0x00
        && addr[8] == 0x00 && addr[9] == 0x00 && addr[10] == (byte) 0xff && addr[11] == (byte) 0xff;
  }
1068152
def get_public_ip(addresses, version=4):
        
        for addr in addresses:
            if addr['public'] and addr['address_family'] == version:
                return addr.get('address')
        return None
860566
public boolean isTrustedForSensitiveHeaders(String hostAddr) {
        if (!useSensitivePrivateHeaders) {
            // trustedSensitiveHeaderOrigin list is either unset (defaults to "none") or explicitly set to "none"
            return false;
        }
        if (restrictSensitiveHeaderOrigin == null) {
            // trustedSensitiveHeaderOrigin is set to "*"
            return true;
        } else {
            // check trustedSensitiveHeaderOrigin list for given host IP
            return restrictSensitiveHeaderOrigin.contains(hostAddr.toLowerCase());
        }
    }
1221725
def get_private_ip(self, addr_family=None, *args, **kwargs):
        """"""
        return self.get_ip('private', addr_family, *args, **kwargs)
121003
def is_valid_vpnv4_prefix(prefix):
    
    if not isinstance(prefix, str):
        return False

    # Split the prefix into route distinguisher and IP
    tokens = prefix.split(':', 2)
    if len(tokens) != 3:
        return False

    # Validate route distinguisher
    if not is_valid_route_dist(':'.join([tokens[0], tokens[1]])):
        return False

    # Validate IPv4 prefix and return
    return is_valid_ipv4_prefix(tokens[2])
803618
private static boolean checkIpv4(byte[] bytes, int pos, int length) {
		int start = pos;
		for (int i = pos; i < length; i++) {
			// assume at least one more symbol is present after dot
			if (i == length - 1 && bytes[i] == '.') {
				return false;
			}
			if (bytes[i] == '.' || i == length - 1) {
				int v;
				if (i - start == 0 && i != length - 1) {
					return false;
				}
				try {
					v = trimAndDecodePositiveInt(bytes, start, i - start);
				} catch (ParseException e) {
					return false;
				}
				if (v < 0 || v > 255) return false;
				start = i + 1;
			}
		}
		return true;
	}
1184784
private static boolean useInetAddress(NetworkInterface networkInterface, InetAddress interfaceAddress) {
        return checkMethod(networkInterface, isUp) &&
               checkMethod(networkInterface, supportsMulticast) &&
               // TODO: IpV6 support
               !(interfaceAddress instanceof Inet6Address) &&
               !interfaceAddress.isLoopbackAddress();
    }
408838
private boolean isLocalIpAddress(InetAddress addr) {
    if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
      return true;
    try {
      return NetworkInterface.getByInetAddress(addr) != null;
    } catch (SocketException e) {
      return false;
    }
  }