public class BlacklistFilter extends IoFilterAdapter
IoFilter which blocks connections from blacklisted remote
address.IoFilter.NextFilter| Modifier and Type | Field and Description |
|---|---|
private java.util.List<Subnet> |
blacklist
The list of blocked addresses
|
private static org.slf4j.Logger |
LOGGER |
| Constructor and Description |
|---|
BlacklistFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
block(java.net.InetAddress address)
Blocks the specified endpoint.
|
void |
block(Subnet subnet)
Blocks the specified subnet.
|
private void |
blockSession(IoSession session) |
private boolean |
isBlocked(IoSession session) |
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
java.lang.Object message)
Filters
IoHandler.messageReceived(IoSession,Object) event. |
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoHandler.messageSent(IoSession,Object) event. |
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionClosed(IoSession) event. |
void |
sessionCreated(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionCreated(IoSession) event. |
void |
sessionIdle(IoFilter.NextFilter nextFilter,
IoSession session,
IdleStatus status)
Filters
IoHandler.sessionIdle(IoSession,IdleStatus) event. |
void |
sessionOpened(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionOpened(IoSession) event. |
void |
setBlacklist(java.net.InetAddress[] addresses)
Sets the addresses to be blacklisted.
|
void |
setBlacklist(java.lang.Iterable<java.net.InetAddress> addresses)
Sets the addresses to be blacklisted.
|
void |
setSubnetBlacklist(java.lang.Iterable<Subnet> subnets)
Sets the subnets to be blacklisted.
|
void |
setSubnetBlacklist(Subnet[] subnets)
Sets the subnets to be blacklisted.
|
void |
unblock(java.net.InetAddress address)
Unblocks the specified endpoint.
|
void |
unblock(Subnet subnet)
Unblocks the specified subnet.
|
destroy, exceptionCaught, filterClose, filterWrite, init, inputClosed, onPostAdd, onPostRemove, onPreAdd, onPreRemove, toStringprivate final java.util.List<Subnet> blacklist
private static final org.slf4j.Logger LOGGER
public void setBlacklist(java.net.InetAddress[] addresses)
addresses - an array of addresses to be blacklisted.public void setSubnetBlacklist(Subnet[] subnets)
subnets - an array of subnets to be blacklisted.public void setBlacklist(java.lang.Iterable<java.net.InetAddress> addresses)
addresses - a collection of InetAddress objects representing the
addresses to be blacklisted.java.lang.IllegalArgumentException - if the specified collections contains
non-InetAddress objects.public void setSubnetBlacklist(java.lang.Iterable<Subnet> subnets)
subnets - an array of subnets to be blacklisted.public void block(java.net.InetAddress address)
public void block(Subnet subnet)
public void unblock(java.net.InetAddress address)
public void unblock(Subnet subnet)
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
IoFilterAdapterIoHandler.sessionCreated(IoSession) event.sessionCreated in interface IoFiltersessionCreated in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventpublic void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoFilterAdapterIoHandler.sessionOpened(IoSession) event.sessionOpened in interface IoFiltersessionOpened in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventjava.lang.Exceptionpublic void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoFilterAdapterIoHandler.sessionClosed(IoSession) event.sessionClosed in interface IoFiltersessionClosed in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventjava.lang.Exceptionpublic void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws java.lang.Exception
IoFilterAdapterIoHandler.sessionIdle(IoSession,IdleStatus) event.sessionIdle in interface IoFiltersessionIdle in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventstatus - The IdleStatus typejava.lang.Exceptionpublic void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Object message)
IoFilterAdapterIoHandler.messageReceived(IoSession,Object) event.messageReceived in interface IoFiltermessageReceived in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventmessage - The received messagepublic void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws java.lang.Exception
IoFilterAdapterIoHandler.messageSent(IoSession,Object) event.messageSent in interface IoFiltermessageSent in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventwriteRequest - The WriteRequest that contains the sent messagejava.lang.Exceptionprivate void blockSession(IoSession session)
private boolean isBlocked(IoSession session)