@@ -65,12 +65,12 @@ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
6565 this .rateLimitMap .clear ();
6666 }
6767
68- private void onRakTick () {
68+ protected void onRakTick () {
6969 this .rateLimitMap .clear ();
7070 this .globalCounter .set (0 );
7171 }
7272
73- private void onBlockedTick () {
73+ protected void onBlockedTick () {
7474 long currTime = System .currentTimeMillis ();
7575
7676 RakServerMetrics metrics = this .channel .config ().getMetrics ();
@@ -126,6 +126,14 @@ public void removeException(InetAddress address) {
126126 this .exceptions .remove (address );
127127 }
128128
129+ public Collection <InetAddress > getExceptions () {
130+ return Collections .unmodifiableCollection (this .exceptions );
131+ }
132+
133+ protected int getAddressMaxPacketCount (InetAddress address ) {
134+ return this .channel .config ().getPacketLimit ();
135+ }
136+
129137 @ Override
130138 protected void channelRead0 (ChannelHandlerContext ctx , DatagramPacket datagram ) throws Exception {
131139 if (this .globalCounter .incrementAndGet () > this .channel .config ().getGlobalPacketLimit ()) {
@@ -141,7 +149,7 @@ protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagram)
141149 }
142150
143151 AtomicInteger counter = this .rateLimitMap .computeIfAbsent (address , a -> new AtomicInteger ());
144- if (counter .incrementAndGet () > this .channel . config (). getPacketLimit ( ) &&
152+ if (counter .incrementAndGet () > this .getAddressMaxPacketCount ( address ) &&
145153 this .blockAddress (address , 10 , TimeUnit .SECONDS )) {
146154 log .warn ("[{}] Blocked because packet limit was reached" , address );
147155 } else {
0 commit comments