1'use strict'; 2require('../common'); 3const assert = require('assert'); 4const net = require('net'); 5 6const v4 = [ 7 '0.0.0.0', 8 '8.8.8.8', 9 '127.0.0.1', 10 '100.100.100.100', 11 '192.168.0.1', 12 '18.101.25.153', 13 '123.23.34.2', 14 '172.26.168.134', 15 '212.58.241.131', 16 '128.0.0.0', 17 '23.71.254.72', 18 '223.255.255.255', 19 '192.0.2.235', 20 '99.198.122.146', 21 '46.51.197.88', 22 '173.194.34.134', 23]; 24 25const v4not = [ 26 '.100.100.100.100', 27 '100..100.100.100.', 28 '100.100.100.100.', 29 '999.999.999.999', 30 '256.256.256.256', 31 '256.100.100.100.100', 32 '123.123.123', 33 'http://123.123.123', 34 '1000.2.3.4', 35 '999.2.3.4', 36 '0000000192.168.0.200', 37 '192.168.0.2000000000', 38]; 39 40v4.forEach((ip) => { 41 assert.strictEqual(net.isIPv4(ip), true); 42}); 43 44v4not.forEach((ip) => { 45 assert.strictEqual(net.isIPv4(ip), false); 46}); 47