Created
July 8, 2012 15:55
-
-
Save eugenehp/3071433 to your computer and use it in GitHub Desktop.
ARIN 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
var net = require('net'); | |
var ARIN = function(ip,keyword,callback){ | |
var arin = { | |
port: 43, | |
host: 'whois.arin.net' | |
}; | |
var client = net.connect(arin.port,arin.host); | |
client.on('connect',function(){ | |
console.log('Connected to whois.arin.net on port 43'); | |
client.write('n '+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 = ARIN; |
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 ARIN = require('./lib/arin'); | |
ARIN('213.46.228.196','amsterdam',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