Class IpFilteringHandlerImpl

    • Constructor Detail

      • IpFilteringHandlerImpl

        public IpFilteringHandlerImpl()
    • Method Detail

      • accept

        protected abstract boolean accept​(ChannelHandlerContext ctx,
                                          ChannelEvent e,
                                          java.net.InetSocketAddress inetSocketAddress)
                                   throws java.lang.Exception
        Called when the channel is connected. It returns True if the corresponding connection is to be allowed. Else it returns False.
        Parameters:
        inetSocketAddress - the remote InetSocketAddress from client
        Returns:
        True if the corresponding connection is allowed, else False.
        Throws:
        java.lang.Exception
      • handleRefusedChannel

        protected ChannelFuture handleRefusedChannel​(ChannelHandlerContext ctx,
                                                     ChannelEvent e,
                                                     java.net.InetSocketAddress inetSocketAddress)
                                              throws java.lang.Exception
        Called when the channel has the CONNECTED status and the channel was refused by a previous call to accept(). This method enables your implementation to send a message back to the client before closing or whatever you need. This method returns a ChannelFuture on which the implementation will wait uninterruptibly before closing the channel.
        For instance, If a message is sent back, the corresponding ChannelFuture has to be returned.
        Parameters:
        inetSocketAddress - the remote InetSocketAddress from client
        Returns:
        the associated ChannelFuture to be waited for before closing the channel. Null is allowed.
        Throws:
        java.lang.Exception
      • isBlocked

        protected boolean isBlocked​(ChannelHandlerContext ctx)
        Internal method to test if the current channel is blocked. Should not be overridden.
        Returns:
        True if the current channel is blocked, else False
      • continues

        protected boolean continues​(ChannelHandlerContext ctx,
                                    ChannelEvent e)
                             throws java.lang.Exception
        Called in handleUpstream, if this channel was previously blocked, to check if whatever the event, it should be passed to the next entry in the pipeline.
        If one wants to not block events, just overridden this method by returning always true.

        Note that OPENED and BOUND events are still passed to the next entry in the pipeline since those events come out before the CONNECTED event and so the possibility to filter the connection.
        Returns:
        True if the event should continue, False if the event should not continue since this channel was blocked by this filter
        Throws:
        java.lang.Exception