Package io.netty.handler.codec.http2
Class Http2MaxRstFrameLimitEncoder
java.lang.Object
io.netty.handler.codec.http2.DecoratingHttp2FrameWriter
io.netty.handler.codec.http2.DecoratingHttp2ConnectionEncoder
io.netty.handler.codec.http2.Http2MaxRstFrameLimitEncoder
- All Implemented Interfaces:
Http2ConnectionEncoder,Http2DataWriter,Http2FrameWriter,Http2SettingsReceivedConsumer,Closeable,AutoCloseable
DecoratingHttp2ConnectionEncoder which guards against a remote peer that will trigger a massive amount
of RST frames on an existing connection.
This encoder will tear-down the connection once we reached the configured limit to reduce the risk of DDOS.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.handler.codec.http2.Http2FrameWriter
Http2FrameWriter.Configuration -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate Http2LifecycleManagerprivate static final InternalLoggerprivate final intprivate final longprivate int -
Constructor Summary
ConstructorsConstructorDescriptionHttp2MaxRstFrameLimitEncoder(Http2ConnectionEncoder delegate, int maxRstFramesPerWindow, int secondsPerWindow) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancountRstFrameErrorCode(long errorCode) voidlifecycleManager(Http2LifecycleManager lifecycleManager) Sets the lifecycle manager.writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) Writes a RST_STREAM frame to the remote endpoint.Methods inherited from class io.netty.handler.codec.http2.DecoratingHttp2ConnectionEncoder
connection, consumeReceivedSettings, flowController, frameWriter, pollSentSettings, remoteSettingsMethods inherited from class io.netty.handler.codec.http2.DecoratingHttp2FrameWriter
close, configuration, writeData, writeFrame, writeGoAway, writeHeaders, writeHeaders, writePing, writePriority, writePushPromise, writeSettings, writeSettingsAck, writeWindowUpdateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.handler.codec.http2.Http2ConnectionEncoder
writeFrameMethods inherited from interface io.netty.handler.codec.http2.Http2DataWriter
writeDataMethods inherited from interface io.netty.handler.codec.http2.Http2FrameWriter
close, configuration, writeGoAway, writeHeaders, writeHeaders, writePing, writePriority, writePushPromise, writeSettings, writeSettingsAck, writeWindowUpdate
-
Field Details
-
logger
-
nanosPerWindow
private final long nanosPerWindow -
maxRstFramesPerWindow
private final int maxRstFramesPerWindow -
lastRstFrameNano
private long lastRstFrameNano -
sendRstInWindow
private int sendRstInWindow -
lifecycleManager
-
-
Constructor Details
-
Http2MaxRstFrameLimitEncoder
Http2MaxRstFrameLimitEncoder(Http2ConnectionEncoder delegate, int maxRstFramesPerWindow, int secondsPerWindow)
-
-
Method Details
-
lifecycleManager
Description copied from interface:Http2ConnectionEncoderSets the lifecycle manager. Must be called as part of initialization before the encoder is used.- Specified by:
lifecycleManagerin interfaceHttp2ConnectionEncoder- Overrides:
lifecycleManagerin classDecoratingHttp2ConnectionEncoder
-
writeRstStream
public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) Description copied from interface:Http2FrameWriterWrites a RST_STREAM frame to the remote endpoint.- Specified by:
writeRstStreamin interfaceHttp2FrameWriter- Overrides:
writeRstStreamin classDecoratingHttp2FrameWriter- Parameters:
ctx- the context to use for writing.streamId- the stream for which to send the frame.errorCode- the error code indicating the nature of the failure.promise- the promise for the write.- Returns:
- the future for the write.
-
countRstFrameErrorCode
private boolean countRstFrameErrorCode(long errorCode)
-