Package org.jivesoftware.openfire.nio
Class NewConnectionRateLimitHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.jivesoftware.openfire.nio.NewConnectionRateLimitHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
@Sharable
public class NewConnectionRateLimitHandler
extends io.netty.channel.ChannelInboundHandlerAdapter
A Netty pipeline handler that enforces a rate limit on newly accepted inbound connections.
For maximum efficiency, this handler should be placed at the head of the server-side child channel pipeline (via
addFirst) so that it intercepts channelActive before any other handler runs. When a new connection
arrives and the rate limit is exhausted, the channel is closed immediately and the event is not propagated further,
preventing all downstream handlers from performing any work (TLS negotiation, XML parser allocation,
session scaffolding, etc.) for the rejected connection.
Rate limits are looked up per ConnectionType from NewConnectionLimiterRegistry, which maintains one
TokenBucketRateLimiter per logical connection category (e.g. C2S, S2S). Connection types that do not have an
active limit configured will receive an unlimited limiter and are always passed through.
This handler is ChannelHandler.Sharable because it holds no per-channel state.
A single instance may be shared across all child channels created by the same server socket acceptor.- Author:
- Guus der Kinderen, guus@goodbytes.nl
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
NewConnectionRateLimitHandler
-
-
Method Details
-
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-