Created
July 8, 2012 17:17
-
-
Save eugenehp/3071852 to your computer and use it in GitHub Desktop.
RIPE check library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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