Set forbidden status code on domain block
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
2
index.js
2
index.js
@@ -26,10 +26,12 @@ http.createServer((req, response) => {
|
|||||||
|
|
||||||
if(blockList.some(b => remoteURL.hostname == b || remoteURL.hostname.endsWith("." + b))) {
|
if(blockList.some(b => remoteURL.hostname == b || remoteURL.hostname.endsWith("." + b))) {
|
||||||
console.log("Domain is in blocklist")
|
console.log("Domain is in blocklist")
|
||||||
|
response.writeHead(403);
|
||||||
return response.end();
|
return response.end();
|
||||||
}
|
}
|
||||||
if(allowList.length > 0 && !allowList.some(b => remoteURL.hostname == b || remoteURL.hostname.endsWith("." + b))) {
|
if(allowList.length > 0 && !allowList.some(b => remoteURL.hostname == b || remoteURL.hostname.endsWith("." + b))) {
|
||||||
console.log("Domain is not in allowlist")
|
console.log("Domain is not in allowlist")
|
||||||
|
response.writeHead(403);
|
||||||
return response.end();
|
return response.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user