Util.ip Module

Import

import { ip } from 'util';

Methods

is_ipv4(ip) is_cidr(cidr) contains_ip(array, ip) ip4toint(ip) inttoip4(int) ip4incidr(ip, cidr)

is_ipv4(ip)

Returns true if the argument is a valid IPv4 address.

Arguments

  • ip (String)

Returns

Boolean

is_cidr(cidr)

Returns true if the argument is a valid IPv4 address range.

Arguments

  • cidr (String)

Returns

Boolean

contains_ip(array, ip)

Returns true if the ip argument is a valid IPv4 address and contained array.

Arguments

  • array (String[]) An array of ip addresses or cidr ranges against which to match ip

  • ip (String)

Returns

Boolean

ip4toint(ip)

Converts an IPv4 string to an integer.

Arguments

  • ip (String)

Returns

Number

inttoip4(int)

Converts an integer to an IPv4 string.

Arguments

  • int (Number)

Returns

String

ip4incidr(ip, cidr)

Returns true if ip is contained in the cidr range.

Arguments

  • ip (String)

  • cidr (String)

Returns

Boolean

Last updated