Search in sources :

Example 1 with IpFilterRuleChannelMatcher

use of org.infinispan.server.core.transport.IpFilterRuleChannelMatcher in project infinispan by infinispan.

the class ServerStateManagerImpl method updateIpFilters.

private CompletionStage<Void> updateIpFilters(String connector, Collection<IpFilterRule> rules) {
    ProtocolServer protocolServer = server.getProtocolServers().get(connector);
    if (rules.isEmpty()) {
        protocolServer.getConfiguration().ipFilter().rules(Collections.emptyList());
        Server.log.connectorIpFilterCleared(connector);
        return CompletableFutures.completedNull();
    } else {
        List<IpSubnetFilterRule> localRules = new ArrayList<>(rules.size());
        for (IpFilterRule rule : rules) {
            localRules.add(new IpSubnetFilterRule(rule.cidr, IpFilterRuleType.valueOf(rule.type)));
        }
        protocolServer.getConfiguration().ipFilter().rules(localRules);
        Transport transport = getTransport(protocolServer);
        CompositeChannelMatcher matcher = new CompositeChannelMatcher(protocolServer.getChannelMatcher(), new IpFilterRuleChannelMatcher(localRules));
        return transport.closeChannels(matcher).thenApply(v -> {
            Server.log.connectorIpFilterSet(connector, localRules);
            return v;
        });
    }
}
Also used : ProtocolServer(org.infinispan.server.core.ProtocolServer) IpFilterRuleChannelMatcher(org.infinispan.server.core.transport.IpFilterRuleChannelMatcher) CompositeChannelMatcher(org.infinispan.server.core.transport.CompositeChannelMatcher) ArrayList(java.util.ArrayList) Transport(org.infinispan.server.core.transport.Transport) IpSubnetFilterRule(org.infinispan.server.core.transport.IpSubnetFilterRule)

Aggregations

ArrayList (java.util.ArrayList)1 ProtocolServer (org.infinispan.server.core.ProtocolServer)1 CompositeChannelMatcher (org.infinispan.server.core.transport.CompositeChannelMatcher)1 IpFilterRuleChannelMatcher (org.infinispan.server.core.transport.IpFilterRuleChannelMatcher)1 IpSubnetFilterRule (org.infinispan.server.core.transport.IpSubnetFilterRule)1 Transport (org.infinispan.server.core.transport.Transport)1