forked from GitHub/dbot
add basic dns function thingies
This commit is contained in:
parent
4bb9f90398
commit
0bb331f87d
17
modules/dns/README.md
Normal file
17
modules/dns/README.md
Normal 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
42
modules/dns/dns.js
Normal 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
14
modules/dns/strings.json
Normal 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})"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user