/** * Converts an IP address to a subnet using the provided * mask * @param address The address to convert into a subnet * @return The subnet as an integer */ private int toSubnet(InetAddress address) { return toInt(address) & subnetMask; }
/** * Checks if the {@link InetAddress} is within this subnet * @param address The {@link InetAddress} to check * @return True if the address is within this subnet, false otherwise */ public boolean inSubnet(InetAddress address) { return toSubnet(address) == subnetInt; }
/** * Converts an IP address to a subnet using the provided mask * * @param address * The address to convert into a subnet * @return The subnet as an integer */ private long toSubnet(InetAddress address) { if (address instanceof Inet4Address) { return toInt(address) & (int) subnetMask; } else { return toLong(address) & subnetMask; } }
@Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionClosed(session); } else { blockSession(session); } }
@Override public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionOpened(session); } else { blockSession(session); } }
/** * Converts an IP address to a subnet using the provided mask * * @param address * The address to convert into a subnet * @return The subnet as an integer */ private long toSubnet(InetAddress address) { if (address instanceof Inet4Address) { return toInt(address) & (int) subnetMask; } else { return toLong(address) & subnetMask; } }
@Override public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionIdle(session, status); } else { blockSession(session); } }
@Override public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionIdle(session, status); } else { blockSession(session); } }
@Override public void sessionCreated(NextFilter nextFilter, IoSession session) { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionCreated(session); } else { blockSession(session); } }
@Override public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionOpened(session); } else { blockSession(session); } }
@Override public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionIdle(session, status); } else { blockSession(session); } }
@Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) { if (!isBlocked(session)) { // forward if not blocked nextFilter.messageReceived(session, message); } else { blockSession(session); } }
@Override public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.messageSent(session, writeRequest); } else { blockSession(session); } }
@Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) { if (!isBlocked(session)) { // forward if not blocked nextFilter.messageReceived(session, message); } else { blockSession(session); } }