Method NetUtils.ip_in_block()


Method ip_in_block

bool ip_in_block(int net, int mask, int|string ip)

Description

Checks whether an IP address is in a block.

The net and mask parameters should be as returned from cidr_to_netmask.

Throws an error if the IP address could not be parsed.

Parameter net

The network component of the block.

Parameter mask

The bitmask of the block.

Parameter ip

The IP address to check, in either string or binary representation.

Returns

true if the IP is in the given block, false otherwise.