Minimal IPv4 CIDR matching, for selecting cluster members on meshes that have no hostnames (e.g. plain WireGuard).
Summary
Functions
Returns true when the IPv4 address string falls inside the CIDR.
Parses an IPv4 CIDR string. Raises ArgumentError on invalid input.
Types
Functions
Returns true when the IPv4 address string falls inside the CIDR.
iex> cidr = LibclusterMesh.CIDR.parse!("10.77.0.0/24")
iex> LibclusterMesh.CIDR.contains?(cidr, "10.77.0.13")
true
iex> LibclusterMesh.CIDR.contains?(cidr, "10.78.0.13")
false
iex> LibclusterMesh.CIDR.contains?(cidr, "not-an-ip")
false
Parses an IPv4 CIDR string. Raises ArgumentError on invalid input.
iex> LibclusterMesh.CIDR.parse!("10.77.0.0/24")
{172818432, 24}
iex> LibclusterMesh.CIDR.parse!("10.77.0.0/-0")
** (ArgumentError) invalid IPv4 CIDR: "10.77.0.0/-0"