diff --git a/modules/dns/README.md b/modules/dns/README.md new file mode 100644 index 0000000..f730352 --- /dev/null +++ b/modules/dns/README.md @@ -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. diff --git a/modules/dns/dns.js b/modules/dns/dns.js new file mode 100644 index 0000000..83d5d9f --- /dev/null +++ b/modules/dns/dns.js @@ -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); +}; diff --git a/modules/dns/strings.json b/modules/dns/strings.json new file mode 100644 index 0000000..f8c69bc --- /dev/null +++ b/modules/dns/strings.json @@ -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})" + } +}