View Javadoc
1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.ipfilter;
17  
18  import java.net.InetSocketAddress;
19  
20  import org.jboss.netty.channel.ChannelEvent;
21  import org.jboss.netty.channel.ChannelFuture;
22  import org.jboss.netty.channel.ChannelHandlerContext;
23  
24  /**
25   * The listener interface for receiving ipFilter events.
26   *
27   * @see IpFilteringHandler
28   */
29  public interface IpFilterListener {
30  
31      /**
32       * Called when the channel has the CONNECTED status and the channel was allowed by a previous call to accept().
33       * This method enables your implementation to send a message back to the client before closing
34       * or whatever you need. This method returns a ChannelFuture on which the implementation
35       * can wait uninterruptibly before continuing.<br>
36       * For instance, If a message is sent back, the corresponding ChannelFuture has to be returned.
37       *
38       * @param inetSocketAddress the remote {@link InetSocketAddress} from client
39       * @return the associated ChannelFuture to be waited for before closing the channel. Null is allowed.
40       */
41      ChannelFuture allowed(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress);
42  
43      /**
44       * Called when the channel has the CONNECTED status and the channel was refused by a previous call to accept().
45       * This method enables your implementation to send a message back to the client before closing
46       * or whatever you need. This method returns a ChannelFuture on which the implementation
47       * will wait uninterruptibly before closing the channel.<br>
48       * For instance, If a message is sent back, the corresponding ChannelFuture has to be returned.
49       *
50       * @param inetSocketAddress the remote {@link InetSocketAddress} from client
51       * @return the associated ChannelFuture to be waited for before closing the channel. Null is allowed.
52       */
53      ChannelFuture refused(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress);
54  
55      /**
56       * Called in handleUpstream, if this channel was previously blocked,
57       * to check if whatever the event, it should be passed to the next entry in the pipeline.<br>
58       * If one wants to not block events, just overridden this method by returning always true.<br><br>
59       * <b>Note that OPENED and BOUND events are still passed to the next entry in the pipeline since
60       * those events come out before the CONNECTED event and so the possibility to filter the connection.</b>
61       *
62       * @return True if the event should continue, False if the event should not continue
63       *         since this channel was blocked by this filter
64       */
65      boolean continues(ChannelHandlerContext ctx, ChannelEvent e);
66  
67  }