|
|
@ -2,16 +2,26 @@ const { spawn } = require("child_process");
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = async function getISP(ip_address) {
|
|
|
|
module.exports = async function getISP(ip_address) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
if (ip_address.startsWith("::ffff:")) {
|
|
|
|
|
|
|
|
ip_address = ip_address.replace("::ffff:", "");
|
|
|
|
|
|
|
|
}
|
|
|
|
const task = spawn("whois", [ip_address]);
|
|
|
|
const task = spawn("whois", [ip_address]);
|
|
|
|
let data = "";
|
|
|
|
let data = "";
|
|
|
|
task.stdout.on("data", (d) => {
|
|
|
|
task.stdout.on("data", (d) => {
|
|
|
|
data += d.toString();
|
|
|
|
data += d.toString();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
task.on("close", () => {
|
|
|
|
task.on("close", () => {
|
|
|
|
|
|
|
|
console.log(data);
|
|
|
|
resolve(
|
|
|
|
resolve(
|
|
|
|
data
|
|
|
|
data
|
|
|
|
.split("\n")
|
|
|
|
.split("\n")
|
|
|
|
.filter((l) => l.includes("role:"))
|
|
|
|
.filter(
|
|
|
|
|
|
|
|
(l) =>
|
|
|
|
|
|
|
|
l.includes("role:") ||
|
|
|
|
|
|
|
|
l.includes("org-name:") ||
|
|
|
|
|
|
|
|
l.includes("country")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.map((l) => l.replace("role:", ""))
|
|
|
|
.join("|")
|
|
|
|
.join("|")
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|