Automattic\WooCommerce\StoreApi

Authentication::validate_ipprotected staticWC 1.0

Uses filter_var() to validate and return ipv4 and ipv6 addresses Will return 0.0.0.0 if the ip is not valid. This is done to group and still rate limit invalid ips.

Method of the class: Authentication{}

No Hooks.

Returns

String.

Usage

$result = Authentication::validate_ip( $ip );
$ip(string) (required)
ipv4 or ipv6 ip string.

Authentication::validate_ip() code WC 10.3.3

protected static function validate_ip( $ip ) {
	$ip = filter_var(
		$ip,
		FILTER_VALIDATE_IP,
		array( FILTER_FLAG_NO_RES_RANGE, FILTER_FLAG_IPV6 )
	);

	return $ip ?: '0.0.0.0';
}