Package io.netty.handler.codec.http2
Class Http2ControlFrameLimitEncoder
- java.lang.Object
-
- io.netty.handler.codec.http2.DecoratingHttp2FrameWriter
-
- io.netty.handler.codec.http2.DecoratingHttp2ConnectionEncoder
-
- io.netty.handler.codec.http2.Http2ControlFrameLimitEncoder
-
- All Implemented Interfaces:
Http2ConnectionEncoder
,Http2DataWriter
,Http2FrameWriter
,Http2SettingsReceivedConsumer
,java.io.Closeable
,java.lang.AutoCloseable
final class Http2ControlFrameLimitEncoder extends DecoratingHttp2ConnectionEncoder
DecoratingHttp2ConnectionEncoder
which guards against a remote peer that will trigger a massive amount of control frames but will not consume our responses to these. 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
Fields Modifier and Type Field Description private Http2LifecycleManager
lifecycleManager
private boolean
limitReached
private static InternalLogger
logger
private int
maxOutstandingControlFrames
private int
outstandingControlFrames
private ChannelFutureListener
outstandingControlFramesListener
-
Constructor Summary
Constructors Constructor Description Http2ControlFrameLimitEncoder(Http2ConnectionEncoder delegate, int maxOutstandingControlFrames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ChannelPromise
handleOutstandingControlFrames(ChannelHandlerContext ctx, ChannelPromise promise)
void
lifecycleManager(Http2LifecycleManager lifecycleManager)
Sets the lifecycle manager.ChannelFuture
writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise)
Writes a PING frame to the remote endpoint.ChannelFuture
writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)
Writes a RST_STREAM frame to the remote endpoint.ChannelFuture
writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise)
Writes a SETTINGS acknowledgment to the remote endpoint.-
Methods inherited from class io.netty.handler.codec.http2.DecoratingHttp2ConnectionEncoder
connection, consumeReceivedSettings, flowController, frameWriter, pollSentSettings, remoteSettings
-
Methods inherited from class io.netty.handler.codec.http2.DecoratingHttp2FrameWriter
close, configuration, writeData, writeFrame, writeGoAway, writeHeaders, writeHeaders, writePriority, writePushPromise, writeSettings, writeWindowUpdate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.handler.codec.http2.Http2ConnectionEncoder
writeFrame
-
Methods inherited from interface io.netty.handler.codec.http2.Http2DataWriter
writeData
-
Methods inherited from interface io.netty.handler.codec.http2.Http2FrameWriter
close, configuration, writeGoAway, writeHeaders, writeHeaders, writePriority, writePushPromise, writeSettings, writeWindowUpdate
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
maxOutstandingControlFrames
private final int maxOutstandingControlFrames
-
outstandingControlFramesListener
private final ChannelFutureListener outstandingControlFramesListener
-
lifecycleManager
private Http2LifecycleManager lifecycleManager
-
outstandingControlFrames
private int outstandingControlFrames
-
limitReached
private boolean limitReached
-
-
Constructor Detail
-
Http2ControlFrameLimitEncoder
Http2ControlFrameLimitEncoder(Http2ConnectionEncoder delegate, int maxOutstandingControlFrames)
-
-
Method Detail
-
lifecycleManager
public void lifecycleManager(Http2LifecycleManager lifecycleManager)
Description copied from interface:Http2ConnectionEncoder
Sets the lifecycle manager. Must be called as part of initialization before the encoder is used.- Specified by:
lifecycleManager
in interfaceHttp2ConnectionEncoder
- Overrides:
lifecycleManager
in classDecoratingHttp2ConnectionEncoder
-
writeSettingsAck
public ChannelFuture writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise)
Description copied from interface:Http2FrameWriter
Writes a SETTINGS acknowledgment to the remote endpoint.- Specified by:
writeSettingsAck
in interfaceHttp2FrameWriter
- Overrides:
writeSettingsAck
in classDecoratingHttp2FrameWriter
- Parameters:
ctx
- the context to use for writing.promise
- the promise for the write.- Returns:
- the future for the write.
-
writePing
public ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise)
Description copied from interface:Http2FrameWriter
Writes a PING frame to the remote endpoint.- Specified by:
writePing
in interfaceHttp2FrameWriter
- Overrides:
writePing
in classDecoratingHttp2FrameWriter
- Parameters:
ctx
- the context to use for writing.ack
- indicates whether this is an ack of a PING frame previously received from the remote endpoint.data
- the payload of the frame.promise
- the promise for the write.- Returns:
- the future for the write.
-
writeRstStream
public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)
Description copied from interface:Http2FrameWriter
Writes a RST_STREAM frame to the remote endpoint.- Specified by:
writeRstStream
in interfaceHttp2FrameWriter
- Overrides:
writeRstStream
in 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.
-
handleOutstandingControlFrames
private ChannelPromise handleOutstandingControlFrames(ChannelHandlerContext ctx, ChannelPromise promise)
-
-