2013-03-21 19:29:18 +01:00
|
|
|
/**
|
|
|
|
* Module Name: DNS
|
|
|
|
* Description: Performs and reports on basic DNS functions.
|
|
|
|
*/
|
2015-10-20 20:22:40 +02:00
|
|
|
var dns = require('dns'),
|
2015-02-15 19:26:25 +01:00
|
|
|
request = require('request');
|
2013-03-21 19:29:18 +01:00
|
|
|
|
|
|
|
var dns = function(dbot) {
|
|
|
|
var commands = {
|
|
|
|
'~lookup': function(event) {
|
|
|
|
domain = event.params[1];
|
2015-10-20 20:22:40 +02:00
|
|
|
dns.lookup(domain, function (error, addr) {
|
2013-03-21 19:29:18 +01:00
|
|
|
if (error) {
|
|
|
|
event.reply(dbot.t("lookup-error",{"domain": domain, "code": error.code}));
|
|
|
|
} else {
|
|
|
|
event.reply(dbot.t("lookup",{"domain": domain, "address": addr}));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2013-06-27 20:26:54 +02:00
|
|
|
|
2013-03-21 19:29:18 +01:00
|
|
|
'~rdns': function(event) {
|
|
|
|
ip = event.params[1];
|
2015-10-20 20:22:40 +02:00
|
|
|
dns.reverse(ip, function (error, domain) {
|
2013-03-22 16:39:29 +01:00
|
|
|
if (error) {
|
|
|
|
event.reply(dbot.t("rdns-error",{"domain": domain, "ip": ip, "error": error.code}));
|
|
|
|
} else {
|
2013-03-21 19:29:18 +01:00
|
|
|
event.reply(dbot.t("rdns",{"domain": domain, "ip": ip}));
|
2013-03-22 16:39:29 +01:00
|
|
|
}
|
|
|
|
});
|
2015-02-15 19:26:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
'~geoip': function(event) {
|
|
|
|
var ip = event.params[1];
|
|
|
|
request.get('http://www.telize.com/geoip/'+ip, {
|
|
|
|
'json': true
|
|
|
|
}, function(err, response, body) {
|
|
|
|
if(!err && body && !_.has(body, 'code')) {
|
|
|
|
event.reply(ip + ' is located in '+ body.postal_code + ', ' + body.city + ', ' + body.country + ' and is hosted by ' + body.isp);
|
|
|
|
} else {
|
|
|
|
event.reply('No info about ' + ip);
|
|
|
|
}
|
|
|
|
});
|
2015-10-20 20:22:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
'~dnsbl': function(event) {
|
|
|
|
var revIp = event.message.split('').reverse().join('');
|
|
|
|
dns.lookup(revIp + '.cbl.abuseat.org', function(err, res) {
|
|
|
|
if(!err && res) {
|
|
|
|
event.reply(event.message + ' is listed as an abusive IP.');
|
|
|
|
} else {
|
|
|
|
event.reply(event.message + ' does not seem to be a Naughty Nancy.');
|
|
|
|
}
|
|
|
|
});
|
2013-03-21 19:29:18 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
this.commands = commands;
|
|
|
|
|
|
|
|
this.on = 'PRIVMSG';
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return new dns(dbot);
|
|
|
|
};
|