Class UniqueIpFilter

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler

@Sharable public class UniqueIpFilter extends AbstractRemoteAddressFilter<java.net.InetSocketAddress>
This class allows one to ensure that at all times for every IP address there is at most one Channel connected to the server.
  • Field Details

    • connected

      private final java.util.Set<java.net.InetAddress> connected
  • Constructor Details

    • UniqueIpFilter

      public UniqueIpFilter()
  • Method Details

    • accept

      protected boolean accept(ChannelHandlerContext ctx, java.net.InetSocketAddress remoteAddress) throws java.lang.Exception
      Description copied from class: AbstractRemoteAddressFilter
      This method is called immediately after a Channel gets registered.
      Specified by:
      accept in class AbstractRemoteAddressFilter<java.net.InetSocketAddress>
      Returns:
      Return true if connections from this IP address and port should be accepted. False otherwise.
      Throws:
      java.lang.Exception