-
Notifications
You must be signed in to change notification settings - Fork 0
isNetworkIncludes()
Evgheniy Kovaliov edited this page May 9, 2023
·
3 revisions
Method that allows you to check if ip network contains ip address.
Ip network and ip address must be correct. (see validation)
Parameters:
-
network: string— ip network to check including in. -
ip: string— ip address.
Return:
-
true/false
Invalide ip network!:
- entered argument is not a correct ip network.
Invalide ip address!:
- entered argument is not a correct ip address.
ipv4.isNetworkIncludes('0.0.0.0/0', '111.222.91.19'); // true
ipv4.isNetworkIncludes('255.255.255.255/32', '255.255.255.255'); // true
ipv4.isNetworkIncludes('0.0.0.0/0', '34.224.199.123'); // true
ipv4.isNetworkIncludes('34.100.252.0/22', '34.100.255.12'); // true
ipv4.isNetworkIncludes('34.100.252.0/22', '34.101.255.12'); // false
ipv4.isNetworkIncludes('34.100.0.0/16', '34.102.255.12'); // false
ipv4.isNetworkIncludes('0.0.0.0/31', '0.0.0.2'); // false
ipv4.isNetworkIncludes('255.255.200.0/33', '128.0.0.12'); // Error: Invalide ip network!
ipv4.isNetworkIncludes('34.100.252.3/22', '34.100.255.12'); // Error: Invalide ip network!
ipv4.isNetworkIncludes('34.100.252.0/22', '34.100.255.12.0'); // Error: Invalide ip address!- Is used in other methods.
Author: Evgheniy Kovaliov <kovaliov.evgeniy11@gmail.com>
For ip version 4
For ip version 6