Determine whether any of the service's IPs are not in the
trusted ranges

@throws Exception
503581
private function assertTrustedIp()
    {
        $baseHost = parse_url($this->serviceUri, PHP_URL_HOST);
        $serviceIp = gethostbyname(
            $baseHost
        );

        if ( ! $this->isTrustedIpAddress($serviceIp)) {
            throw new EmailServiceClientException(
                'The service has an IP that is not trusted ... ' . $serviceIp,
                1503511662
            );
        }
    }
1115509
public static boolean isValidIP( String ip ) {

		boolean result = false;
		try {
			String[] parts;
			if( ! Utils.isEmptyOrWhitespaces( ip )
					&& (parts = ip.split("\\.")).length == 4 ) {

				result = true;
				for( String s : parts ) {
					int part = Integer.parseInt( s );
					if( part < 0 || part > 255 ) {
						result = false;
						break;
					}
				}
			}

		} catch( NumberFormatException e ) {
			result = false;
		}

		return result;
	}
834234
def is_reserved_ip(self, ip):
        
        theip = ipaddress(ip)
        for res in self._reserved_netmasks:
            if theip in ipnetwork(res):
                return True
        return False
221318
def is_private(ip):
    
    if matches_prefix(ip, '10.0.0.0/8'):
        return True
    if matches_prefix(ip, '172.16.0.0/12'):
        return True
    if matches_prefix(ip, '192.168.0.0/16'):
        return True
    return False
918228
private function setClientIPs()
    {
        if ($this->isUsingTrustedProxy()) {
            $this->clientIps = [$this->server->get('REMOTE_ADDR')];
        }
        $clientIps = [];

        if ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED])) {
            $header = $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED]);
            preg_match_all("/for=(?:\"?\[?)([a-z0-9:\.\-\/_]*)/", $header, $matches);
            $clientIps = $matches[1];
        } elseif ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP])) {
            $clientIps = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP]));
            $clientIps = array_map('trim', $clientIps);
        }

        $clientIps[] = $this->server->get('REMOTE_ADDR');
        $fallbackClientIps = [$clientIps[0]];

        foreach ($clientIps as $index => $clientIp) {
            // Check for valid IPs
            if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
                unset($clientIps[$index]);

                continue;
            }

            // Don't allow trusted proxies
            if (in_array($clientIp, self::$trustedProxies)) {
                unset($clientIps[$index]);
            }
        }

        $this->clientIps = (count($clientIps) == 0) ? $fallbackClientIps : array_reverse($clientIps);
    }
510426
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSIPAddress source_ip_address_validator = new MPSIPAddress();
		source_ip_address_validator.validate(operationType, source_ip_address, "\"source_ip_address\"");
		
		MPSIPAddress target_ip_address_arr_validator = new MPSIPAddress();
		if(target_ip_address_arr != null)
		{
			for(int i=0; i<target_ip_address_arr.length; i++)
			{
				target_ip_address_arr_validator.validate(operationType, target_ip_address_arr[i], "target_ip_address_arr["+i+"]");
			}
		}
		
	}
86846
def _is_private_ip(ip):
	
	networks = [
		"0.0.0.0/8",
		"10.0.0.0/8",
		"100.64.0.0/10",
		"127.0.0.0/8",
		"169.254.0.0/16",
		"172.16.0.0/12",
		"192.0.0.0/24",
		"192.0.2.0/24",
		"192.88.99.0/24",
		"192.168.0.0/16",
		"198.18.0.0/15",
		"198.51.100.0/24",
		"203.0.113.0/24",
		"240.0.0.0/4",
		"255.255.255.255/32",
		"224.0.0.0/4",
	]

	for network in networks:
		try:
			ipaddr = struct.unpack(">I", socket.inet_aton(ip))[0]

			netaddr, bits = network.split("/")

			network_low = struct.unpack(">I", socket.inet_aton(netaddr))[0]
			network_high = network_low | 1 << (32 - int(bits)) - 1

			if ipaddr <= network_high and ipaddr >= network_low:
				return True
		except Exception:
			continue

	return False
1100915
public boolean belowRange(InetAddress ip) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "belowRange, ip is " + ip);
            Tr.debug(tc, "belowRange, ipLower is " + ipLower);
        }
        return lessThan(ip, ipLower);
    }
1351527
private function validateRequiredProperties()
    {
        if ($this->base_url == null) {
            throw new \Exception('The base_url property was not set.');
        }

        if (is_numeric($this->total_records)) {
            $this->total_records = intval($this->total_records);
        } else {
            throw new \Exception('The total_records property was not set.');
        }

        if (!is_numeric($this->page_number_value)) {
            throw new \Exception('The page_number_value property was not set.');
        }
    }
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
235106
public boolean isValidInet4Address(String inet4Address) {
        // verify that address conforms to generic IPv4 format
        String[] groups = ipv4Validator.match(inet4Address);

        if (groups == null) {
            return false;
        }

        // verify that address subgroups are legal
        for (String ipSegment : groups) {
            if (ipSegment == null || ipSegment.length() == 0) {
                return false;
            }

            int iIpSegment = 0;

            try {
                iIpSegment = Integer.parseInt(ipSegment);
            } catch(NumberFormatException e) {
                return false;
            }

            if (iIpSegment > IPV4_MAX_OCTET_VALUE) {
                return false;
            }

            if (ipSegment.length() > 1 && ipSegment.startsWith("0")) {
                return false;
            }

        }

        return true;
    }
1035513
def validate(self, value):
        """"""
        try:
            self._choice = IPAddress(value)
            return True
        except (ValueError, AddrFormatError):
            self.error_message = '%s is not a valid IP address.' % value
            return False
1105221
public void setCheckerIpRanges(java.util.Collection<String> checkerIpRanges) {
        if (checkerIpRanges == null) {
            this.checkerIpRanges = null;
            return;
        }

        this.checkerIpRanges = new com.amazonaws.internal.SdkInternalList<String>(checkerIpRanges);
    }
993897
protected function isVisitorIpExcluded()
    {
        $excludedIps = $this->getAttributes('excluded_ips', 'global_excluded_ips');

        if (!empty($excludedIps)) {
            $ip = IP::fromBinaryIP($this->ip);
            if ($ip->isInRanges($excludedIps)) {
                Common::printDebug('Visitor IP ' . $ip->toString() . ' is excluded from being tracked');
                return true;
            }
        }

        return false;
    }
1099508
def check_ip(original_ip):
    '''
    
    ''' 
    ip = original_ip.strip()
    parts = ip.split('.')
    if len(parts) != 4:
        return None
    for p in parts:
        try:
            p = int(p)
            if (p < 0) or (p > 255):
                return None
        except:
            return None
    return ip
362500
private static void validateSeedBrokers(String[] seedBrokers, Exception exception) {
		if (!(exception instanceof ClosedChannelException)) {
			return;
		}
		int unknownHosts = 0;
		for (String broker : seedBrokers) {
			URL brokerUrl = NetUtils.getCorrectHostnamePort(broker.trim());
			try {
				InetAddress.getByName(brokerUrl.getHost());
			} catch (UnknownHostException e) {
				unknownHosts++;
			}
		}
		// throw meaningful exception if all the provided hosts are invalid
		if (unknownHosts == seedBrokers.length) {
			throw new IllegalArgumentException("All the servers provided in: '"
				+ ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG + "' config are invalid. (unknown hosts)");
		}
	}
538198
private static void checkAddress(String address, AddressFamily addrFamily) {
        if (addrFamily == null) {
            throw new NullPointerException("addrFamily");
        }

        switch (addrFamily) {
            case AF_UNSPEC:
                if (address != null) {
                    throw new HAProxyProtocolException("unable to validate an AF_UNSPEC address: " + address);
                }
                return;
            case AF_UNIX:
                return;
        }

        if (address == null) {
            throw new NullPointerException("address");
        }

        switch (addrFamily) {
            case AF_IPv4:
                if (!NetUtil.isValidIpV4Address(address)) {
                    throw new HAProxyProtocolException("invalid IPv4 address: " + address);
                }
                break;
            case AF_IPv6:
                if (!NetUtil.isValidIpV6Address(address)) {
                    throw new HAProxyProtocolException("invalid IPv6 address: " + address);
                }
                break;
            default:
                throw new Error();
        }
    }