-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Allow to define a (white|allow)-list, which a connector should bridge connection requests to.
Draft:
const { BlockList } = require("net");
const dns = require("dns");
const { readFileSync } = require("fs");
const allowlist = new BlockList();
const ALLOWS = JSON.parse(readFileSync("./allowlist.json"));
ALLOWS.forEach((host) => {
if (host.includes("/")) {
let [net, prefix] = host.split("/");
allowlist.addSubnet(net, parseInt(prefix));
} else {
dns.resolve(host, (err, records) => {
if (err) {
return console.error(err);
}
records.forEach((ip) => {
allowlist.addAddress(ip);
});
});
}
});
setTimeout(async () => {
console.log("Allowlist", allowlist)
const host = "192.168.2.1";
const allow = await new Promise((resolve, reject) => {
if (ALLOWS.includes(host)) {
resolve(true);
} else {
dns.resolve(host, (err, addresses) => {
if (err) {
reject(err);
} else {
if(addresses.length <= 0){
return resolve(false);
}
resolve(allowlist.check(addresses[0]));
}
});
}
});
console.log("Allow:", `${host} = ${allow}`);
}, 100);Metadata
Metadata
Assignees
Labels
No labels