Skip to content

Node.js module checking whether the domain points to private IP addresses

Notifications You must be signed in to change notification settings

wormly/private-ips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests whether a domain points to a private IP address, supports IPv4 and IPv6, handles multiple records properly.

A domain can point to multiple IP addresses, for example

  • 8.8.8.8
  • 127.0.0.1

In this case most software like browsers, curl, etc. will try another IP address if one is unavailable. This can cause security issues when server has can access protected resources on the internal network, provides publicly available api for fetching URL-s and only checks whether the first IP address is public.

Options:

  • ipv4 - test A (IPv4) records, defaults to true
  • ipv6 - test AAAA (IPv6) records, defaults to false

Methods

  • isPrivate(domain, callback) - is the domain private? Supports IP, domain, and URL. callback(err, private) is called on finish

Example usage:

var checker = require('private-ips')({
    ipv6: true
});
checker.isPrivate('some-domain.com', function(err, private) {
    if (! err && ! private) next();
});

About

Node.js module checking whether the domain points to private IP addresses

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published