Skip to content

Instantly share code, notes, and snippets.

@eugenehp
Created July 8, 2012 17:17
Show Gist options
  • Save eugenehp/3071852 to your computer and use it in GitHub Desktop.
Save eugenehp/3071852 to your computer and use it in GitHub Desktop.
RIPE check library
//https://apps.db.ripe.net/whois/search.json?query-string=213.46.228.196&source=ripe
var net = require('net');
var RIPE = function(ip,keyword,callback){
var arin = {
port: 43,
host: 'whois.ripe.net'
};
var client = net.connect(arin.port,arin.host);
client.on('connect',function(){
console.log('Connected to '+arin.host+' on port '+arin.port);
client.write(ip+'\n');
});
var response = '';
client.on('data',function(data){
response += new Buffer(data).toString();
});
client.on('end',function(data){
callback(null,response.toLowerCase().indexOf(keyword.toLowerCase())>0)
});
client.on('error',function(error){
callback(error);
})
};
module.exports = RIPE;
var RIPE = require('./lib/ripe');
RIPE('213.46.228.196','UPC',function(err,flag){
console.log('ARIN check is',flag);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment