Skip to content

Instantly share code, notes, and snippets.

@sh1mmer
Created August 31, 2010 03:24
Show Gist options
  • Save sh1mmer/558496 to your computer and use it in GitHub Desktop.
Save sh1mmer/558496 to your computer and use it in GitHub Desktop.
var hardBlockedIps = [];
hardBlockedIps.push({ip: '127.0.0.1', undefined}); // block 127.0.0.1 forever
hardBlockedIps.push({ip: '10.0.0.1', 1283223005549}); // block 10.0.0.1 until time stamp expires
for (var i=0;i<hardBlockedIps.length;i++){
if (req.connection.remoteAddress === hardBlockedIps[i].ip) {
if (hardBlockedIps[i].expires !== undefined && (new Date).getTime() > hardBlockedIps[i].expires) {
console.log("Hard Block on IP " + hardBlockedIps[i].ip + " expired");
break;
} else {
req.connection.end();
res.end();
console.log("Hard Blocked IP " + hardBlockedIps[i].ip);
router.stopPropegation('clientReq');
router.preventDefault('clientReq');
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment