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
AbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.Listener_handlerFAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING| Constructor and Description |
|---|
ThreadLimitHandler() |
ThreadLimitHandler(String forwardedHeader) |
ThreadLimitHandler(String forwardedHeader,
boolean rfc7239) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart() |
void |
exclude(String inetAddressPattern) |
protected org.eclipse.jetty.server.handler.ThreadLimitHandler.Remote |
getRemote(Request baseRequest) |
protected String |
getRemoteIP(Request baseRequest) |
int |
getThreadLimit() |
protected int |
getThreadLimit(String ip) |
void |
handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
Handle a request.
|
void |
include(String inetAddressPattern) |
boolean |
isEnabled() |
void |
setEnabled(boolean enabled) |
void |
setThreadLimit(int threadLimit) |
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerexpandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerdoStop, dumpThis, getServeraddBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopprotected void doStart()
throws Exception
doStart in class AbstractHandlerException@ManagedAttribute(value="true if this handler is enabled") public boolean isEnabled()
public void setEnabled(boolean enabled)
@ManagedAttribute(value="The maximum threads that can be dispatched per remote IP") public int getThreadLimit()
public void setThreadLimit(int threadLimit)
@ManagedOperation(value="Include IP in thread limits") public void include(String inetAddressPattern)
@ManagedOperation(value="Exclude IP from thread limits") public void exclude(String inetAddressPattern)
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws 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.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(String ip)
protected org.eclipse.jetty.server.handler.ThreadLimitHandler.Remote getRemote(Request baseRequest)
Copyright © 1995–2017 Webtide. All rights reserved.