8
index.js
8
index.js
@@ -25,12 +25,12 @@ http.createServer((req, response) => {
|
||||
if(!remoteURL.hostname || remoteURL.hostname === 'localhost') return response.end();
|
||||
|
||||
if(blockList.some(b => remoteURL.hostname == b || remoteURL.hostname.endsWith("." + b))) {
|
||||
console.log("Domain is in blocklist")
|
||||
console.log(`Domain '${remoteURL.hostname}' is in blocklist`)
|
||||
response.writeHead(403);
|
||||
return response.end();
|
||||
}
|
||||
if(allowList.length > 0 && !allowList.some(b => remoteURL.hostname == b || remoteURL.hostname.endsWith("." + b))) {
|
||||
console.log("Domain is not in allowlist")
|
||||
console.log(`Domain '${remoteURL.hostname}' is not in allowlist`)
|
||||
response.writeHead(403);
|
||||
return response.end();
|
||||
}
|
||||
@@ -87,8 +87,8 @@ function loadWebpage(req, res) {
|
||||
res.writeHead(200);
|
||||
res.end(
|
||||
contents
|
||||
.replaceAll('[[BLOCKLIST]]', JSON.stringify(blockList))
|
||||
.replaceAll('[[ALLOWLIST]]', JSON.stringify(allowList))
|
||||
.replaceAll('[[BLOCKLIST]]', JSON.stringify(blockList))
|
||||
.replaceAll('[[ALLOWLIST]]', JSON.stringify(allowList))
|
||||
);
|
||||
})
|
||||
.catch(err => {
|
||||
|
Reference in New Issue
Block a user