/** * Sets the subnets to be blacklisted. * * NOTE: this call will remove any previously blacklisted subnets. * * @param subnets an array of subnets to be blacklisted. */ public void setSubnetBlacklist(Iterable<Subnet> subnets) { if (subnets == null) { throw new IllegalArgumentException("Subnets must not be null"); } blacklist.clear(); for (Subnet subnet : subnets) { block(subnet); } }
@Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionClosed(session); } else { blockSession(session); } }
/** * Unblocks the specified endpoint. * * @param address The address to unblock */ public void unblock(InetAddress address) { if (address == null) { throw new IllegalArgumentException("Adress to unblock can not be null"); } unblock(new Subnet(address, 32)); }
public GateWebSocketUserServer(MinaServerConfig minaServerConfig) { super(null); this.minaServerConfig=minaServerConfig; blacklistFilter=new BlacklistFilter(); filters.put("Blacklist", blacklistFilter); ScriptManager.getInstance().getBaseScriptEntry().executeScripts(IGateServerScript.class, script->script.setIpBlackList(blacklistFilter)); gateWebSocketUserServerHandler=new GateWebSocketUserServerHandler(); tcpServer=new TcpServer(minaServerConfig, gateWebSocketUserServerHandler, new WebSocketCodecFactory(), filters); }
private void updateBlacklistFilter() { if (acceptor != null) { BlacklistFilter filter = (BlacklistFilter) acceptor .getFilterChain().get("ipFilter"); if (filter != null) { if (getBlockedAddresses() != null) { filter.setBlacklist(getBlockedAddresses()); } else if (getBlockedSubnets() != null) { filter.setSubnetBlacklist(getBlockedSubnets()); } else { // an empty list clears the blocked addresses filter.setSubnetBlacklist(new ArrayList<Subnet>()); } } } }
/** * Unblocks the specified endpoint. * * @param address The address to unblock */ public void unblock(InetAddress address) { if (address == null) { throw new IllegalArgumentException("Adress to unblock can not be null"); } unblock(new Subnet(address, 32)); }
public GateUdpUserServer(MinaServerConfig minaServerConfig) { super(null); this.minaServerConfig=minaServerConfig; blacklistFilter=new BlacklistFilter(); filters.put("Blacklist", blacklistFilter); ScriptManager.getInstance().getBaseScriptEntry().executeScripts(IGateServerScript.class, script->script.setIpBlackList(blacklistFilter)); udpServer=new UdpServer(minaServerConfig, new GateUdpUserServerHandler(this),new ClientProtocolCodecFactory(),filters); }
@Override public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionOpened(session); } else { blockSession(session); } }
/** * Sets the subnets to be blacklisted. * * NOTE: this call will remove any previously blacklisted subnets. * * @param subnets an array of subnets to be blacklisted. */ public void setSubnetBlacklist(Iterable<Subnet> subnets) { if (subnets == null) { throw new NullPointerException("Subnets must not be null"); } blacklist.clear(); for (Subnet subnet : subnets) { block(subnet); } }
/** * Unblocks the specified endpoint. */ public void unblock(InetAddress address) { if (address == null) { throw new NullPointerException("Adress to unblock can not be null"); } unblock(new Subnet(address, 32)); }
acceptor.getFilterChain().addLast("ipFilter", new BlacklistFilter()); updateBlacklistFilter();
@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); } }
/** * Sets the subnets to be blacklisted. * * NOTE: this call will remove any previously blacklisted subnets. * * @param subnets an array of subnets to be blacklisted. */ public void setSubnetBlacklist(Subnet[] subnets) { if (subnets == null) { throw new IllegalArgumentException("Subnets must not be null"); } blacklist.clear(); for (Subnet subnet : subnets) { block(subnet); } }
@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); } }
/** * Sets the addresses to be blacklisted. * * NOTE: this call will remove any previously blacklisted addresses. * * @param addresses an array of addresses to be blacklisted. */ public void setBlacklist(InetAddress[] addresses) { if (addresses == null) { throw new IllegalArgumentException("addresses"); } blacklist.clear(); for (int i = 0; i < addresses.length; i++) { InetAddress addr = addresses[i]; block(addr); } }
@Override public void sessionCreated(NextFilter nextFilter, IoSession session) { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionCreated(session); } else { blockSession(session); } }
/** * Sets the addresses to be blacklisted. * * NOTE: this call will remove any previously blacklisted addresses. * * @param addresses a collection of InetAddress objects representing the * addresses to be blacklisted. * @throws IllegalArgumentException if the specified collections contains * non-{@link InetAddress} objects. */ public void setBlacklist(Iterable<InetAddress> addresses) { if (addresses == null) { throw new IllegalArgumentException("addresses"); } blacklist.clear(); for (InetAddress address : addresses) { block(address); } }
@Override public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { if (!isBlocked(session)) { // forward if not blocked nextFilter.sessionOpened(session); } else { blockSession(session); } }
/** * Sets the addresses to be blacklisted. * * NOTE: this call will remove any previously blacklisted addresses. * * @param addresses an array of addresses to be blacklisted. */ public void setBlacklist(InetAddress[] addresses) { if (addresses == null) { throw new NullPointerException("addresses"); } blacklist.clear(); for (int i = 0; i < addresses.length; i++) { InetAddress addr = addresses[i]; block(addr); } }
@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); } }