install gulp

This commit is contained in:
2018-05-28 13:26:25 +02:00
parent 2de92c908b
commit 04fab6ba46
8032 changed files with 709336 additions and 3100 deletions
@@ -0,0 +1,19 @@
[
" 127.0.0.1",
"127.0.0.1 ",
"127.0.0.1 127.0.0.1",
"127.0.0.256",
"127.0.0.1//1",
"127.0.0.1/0x1",
"127.0.0.1/-1",
"127.0.0.1/ab",
"127.0.0.1/",
"127.0.0.256/32",
"127.0.0.1/33",
"001.002.003.004",
" ----- Valid but with subnets ----- ",
"127.0.0.1/02",
"127.0.0.1/32",
"255.255.255.255/32"
]
@@ -0,0 +1,335 @@
[
"':10.0.0.1",
"-1",
"::1 ::1",
"02001:0000:1234:0000:0000:C1C0:ABCD:0876",
"1.2.3.4",
"1.2.3.4:1111:2222:3333:4444::5555",
"1.2.3.4:1111:2222:3333::5555",
"1.2.3.4:1111:2222::5555",
"1.2.3.4:1111::5555",
"1.2.3.4::",
"1.2.3.4::5555",
"1111",
"11112222:3333:4444:5555:6666:1.2.3.4",
"11112222:3333:4444:5555:6666:7777:8888",
"::1//64",
"::1/0001",
"1111:",
"1111:1.2.3.4",
"1111:2222",
"1111:22223333:4444:5555:6666:1.2.3.4",
"1111:22223333:4444:5555:6666:7777:8888",
"1111:2222:",
"1111:2222:1.2.3.4",
"1111:2222:3333",
"1111:2222:33334444:5555:6666:1.2.3.4",
"1111:2222:33334444:5555:6666:7777:8888",
"1111:2222:3333:",
"1111:2222:3333:1.2.3.4",
"1111:2222:3333:4444",
"1111:2222:3333:44445555:6666:1.2.3.4",
"1111:2222:3333:44445555:6666:7777:8888",
"1111:2222:3333:4444:",
"1111:2222:3333:4444:1.2.3.4",
"1111:2222:3333:4444:5555",
"1111:2222:3333:4444:55556666:1.2.3.4",
"1111:2222:3333:4444:55556666:7777:8888",
"1111:2222:3333:4444:5555:",
"1111:2222:3333:4444:5555:1.2.3.4",
"1111:2222:3333:4444:5555:6666",
"1111:2222:3333:4444:5555:66661.2.3.4",
"1111:2222:3333:4444:5555:66667777:8888",
"1111:2222:3333:4444:5555:6666:",
"1111:2222:3333:4444:5555:6666:00.00.00.00",
"1111:2222:3333:4444:5555:6666:000.000.000.000",
"1111:2222:3333:4444:5555:6666:1.2.3.4.5",
"1111:2222:3333:4444:5555:6666:255.255.255255",
"1111:2222:3333:4444:5555:6666:255.255255.255",
"1111:2222:3333:4444:5555:6666:255255.255.255",
"1111:2222:3333:4444:5555:6666:256.256.256.256",
"1111:2222:3333:4444:5555:6666:7777",
"1111:2222:3333:4444:5555:6666:77778888",
"1111:2222:3333:4444:5555:6666:7777:",
"1111:2222:3333:4444:5555:6666:7777:1.2.3.4",
"1111:2222:3333:4444:5555:6666:7777:8888:",
"1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4",
"1111:2222:3333:4444:5555:6666:7777:8888:9999",
"1111:2222:3333:4444:5555:6666:7777:8888::",
"1111:2222:3333:4444:5555:6666:7777:::",
"1111:2222:3333:4444:5555:6666::1.2.3.4",
"1111:2222:3333:4444:5555:6666::8888:",
"1111:2222:3333:4444:5555:6666:::",
"1111:2222:3333:4444:5555:6666:::8888",
"1111:2222:3333:4444:5555::7777:8888:",
"1111:2222:3333:4444:5555::7777::",
"1111:2222:3333:4444:5555::8888:",
"1111:2222:3333:4444:5555:::",
"1111:2222:3333:4444:5555:::1.2.3.4",
"1111:2222:3333:4444:5555:::7777:8888",
"1111:2222:3333:4444::5555:",
"1111:2222:3333:4444::6666:7777:8888:",
"1111:2222:3333:4444::6666:7777::",
"1111:2222:3333:4444::6666::8888",
"1111:2222:3333:4444::7777:8888:",
"1111:2222:3333:4444::8888:",
"1111:2222:3333:4444:::",
"1111:2222:3333:4444:::6666:1.2.3.4",
"1111:2222:3333:4444:::6666:7777:8888",
"1111:2222:3333::5555:",
"1111:2222:3333::5555:6666:7777:8888:",
"1111:2222:3333::5555:6666:7777::",
"1111:2222:3333::5555:6666::8888",
"1111:2222:3333::5555::1.2.3.4",
"1111:2222:3333::5555::7777:8888",
"1111:2222:3333::6666:7777:8888:",
"1111:2222:3333::7777:8888:",
"1111:2222:3333::8888:",
"1111:2222:3333:::",
"1111:2222:3333:::5555:6666:1.2.3.4",
"1111:2222:3333:::5555:6666:7777:8888",
"1111:2222::4444:5555:6666:7777:8888:",
"1111:2222::4444:5555:6666:7777::",
"1111:2222::4444:5555:6666::8888",
"1111:2222::4444:5555::1.2.3.4",
"1111:2222::4444:5555::7777:8888",
"1111:2222::4444::6666:1.2.3.4",
"1111:2222::4444::6666:7777:8888",
"1111:2222::5555:",
"1111:2222::5555:6666:7777:8888:",
"1111:2222::6666:7777:8888:",
"1111:2222::7777:8888:",
"1111:2222::8888:",
"1111:2222:::",
"1111:2222:::4444:5555:6666:1.2.3.4",
"1111:2222:::4444:5555:6666:7777:8888",
"1111::3333:4444:5555:6666:7777:8888:",
"1111::3333:4444:5555:6666:7777::",
"1111::3333:4444:5555:6666::8888",
"1111::3333:4444:5555::1.2.3.4",
"1111::3333:4444:5555::7777:8888",
"1111::3333:4444::6666:1.2.3.4",
"1111::3333:4444::6666:7777:8888",
"1111::3333::5555:6666:1.2.3.4",
"1111::3333::5555:6666:7777:8888",
"1111::4444:5555:6666:7777:8888:",
"1111::5555:",
"1111::5555:6666:7777:8888:",
"1111::6666:7777:8888:",
"1111::7777:8888:",
"1111::8888:",
"1111:::",
"1111:::3333:4444:5555:6666:1.2.3.4",
"1111:::3333:4444:5555:6666:7777:8888",
"123",
"12345::6:7:8",
"124.15.6.89/60",
"1:2:3:4:5:6:7:8:9",
"1:2:3::4:5:6:7:8:9",
"1:2:3::4:5::7:8",
"1::1.2.256.4",
"1::1.2.3.256",
"1::1.2.3.300",
"1::1.2.3.900",
"1::1.2.300.4",
"1::1.2.900.4",
"1::1.256.3.4",
"1::1.300.3.4",
"1::1.900.3.4",
"1::256.2.3.4",
"1::260.2.3.4",
"1::2::3",
"1::300.2.3.4",
"1::300.300.300.300",
"1::3000.30.30.30",
"1::400.2.3.4",
"1::5:1.2.256.4",
"1::5:1.2.3.256",
"1::5:1.2.3.300",
"1::5:1.2.3.900",
"1::5:1.2.300.4",
"1::5:1.2.900.4",
"1::5:1.256.3.4",
"1::5:1.300.3.4",
"1::5:1.900.3.4",
"1::5:256.2.3.4",
"1::5:260.2.3.4",
"1::5:300.2.3.4",
"1::5:300.300.300.300",
"1::5:3000.30.30.30",
"1::5:400.2.3.4",
"1::5:900.2.3.4",
"1::900.2.3.4",
"1:::3:4:5",
"2001:0000:1234: 0000:0000:C1C0:ABCD:0876",
"2001:0000:1234:0000:00001:C1C0:ABCD:0876",
"2001:0000:1234:0000:0000:C1C0:ABCD:0876 0",
"2001:1:1:1:1:1:255Z255X255Y255",
"2001::FFD3::57ab",
"2001:DB8:0:0:8:800:200C:417A:221",
"2001:db8:85a3::8a2e:37023:7334",
"2001:db8:85a3::8a2e:370k:7334",
"3ffe:0b00:0000:0001:0000:0000:000a",
"3ffe:b00::1::a",
":",
":1.2.3.4",
":1111:2222:3333:4444:5555:6666:1.2.3.4",
":1111:2222:3333:4444:5555:6666:7777:8888",
":1111:2222:3333:4444:5555:6666:7777::",
":1111:2222:3333:4444:5555:6666::",
":1111:2222:3333:4444:5555:6666::8888",
":1111:2222:3333:4444:5555::",
":1111:2222:3333:4444:5555::1.2.3.4",
":1111:2222:3333:4444:5555::7777:8888",
":1111:2222:3333:4444:5555::8888",
":1111:2222:3333:4444::",
":1111:2222:3333:4444::1.2.3.4",
":1111:2222:3333:4444::5555",
":1111:2222:3333:4444::6666:1.2.3.4",
":1111:2222:3333:4444::6666:7777:8888",
":1111:2222:3333:4444::7777:8888",
":1111:2222:3333:4444::8888",
":1111:2222:3333::",
":1111:2222:3333::1.2.3.4",
":1111:2222:3333::5555",
":1111:2222:3333::5555:6666:1.2.3.4",
":1111:2222:3333::5555:6666:7777:8888",
":1111:2222:3333::6666:1.2.3.4",
":1111:2222:3333::6666:7777:8888",
":1111:2222:3333::7777:8888",
":1111:2222:3333::8888",
":1111:2222::",
":1111:2222::1.2.3.4",
":1111:2222::4444:5555:6666:1.2.3.4",
":1111:2222::4444:5555:6666:7777:8888",
":1111:2222::5555",
":1111:2222::5555:6666:1.2.3.4",
":1111:2222::5555:6666:7777:8888",
":1111:2222::6666:1.2.3.4",
":1111:2222::6666:7777:8888",
":1111:2222::7777:8888",
":1111:2222::8888",
":1111::",
":1111::1.2.3.4",
":1111::3333:4444:5555:6666:1.2.3.4",
":1111::3333:4444:5555:6666:7777:8888",
":1111::4444:5555:6666:1.2.3.4",
":1111::4444:5555:6666:7777:8888",
":1111::5555",
":1111::5555:6666:1.2.3.4",
":1111::5555:6666:7777:8888",
":1111::6666:1.2.3.4",
":1111::6666:7777:8888",
":1111::7777:8888",
":1111::8888",
":2222:3333:4444:5555:6666:1.2.3.4",
":2222:3333:4444:5555:6666:7777:8888",
":3333:4444:5555:6666:1.2.3.4",
":3333:4444:5555:6666:7777:8888",
":4444:5555:6666:1.2.3.4",
":4444:5555:6666:7777:8888",
":5555:6666:1.2.3.4",
":5555:6666:7777:8888",
":6666:1.2.3.4",
":6666:7777:8888",
":7777:8888",
":8888",
"::-1",
"::.",
"::..",
"::...",
"::...4",
"::..3.",
"::..3.4",
"::.2..",
"::.2.3.",
"::.2.3.4",
"::1...",
"::1.2..",
"::1.2.256.4",
"::1.2.3.",
"::1.2.3.256",
"::1.2.3.300",
"::1.2.3.900",
"::1.2.300.4",
"::1.2.900.4",
"::1.256.3.4",
"::1.300.3.4",
"::1.900.3.4",
"::1111:2222:3333:4444:5555:6666::",
"::2222:3333:4444:5555:6666:7777:1.2.3.4",
"::2222:3333:4444:5555:6666:7777:8888:",
"::2222:3333:4444:5555:6666:7777:8888:9999",
"::2222:3333:4444:5555:7777:8888::",
"::2222:3333:4444:5555:7777::8888",
"::2222:3333:4444:5555::1.2.3.4",
"::2222:3333:4444:5555::7777:8888",
"::2222:3333:4444::6666:1.2.3.4",
"::2222:3333:4444::6666:7777:8888",
"::2222:3333::5555:6666:1.2.3.4",
"::2222:3333::5555:6666:7777:8888",
"::2222::4444:5555:6666:1.2.3.4",
"::2222::4444:5555:6666:7777:8888",
"::256.2.3.4",
"::260.2.3.4",
"::300.2.3.4",
"::300.300.300.300",
"::3000.30.30.30",
"::3333:4444:5555:6666:7777:8888:",
"::400.2.3.4",
"::4444:5555:6666:7777:8888:",
"::5555:",
"::5555:6666:7777:8888:",
"::6666:7777:8888:",
"::7777:8888:",
"::8888:",
"::900.2.3.4",
":::",
":::1.2.3.4",
":::2222:3333:4444:5555:6666:1.2.3.4",
":::2222:3333:4444:5555:6666:7777:8888",
":::3333:4444:5555:6666:7777:8888",
":::4444:5555:6666:1.2.3.4",
":::4444:5555:6666:7777:8888",
":::5555",
":::5555:6666:1.2.3.4",
":::5555:6666:7777:8888",
":::6666:1.2.3.4",
":::6666:7777:8888",
":::7777:8888",
":::8888",
"::ffff:192x168.1.26",
"::ffff:2.3.4",
"::ffff:257.1.2.3",
"FF01::101::2",
"FF02:0000:0000:0000:0000:0000:0000:0000:0001",
"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4",
"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX",
"a::b::c",
"a::g",
"a:a:a:a:a:a:a:a:a",
"a:aaaaa::",
"a:b",
"a:b:c:d:e:f:g:0",
"fe80:0000:0000:0000:0204:61ff:254.157.241.086",
"ffff:",
"ffff::ffff::ffff",
"ffgg:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
"ldkfj",
"::/129",
"1000:://32",
"::/",
" ----- Valid but with subnets ----- ",
"0000:0000:0000:0000:0000:0000:0000:0000/128",
"0:1:2:3:4:5:6:7/001",
"0:1:2:3:4:5:6:7/128",
"2001:0DB8:0000:CD30:0000:0000:0000:0000/60",
"2001:0DB8:0:CD30::/60",
"2001:0DB8::CD30:0:0:0:0/60",
"::/128",
"::1/128",
"FE80::/10",
"FEC0::/10",
"FF00::/8"
]
@@ -0,0 +1,6 @@
[
"127.0.0.1",
"1.1.1.1",
"255.255.255.255",
"255.1.255.1"
]
@@ -0,0 +1,189 @@
[
"0000:0000:0000:0000:0000:0000:0000:0000",
"0000:0000:0000:0000:0000:0000:0000:0001",
"0:0:0:0:0:0:0:0",
"0:0:0:0:0:0:0:1",
"0:0:0:0:0:0:0::",
"0:0:0:0:0:0:13.1.68.3",
"0:0:0:0:0:0::",
"0:0:0:0:0::",
"0:0:0:0:0:FFFF:129.144.52.38",
"0:0:0:0:1:0:0:0",
"0:0:0:0::",
"0:0:0::",
"0:0::",
"0:1:2:3:4:5:6:7",
"0::",
"0:a:b:c:d:e:f::",
"1080:0:0:0:8:800:200c:417a",
"1080::8:800:200c:417a",
"1111:2222:3333:4444:5555:6666:123.123.123.123",
"1111:2222:3333:4444:5555:6666:7777:8888",
"1111:2222:3333:4444:5555:6666:7777::",
"1111:2222:3333:4444:5555:6666::",
"1111:2222:3333:4444:5555:6666::8888",
"1111:2222:3333:4444:5555::",
"1111:2222:3333:4444:5555::123.123.123.123",
"1111:2222:3333:4444:5555::7777:8888",
"1111:2222:3333:4444:5555::8888",
"1111:2222:3333:4444::",
"1111:2222:3333:4444::123.123.123.123",
"1111:2222:3333:4444::6666:123.123.123.123",
"1111:2222:3333:4444::6666:7777:8888",
"1111:2222:3333:4444::7777:8888",
"1111:2222:3333:4444::8888",
"1111:2222:3333::",
"1111:2222:3333::123.123.123.123",
"1111:2222:3333::5555:6666:123.123.123.123",
"1111:2222:3333::5555:6666:7777:8888",
"1111:2222:3333::6666:123.123.123.123",
"1111:2222:3333::6666:7777:8888",
"1111:2222:3333::7777:8888",
"1111:2222:3333::8888",
"1111:2222::",
"1111:2222::123.123.123.123",
"1111:2222::4444:5555:6666:123.123.123.123",
"1111:2222::4444:5555:6666:7777:8888",
"1111:2222::5555:6666:123.123.123.123",
"1111:2222::5555:6666:7777:8888",
"1111:2222::6666:123.123.123.123",
"1111:2222::6666:7777:8888",
"1111:2222::7777:8888",
"1111:2222::8888",
"1111::",
"1111::123.123.123.123",
"1111::3333:4444:5555:6666:123.123.123.123",
"1111::3333:4444:5555:6666:7777:8888",
"1111::4444:5555:6666:123.123.123.123",
"1111::4444:5555:6666:7777:8888",
"1111::5555:6666:123.123.123.123",
"1111::5555:6666:7777:8888",
"1111::6666:123.123.123.123",
"1111::6666:7777:8888",
"1111::7777:8888",
"1111::8888",
"1:2:3:4:5:6:1.2.3.4",
"1:2:3:4:5:6:7:8",
"1:2:3:4:5:6::",
"1:2:3:4:5:6::8",
"1:2:3:4:5::",
"1:2:3:4:5::1.2.3.4",
"1:2:3:4:5::7:8",
"1:2:3:4:5::8",
"1:2:3:4::",
"1:2:3:4::1.2.3.4",
"1:2:3:4::5:1.2.3.4",
"1:2:3:4::7:8",
"1:2:3:4::8",
"1:2:3::",
"1:2:3::1.2.3.4",
"1:2:3::5:1.2.3.4",
"1:2:3::7:8",
"1:2:3::8",
"1:2::",
"1:2::1.2.3.4",
"1:2::5:1.2.3.4",
"1:2::7:8",
"1:2::8",
"1::",
"1::1.2.3.4",
"1::2:3",
"1::2:3:4",
"1::2:3:4:5",
"1::2:3:4:5:6",
"1::2:3:4:5:6:7",
"1::5:1.2.3.4",
"1::5:11.22.33.44",
"1::7:8",
"1::8",
"2001:0000:1234:0000:0000:C1C0:ABCD:0876",
"2001:0000:4136:e378:8000:63bf:3fff:fdd2",
"2001:0db8:0000:0000:0000:0000:1428:57ab",
"2001:0db8:0000:0000:0000::1428:57ab",
"2001:0db8:0:0:0:0:1428:57ab",
"2001:0db8:0:0::1428:57ab",
"2001:0db8:1234:0000:0000:0000:0000:0000",
"2001:0db8:1234::",
"2001:0db8:1234:ffff:ffff:ffff:ffff:ffff",
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"2001:0db8::1428:57ab",
"2001::CE49:7601:2CAD:DFFF:7C94:FFFE",
"2001::CE49:7601:E866:EFFF:62C3:FFFE",
"2001:DB8:0:0:8:800:200C:417A",
"2001:DB8::8:800:200C:417A",
"2001:db8:85a3:0:0:8a2e:370:7334",
"2001:db8:85a3::8a2e:370:7334",
"2001:db8::",
"2001:db8::1428:57ab",
"2001:db8:a::123",
"2002::",
"2608::3:5",
"2608:af09:30:0:0:0:0:134",
"2608:af09:30::102a:7b91:c239:baff",
"2::10",
"3ffe:0b00:0000:0000:0001:0000:0000:000a",
"7:6:5:4:3:2:1:0",
"::",
"::0",
"::0:0",
"::0:0:0",
"::0:0:0:0",
"::0:0:0:0:0",
"::0:0:0:0:0:0",
"::0:0:0:0:0:0:0",
"::0:a:b:c:d:e:f",
"::1",
"::123.123.123.123",
"::13.1.68.3",
"::2222:3333:4444:5555:6666:123.123.123.123",
"::2222:3333:4444:5555:6666:7777:8888",
"::2:3",
"::2:3:4",
"::2:3:4:5",
"::2:3:4:5:6",
"::2:3:4:5:6:7",
"::2:3:4:5:6:7:8",
"::3333:4444:5555:6666:7777:8888",
"::4444:5555:6666:123.123.123.123",
"::4444:5555:6666:7777:8888",
"::5555:6666:123.123.123.123",
"::5555:6666:7777:8888",
"::6666:123.123.123.123",
"::6666:7777:8888",
"::7777:8888",
"::8",
"::8888",
"::FFFF:129.144.52.38",
"::ffff:0:0",
"::ffff:0c22:384e",
"::ffff:12.34.56.78",
"::ffff:192.0.2.128",
"::ffff:192.168.1.1",
"::ffff:192.168.1.26",
"::ffff:c000:280",
"FF01:0:0:0:0:0:0:101",
"FF01::101",
"FF02:0000:0000:0000:0000:0000:0000:0001",
"a:b:c:d:e:f:0::",
"fe80:0000:0000:0000:0204:61ff:fe9d:f156",
"fe80:0:0:0:204:61ff:254.157.241.86",
"fe80:0:0:0:204:61ff:fe9d:f156",
"fe80::",
"fe80::1",
"fe80::204:61ff:254.157.241.86",
"fe80::204:61ff:fe9d:f156",
"fe80::217:f2ff:254.7.237.98",
"fe80::217:f2ff:fe07:ed62",
"fedc:ba98:7654:3210:fedc:ba98:7654:3210",
"ff02::1",
"ffff::",
"ffff::3:5",
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
"a:0::0:b",
"a:0:0::0:b",
"a:0::0:0:b",
"a::0:0:b",
"a::0:b",
"a:0::b",
"a:0:0::b"
]
+90
View File
@@ -0,0 +1,90 @@
var reIpv4FirstPass = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
var reSubnetString = /\/\d{1,3}(?=%|$)/
var reForwardSlash = /\//
var reZone = /%.*$/
var reBadCharacters = /([^0-9a-f:/%])/i
var reBadAddress = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/i
function validate4 (input) {
if (!(reIpv4FirstPass.test(input))) return false
var parts = input.split('.')
if (parts.length !== 4) return false
if (parts[0][0] === '0' && parts[0].length > 1) return false
if (parts[1][0] === '0' && parts[1].length > 1) return false
if (parts[2][0] === '0' && parts[2].length > 1) return false
if (parts[3][0] === '0' && parts[3].length > 1) return false
var n0 = Number(parts[0])
var n1 = Number(parts[1])
var n2 = Number(parts[2])
var n3 = Number(parts[3])
return (n0 >= 0 && n0 < 256 && n1 >= 0 && n1 < 256 && n2 >= 0 && n2 < 256 && n3 >= 0 && n3 < 256)
}
function validate6 (input) {
var withoutSubnet = input.replace(reSubnetString, '')
var hasSubnet = (input.length !== withoutSubnet.length)
// FIXME: this should probably be an option in the future
if (hasSubnet) return false
if (!hasSubnet) {
if (reForwardSlash.test(input)) return false
}
var withoutZone = withoutSubnet.replace(reZone, '')
var lastPartSeparator = withoutZone.lastIndexOf(':')
if (lastPartSeparator === -1) return false
var lastPart = withoutZone.substring(lastPartSeparator + 1)
var hasV4Part = validate4(lastPart)
var address = (hasV4Part ? withoutZone.substring(0, lastPartSeparator + 1) + '1234:5678' : withoutZone)
if (reBadCharacters.test(address)) return false
if (reBadAddress.test(address)) return false
var halves = address.split('::')
if (halves.length > 2) return false
if (halves.length === 2) {
var first = (halves[0] === '' ? [] : halves[0].split(':'))
var last = (halves[1] === '' ? [] : halves[1].split(':'))
var remainingLength = 8 - (first.length + last.length)
if (remainingLength <= 0) return false
} else {
if (address.split(':').length !== 8) return false
}
return true
}
function validate (input) {
return validate4(input) || validate6(input)
}
module.exports = function validator (options) {
if (!options) options = {}
if (options.version === 4) return validate4
if (options.version === 6) return validate6
if (options.version == null) return validate
throw new Error('Unknown version: ' + options.version)
}
module.exports['__all_regexes__'] = [
reIpv4FirstPass,
reSubnetString,
reForwardSlash,
reZone,
reBadCharacters,
reBadAddress
]
+50
View File
@@ -0,0 +1,50 @@
{
"_args": [
[
"is-my-ip-valid@1.0.0",
"/mnt/data/Sites/anissabensalah.net/user/themes/anissabensalah"
]
],
"_development": true,
"_from": "is-my-ip-valid@1.0.0",
"_id": "is-my-ip-valid@1.0.0",
"_inBundle": false,
"_integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==",
"_location": "/is-my-ip-valid",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "is-my-ip-valid@1.0.0",
"name": "is-my-ip-valid",
"escapedName": "is-my-ip-valid",
"rawSpec": "1.0.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
},
"_requiredBy": [
"/is-my-json-valid"
],
"_resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz",
"_spec": "1.0.0",
"_where": "/mnt/data/Sites/anissabensalah.net/user/themes/anissabensalah",
"bugs": {
"url": "https://github.com/LinusU/is-my-ip-valid/issues"
},
"description": "A small lib to validate IP addresses.",
"devDependencies": {
"safe-regex": "^1.1.0",
"standard": "^10.0.3"
},
"homepage": "https://github.com/LinusU/is-my-ip-valid#readme",
"license": "MIT",
"name": "is-my-ip-valid",
"repository": {
"type": "git",
"url": "git+https://github.com/LinusU/is-my-ip-valid.git"
},
"scripts": {
"test": "standard && node test"
},
"version": "1.0.0"
}
+42
View File
@@ -0,0 +1,42 @@
# Is my IP valid
A small lib to validate IP addresses.
## Installation
```sh
npm install --save is-my-ip-valid
```
## Usage
```js
const validator = require('is-my-ip-valid')
const validate = validator()
const validate4 = validator({ version: 4 })
const validate6 = validator({ version: 6 })
console.log(validate('127.0.0.1'))
//=> true
console.log(validate4('127.0.0.1'))
//=> true
console.log(validate6('127.0.0.1'))
//=> false
console.log(validate('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true
console.log(validate4('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> false
console.log(validate6('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true
```
## Acknowledgements
The code is mostly based on this wonderful library: [beaugunderson/ip-address](https://github.com/beaugunderson/ip-address)
All regexes used are audited for catastrophic backtracking by this module: [substack/safe-regex](https://github.com/substack/safe-regex)
+26
View File
@@ -0,0 +1,26 @@
var assert = require('assert')
var safeRegex = require('safe-regex')
var validator = require('./')
var invalid4 = require('./fixtures/invalid-ipv4-addresses')
var invalid6 = require('./fixtures/invalid-ipv6-addresses')
var valid4 = require('./fixtures/valid-ipv4-addresses')
var valid6 = require('./fixtures/valid-ipv6-addresses')
var validate = validator()
var validate4 = validator({ version: 4 })
var validate6 = validator({ version: 6 })
var i
for (i = 0; i < validator.__all_regexes__.length; i++) assert.ok(safeRegex(validator.__all_regexes__[i]), validator.__all_regexes__[i] + ' should be safe regex')
for (i = 0; i < invalid4.length; i++) assert.strictEqual(validate4(invalid4[i]), false, invalid4[i] + ' should be invalid IPv4')
for (i = 0; i < invalid6.length; i++) assert.strictEqual(validate6(invalid6[i]), false, invalid6[i] + ' should be invalid IPv6')
for (i = 0; i < valid4.length; i++) assert.strictEqual(validate(valid4[i]), true, valid4[i] + ' should be valid IP')
for (i = 0; i < valid4.length; i++) assert.strictEqual(validate4(valid4[i]), true, valid4[i] + ' should be valid IPv4')
for (i = 0; i < valid6.length; i++) assert.strictEqual(validate(valid6[i]), true, valid6[i] + ' should be valid IP')
for (i = 0; i < valid6.length; i++) assert.strictEqual(validate6(valid6[i]), true, valid6[i] + ' should be valid IPv6')