Skip to content

aviv1ron1/ip2asn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip2asn

nodejs module for getting asn for a given ip

utilizes theMaxMind GeoLite Legacy Downloadable Databases csv format

This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com

example

var ip2asn = require('./index.js')();

var opts = {};

ip2asn.lastUpdated(function(err, t) {
    if (err) {
        console.error(err);
    } else {
        if (t > 29) {
            //updated more than 29 days ago, lets update from the net
            opts.update = true;
        }
        ip2asn.load(opts);
    }
});

var arr = ['50.21.180.100',
    '50.22.180.100',
    '1.38.1.1',
    2733834241
]

ip2asn.on('ready', function() {
    arr.forEach(function(ip) {
        console.log(ip2asn.lookup(ip));
    })
});

optionally you can load the data from another csv file instead of the default one by var ip2asn = require('./index.js')('path-to-my-file.csv');

another option is to give a different url for updating the default file in the options. this url must point to a zip file containing a GeoIPASNum2.csv file

var opts = {};
opts.update = true;
opts.url = 'http://wherever.you.want.zip'

About

nodejs module for getting asn for a given ip

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published