464740 DosFilter whiteList check improvement

This commit is contained in:
Greg Wilkins 2015-04-22 13:19:00 +10:00
parent f73f2c22e3
commit e97c726ccf
1 changed files with 20 additions and 1 deletions

View File

@ -578,7 +578,7 @@ public class DoSFilter implements Filter
if (tracker == null)
{
boolean allowed = checkWhitelist(_whitelist, request.getRemoteAddr());
boolean allowed = checkWhitelist(request.getRemoteAddr());
int maxRequestsPerSec = getMaxRequestsPerSec();
tracker = allowed ? new FixedRateTracker(loadId, type, maxRequestsPerSec)
: new RateTracker(loadId, type, maxRequestsPerSec);
@ -601,6 +601,25 @@ public class DoSFilter implements Filter
return tracker;
}
protected boolean checkWhitelist(String candidate)
{
for (String address : _whitelist)
{
if (address.contains("/"))
{
if (subnetMatch(address, candidate))
return true;
}
else
{
if (address.equals(candidate))
return true;
}
}
return false;
}
@Deprecated
protected boolean checkWhitelist(List<String> whitelist, String candidate)
{
for (String address : whitelist)