On Wed, Jan 27, 2010 at 1:10 PM, jose vilmar estacio de souza
<vil...@informal.com.br> 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:vil...@informal.com.br Skype:jvilmar
> Twitter: http://www.twitter.com/jvesouza
> Phone: +55 21-2555-2650 Cel: +55 21-8868-0859
>
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Reply via email to