Skip to content
Snippets Groups Projects
Commit a64bc870 authored by Gunananthaa K B's avatar Gunananthaa K B
Browse files

basic filtering done

parent 7fc1ca73
No related branches found
No related tags found
No related merge requests found
const http = require('http');
const PORT = 8080;
const filter = request=>{
if(request.url==='/good'){
return true;
}
return false;
}
const requestListener = (req,res)=>{
const options = {
hostname:'localhost',
port:3000,
path:'/'
};
if(filter(req)){
const get = http.get(options,response=>{
console.log(`statusCode: ${response.statusCode}`);
let buffer="";
......@@ -17,11 +26,96 @@ const requestListener = (req,res)=>{
res.writeHead(200);
res.end(buffer);
});
})
});
}
else{
res.setHeader("Content-Type", "text/html");
res.writeHead(403);
res.end(rejectionDisplay);
}
// res.writeHead(200);
console.log(req.headers);
console.log(req.url);
// res.end("hello");
}
const server = http.createServer(requestListener);
server.listen(PORT);
const rejectionDisplay = `
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<meta name="id" content="siteBlocked">
<title>Web Site Blocked</title>
<style type="text/css">
#shd { width:500px;position:relative;right:3px;top:3px;margin-right:3px;margin-bottom:3px;text-align:center; }
#shd .second,
#shd .third,
#shd .box { position:relative;left:-1px;top:-1px; }
#shd .first { background: #f1f0f1; }
#shd .second { background: #dbdadb; }
#shd .third { background: #b8b6b8; }
#shd .box { background:#ffffff;border:1px solid #848284;height:350px; }
.strip { width:100%;height:70px; }
.warn {
background-color:#f0d44d;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fae379', endColorstr='#eed145');
background:-webkit-gradient(linear, left top, left bottom, from(#fae379), to(#eed145));
background:-moz-linear-gradient(top, #fae379, #eed145);
font-size:14px;
font-weight:bold;
}
#nsa_banner { position:relative;top:20px;left:20px;float:left; }
#alert_icon { position:relative;top:15px;left:20px;float:left; }
#alert_text { float:left;position:relative;top:25px;left:40px;width:400px; }
</style>
<script type="text/JavaScript">
var isIE7=false;
function onLoadFunc()
{
var s = document.URL;
s = s.replace(/</g, "&lt;").replace(/>/g, "&gt;");
if (s.length < 50) { s='URL: <b>'+s+'</b>'; }
else { s='URL: <b>'+s.substring(0,50)+'</b>...'; }
var o=document.getElementById("urlp");
if (o) { o.innerHTML=s; }
if (isIE7==true) {
var base="http://172.17.100.100/";
if (base.indexOf("fw_interface")>=0) {
base="";
}
o=document.getElementById("nsa_banner");
if (o) { o.src=base+"nsa_banner.gif"; }
o=document.getElementById("alert_icon");
if (o) { o.src=base+"alert_icon.gif"; }
}
}
</script>
</head>
<body onload="onLoadFunc();">
<div style="width:100%;height:100px;"></div>
<center>
<div id="shd"><div class="first"><div class="second"><div class="third">
<div class="box">
<div class="strip">
<div id="alert_text">
This site has been blocked by the network administrator.
</div>
</div>
<div>
<p id="urlp">
</p>
<p>
Block reason: <b>Advanced Computer Network's Firewall</b>
</p>
<p>
This is an intentionally block based on web proxy server's filter. The only allowed endpoint as per the currnet rule is '/good'
</p>
</div>
</div>
</div></div></div></div>
</center>
</body>
</html>
`;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment