464740 DosFilter whiteList check improvement
This commit is contained in:
parent
f73f2c22e3
commit
e97c726ccf
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue