Merge remote-tracking branch 'origin/jetty-9.2.x'

This commit is contained in:
Greg Wilkins 2015-04-30 13:52:31 +10:00
commit a593d8eef6
2 changed files with 4 additions and 16 deletions

View File

@ -1038,29 +1038,17 @@ public class DoSFilter implements Filter
/**
* Set a list of IP addresses that will not be rate limited.
*
* @param value comma-separated whitelist
* @param commaSeparatedList comma-separated whitelist
*/
public void setWhitelist(String value)
public void setWhitelist(String commaSeparatedList)
{
List<String> result = new ArrayList<>();
for (String address : value.split(","))
for (String address : commaSeparatedList.split(","))
addWhitelistAddress(result, address);
clearWhitelist();
_whitelist.addAll(result);
LOG.debug("Whitelisted IP addresses: {}", result);
}
/**
* Set a list of IP addresses that will not be rate limited.
*
* @param values whitelist
*/
public void setWhitelist(List<String> values)
{
clearWhitelist();
_whitelist.addAll(values);
LOG.debug("Whitelisted IP addresses: {}", values);
}
/**
* Clears the list of whitelisted IP addresses

View File

@ -83,7 +83,7 @@ public class DoSFilterTest extends AbstractDoSFilterTest
whitelist.add("10.0.0.0/8");
whitelist.add("4d8:0:a:1234:ABc:1F:b18:17");
whitelist.add("4d8:0:a:1234:ABc:1F:0:0/96");
filter.setWhitelist(whitelist);
filter.setWhitelist("192.168.0.1/32,10.0.0.0/8,4d8:0:a:1234:ABc:1F:b18:17,4d8:0:a:1234:ABc:1F:0:0/96");
Assert.assertTrue(filter.checkWhitelist("192.168.0.1"));
Assert.assertFalse(filter.checkWhitelist("192.168.0.2"));
Assert.assertFalse(filter.checkWhitelist("11.12.13.14"));