You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const { spawn } = require("child_process");
|
|
|
|
|
|
|
|
module.exports = async function getISP(ip_address) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (ip_address.startsWith("::ffff:")) {
|
|
|
|
ip_address = ip_address.replace("::ffff:", "");
|
|
|
|
}
|
|
|
|
const task = spawn("whois", [ip_address]);
|
|
|
|
let data = "";
|
|
|
|
task.stdout.on("data", (d) => {
|
|
|
|
data += d.toString();
|
|
|
|
});
|
|
|
|
task.on("close", () => {
|
|
|
|
resolve(
|
|
|
|
data
|
|
|
|
.split("\n")
|
|
|
|
.filter(
|
|
|
|
(l) =>
|
|
|
|
l.includes("role:") ||
|
|
|
|
l.includes("org-name:") ||
|
|
|
|
l.includes("country")
|
|
|
|
)
|
|
|
|
.map((l) => l.replace("role:", ""))
|
|
|
|
.join("|")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
task.on("error", () => reject());
|
|
|
|
});
|
|
|
|
};
|