Skip to content

Instantly share code, notes, and snippets.

@ianbishop
Created January 24, 2014 17:33
Show Gist options
  • Save ianbishop/8602106 to your computer and use it in GitHub Desktop.
Save ianbishop/8602106 to your computer and use it in GitHub Desktop.
var counts = {};
var total = 0;
function freqIP(ip) {
var count = counts[ip];
if (count == undefined)
count = 1;
else
count++;
total++;
if (total > 10) {
total = 0;
counts = {};
return ((count / 10.0) >= 0.10);
}
return false;
}
var blacklist = {};
function currentlyBlacklisted(ip) {
if (blacklist[ip]) return true;
blacklist[ip] = freqIP(ip);
return blacklist[ip];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment