Skip to content

Commit

Permalink
Check against fc00::/7 ipv6 private space
Browse files Browse the repository at this point in the history
  • Loading branch information
bcbailey-godaddy authored and indexzero committed Mar 4, 2016
1 parent 7b59d29 commit e5b399b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ ip.isPrivate = function(addr) {
.test(addr) ||
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^fc00:/i.test(addr) ||
/^f[cd][0-9a-f]{2}:/i.test(addr) ||
/^fe80:/i.test(addr) ||
/^::1$/.test(addr) ||
/^::$/.test(addr);
Expand Down
1 change: 1 addition & 0 deletions test/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ describe('IP library for node.js', function() {
});

it('should check if an address is from a private IPv6 network', function() {
assert.equal(ip.isPrivate('fd12:3456:789a:1::1'), true);
assert.equal(ip.isPrivate('fe80::f2de:f1ff:fe3f:307e'), true);
assert.equal(ip.isPrivate('::ffff:10.100.1.42'), true);
assert.equal(ip.isPrivate('::FFFF:172.16.200.1'), true);
Expand Down

0 comments on commit e5b399b

Please sign in to comment.