public class ThreadLimitHandler extends HandlerWrapper
Handler to limit the threads per IP address for DOS protection
The ThreadLimitHandler applies a limit to the number of Threads that can be used simultaneously per remote IP address.
The handler makes a determination of the remote IP separately to
any that may be made by the ForwardedRequestCustomizer or similar:
This is a simpler alternative to DosFilter
AbstractHandler.ErrorDispatchHandler_handler| Constructor and Description |
|---|
ThreadLimitHandler() |
ThreadLimitHandler(java.lang.String forwardedHeader) |
ThreadLimitHandler(java.lang.String forwardedHeader,
boolean rfc7239) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart() |
void |
exclude(java.lang.String inetAddressPattern) |
protected org.eclipse.jetty.server.handler.ThreadLimitHandler.Remote |
getRemote(Request baseRequest) |
protected java.lang.String |
getRemoteIP(Request baseRequest) |
int |
getThreadLimit() |
protected int |
getThreadLimit(java.lang.String ip) |
void |
handle(java.lang.String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
Handle a request.
|
void |
include(java.lang.String inetAddressPattern) |
boolean |
isEnabled() |
void |
setEnabled(boolean enabled) |
void |
setThreadLimit(int threadLimit) |
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerexpandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerdoError, doStop, dumpThis, getServerpublic ThreadLimitHandler()
public ThreadLimitHandler(java.lang.String forwardedHeader)
public ThreadLimitHandler(java.lang.String forwardedHeader,
boolean rfc7239)
protected void doStart()
throws java.lang.Exception
doStart in class AbstractHandlerjava.lang.Exceptionpublic boolean isEnabled()
public void setEnabled(boolean enabled)
public int getThreadLimit()
public void setThreadLimit(int threadLimit)
public void include(java.lang.String inetAddressPattern)
public void exclude(java.lang.String inetAddressPattern)
public void handle(java.lang.String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
throws java.io.IOException,
ServletException
Handlerhandle in interface Handlerhandle in class HandlerWrappertarget - The target of the request - either a URI or a name.baseRequest - The original unwrapped request object.request - The request either as the Request object or a wrapper of that request. The
HttpConnection.getCurrentConnection().getHttpChannel().getRequest()
method can be used access the Request object if required.response - The response as the Response object or a wrapper of that request. The
HttpConnection.getCurrentConnection().getHttpChannel().getResponse()
method can be used access the Response object if required.java.io.IOException - if unable to handle the request or response processingServletException - if unable to handle the request or response due to underlying servlet issueprotected int getThreadLimit(java.lang.String ip)
protected org.eclipse.jetty.server.handler.ThreadLimitHandler.Remote getRemote(Request baseRequest)
protected java.lang.String getRemoteIP(Request baseRequest)