3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +01:00

Merge pull request #323 from zuzak/dns

DNS functionality
This commit is contained in:
reality 2013-03-22 03:45:28 -07:00
commit a5f2c35b4d
3 changed files with 73 additions and 0 deletions

17
modules/dns/README.md Normal file
View File

@ -0,0 +1,17 @@
## DNS
Performs and reports upon basic DNS functions.
### Description
This module utilises the domain name system to discover basic information about
domain names and IP addresses.
### Commands
#### ~lookup [domain name]
Looks up the specified domain name in the domain name system. If a match is found,
the first corresponding A or AAAA record is displayed.
#### ~rdns [IP address]
Looks up the specified IP address in the domain name system. If a match is found,
the first corresponding rDNS domain name is displayed.

42
modules/dns/dns.js Normal file
View File

@ -0,0 +1,42 @@
/**
* Module Name: DNS
* Description: Performs and reports on basic DNS functions.
*/
var dnsmod = require('dns');
var dns = function(dbot) {
var commands = {
'~lookup': function(event) {
domain = event.params[1];
dnsmod.lookup(domain, function (error, addr) {
if (error) {
console.log(error);
event.reply(dbot.t("lookup-error",{"domain": domain, "code": error.code}));
} else {
event.reply(dbot.t("lookup",{"domain": domain, "address": addr}));
}
});
},
'~rdns': function(event) {
ip = event.params[1];
try {
dnsmod.reverse(ip, function (error, domain) {
if (error) {
throw error;
}
event.reply(dbot.t("rdns",{"domain": domain, "ip": ip}));
});
} catch (err) {
event.reply(dbot.t("rdns-error",{"domain": domain, "ip": ip, "error": err}));
}
}
};
this.commands = commands;
this.on = 'PRIVMSG';
};
exports.fetch = function(dbot) {
return new dns(dbot);
};

14
modules/dns/strings.json Normal file
View File

@ -0,0 +1,14 @@
{
"lookup-error": {
"en": "{domain} is \u000303AVAILABLE! \u000314({code})"
},
"lookup": {
"en": "{domain} is \u000305TAKEN! \u000314({address})"
},
"rdns": {
"en": "{ip} \u2192 {domain}"
},
"rdns-error": {
"en": "Unable to lookup {ip}. \u000314({error})"
}
}