-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
38 lines (35 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var util = require("util"),
whois = require("whois-raw"),
parseRawData = require("./parse-raw-data.js");
var lookup = util.promisify(whois.lookup);
module.exports = {
lookup: async function (domain, options = {}) {
// Where possible don't follow the detailed results to improve efficiency
if (options && !options.hasOwnProperty("follow")) {
if (
domain.endsWith(".org") ||
domain.endsWith(".net") ||
domain.endsWith(".com")
) {
options["follow"] = 0;
}
}
//console.log("looking up whois for " + domain);
var result = {};
try {
var rawData = await lookup(domain, options || {});
if (typeof rawData === "object") {
result = rawData.map(function (data) {
data.data = parseRawData(data.data, domain);
return data;
});
} else {
result = { ...result, ...parseRawData(rawData, domain) };
}
return result;
} catch (err) {
//console.log(err);
throw err;
}
},
};