One more question please.
Looking at class BlackListFilter I saw that the locking mechanism was implemented in all routines, sessionCreated, sessionOpened, sessionClosed, sessionIdle, messageReceived and messageSent.

I think that would be sufficient to implement in the method sessionCreated. Is it true or am I missing something?
Thanks.

[]S José Vilmar Estácio de Souza
http://www.informal.com.br
Msn:[email protected] Skype:jvilmar
Twitter: http://www.twitter.com/jvesouza
Phone: +55 21-2555-2650 Cel: +55 21-8868-0859


On 01/27/2010 05:44 AM, Ashish wrote:
On Wed, Jan 27, 2010 at 1:10 PM, jose vilmar estacio de souza
<[email protected]>  wrote:
Hi all,
If I understand correctly, the class BlacklistFilter block addresses that
are present in a table and reject address that are not present.
What I need is a filter that does just the opposite. Accept thee addresses
present in the table and reject the addresses not present.
Is there anything available?
Thanks.
Its simple, just check for the opposite condition in the current
blacklist filter.
Please note that current filter uses a List for this, you can optimize
it to use a ConcurrentHashMap for faster lookup's

Something like

private boolean isBlocked(IoSession session) {
         SocketAddress remoteAddress = session.getRemoteAddress();
         if (remoteAddress instanceof InetSocketAddress) {
             InetAddress address = ((InetSocketAddress)
remoteAddress).getAddress();

             // check all subnets
             for(Subnet subnet : blacklist) {
                 if(!subnet.inSubnet(address)) {
                     return true;
                 }
             }
         }

         return false;
     }

This is just over the head, please check other conditions carefully :-)

[]S José Vilmar Estácio de Souza
http://www.informal.com.br
Msn:[email protected] Skype:jvilmar
Twitter: http://www.twitter.com/jvesouza
Phone: +55 21-2555-2650 Cel: +55 21-8868-0859




Reply via email to