Skip to content

jcamelis/ip-in-range

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

INSTALL

npm install @jcamelis/ip-in-range

How to use

Evaluate an ip address against a range

const ipInRange = require('@jcamelis/ip-in-range').ipInRange


const range = {
    from: '192.0.0.1',
    to: '192.0.0.12'
};

// Returns true
ipInRange('192.0.0.4', range);

// Returns false
ipInRange('192.0.0.16', range);

Evaluate an ip address against an array of ranges

const ipInRanges = require('@jcamelis/ip-in-range').ipInRanges


const ranges = [
    {
        from: '192.0.0.1',
        to: '192.0.0.12'
    },
    {
        from: '192.0.0.32',
        to: '192.0.0.40'
    },
    {
        from: '192.0.0.50',
        to: '192.0.0.60'
    }
];

// Returns true
ipInRanges('192.0.0.34', ranges);

// Returns false
ipInRanges('192.0.0.43', ranges);

About

Check if an ip v4 address is in a range of ips

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published