UNPKG

subnet-check

Version:

Check if an IPv4 or IPv6 address is contained in the given CIDR subnet

26 lines (25 loc) 1.24 kB
/** * Given a mapped IPv4 address, return the bare IPv4 equivalent. */ export declare function extractMappedIpv4(ip: string): string; /** * Test if the given IPv6 address is contained in the specified subnet. * @param address the IPv6 address to check * @param subnet the IPv6 CIDR to test (or an array of them) * @throws if the address or subnet are not valid IP addresses, or the CIDR prefix length * is not valid */ export declare function isInSubnet(address: string, subnetOrSubnets: string | string[]): boolean; /** Test if the given IP address is a private/internal IP address. */ export declare function isPrivate(address: string): boolean; /** Test if the given IP address is a localhost address. */ export declare function isLocalhost(address: string): boolean; /** Test if the given IP address is an IPv4 address mapped onto IPv6 */ export declare function isIPv4MappedAddress(address: string): boolean; /** Test if the given IP address is in a known reserved range and not a normal host IP */ export declare function isReserved(address: string): boolean; /** * Test if the given IP address is a special address of any kind (private, reserved, * localhost) */ export declare function isSpecial(address: string): boolean;