Search in sources :

Example 1 with BlackIPFilter

use of com.generallycloud.baseio.container.BlackIPFilter in project baseio by generallycloud.

the class HttpApplicationContextEnricher method enrich.

@Override
public void enrich(ApplicationContext context) {
    SocketChannelContext channelContext = context.getChannelContext();
    context.setServiceFilter(new FutureAcceptorHttpFilter());
    context.setExceptionCaughtHandle(new HttpExceptionCaughtHandle());
    // FIXME 重复的
    Set<String> blackIPs = context.getBlackIPs();
    if (blackIPs != null && !blackIPs.isEmpty()) {
        channelContext.addSessionEventListener(new BlackIPFilter(blackIPs));
    }
    channelContext.setBeatFutureFactory(new WebSocketBeatFutureFactory());
    channelContext.addSessionEventListener(new LoggerSocketSEListener());
    channelContext.addSessionIdleEventListener(new SocketSessionAliveSEListener());
    channelContext.setProtocolFactory(new ServerHTTPProtocolFactory());
}
Also used : LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) SocketSessionAliveSEListener(com.generallycloud.baseio.component.SocketSessionAliveSEListener) BlackIPFilter(com.generallycloud.baseio.container.BlackIPFilter) FutureAcceptorHttpFilter(com.generallycloud.baseio.container.http11.service.FutureAcceptorHttpFilter) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) ServerHTTPProtocolFactory(com.generallycloud.baseio.codec.http11.ServerHTTPProtocolFactory) WebSocketBeatFutureFactory(com.generallycloud.baseio.codec.http11.future.WebSocketBeatFutureFactory)

Example 2 with BlackIPFilter

use of com.generallycloud.baseio.container.BlackIPFilter in project baseio by generallycloud.

the class ProtobaseApplicationContextEnricher method enrich.

@Override
public void enrich(ApplicationContext context) {
    SocketChannelContext channelContext = context.getChannelContext();
    context.setServiceFilter(new FutureAcceptorServiceFilter());
    // FIXME 重复的
    Set<String> blackIPs = context.getBlackIPs();
    if (blackIPs != null && !blackIPs.isEmpty()) {
        channelContext.addSessionEventListener(new BlackIPFilter(blackIPs));
    }
    channelContext.addSessionEventListener(new LoggerSocketSEListener());
    channelContext.setProtocolFactory(new ParamedProtobaseProtocolFactory());
    channelContext.setBeatFutureFactory(new ParamedProtobaseBeatFutureFactory());
}
Also used : LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) FutureAcceptorServiceFilter(com.generallycloud.baseio.container.service.FutureAcceptorServiceFilter) BlackIPFilter(com.generallycloud.baseio.container.BlackIPFilter) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) ParamedProtobaseProtocolFactory(com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory) ParamedProtobaseBeatFutureFactory(com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseBeatFutureFactory)

Aggregations

LoggerSocketSEListener (com.generallycloud.baseio.component.LoggerSocketSEListener)2 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)2 BlackIPFilter (com.generallycloud.baseio.container.BlackIPFilter)2 ServerHTTPProtocolFactory (com.generallycloud.baseio.codec.http11.ServerHTTPProtocolFactory)1 WebSocketBeatFutureFactory (com.generallycloud.baseio.codec.http11.future.WebSocketBeatFutureFactory)1 ParamedProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory)1 ParamedProtobaseBeatFutureFactory (com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseBeatFutureFactory)1 SocketSessionAliveSEListener (com.generallycloud.baseio.component.SocketSessionAliveSEListener)1 FutureAcceptorHttpFilter (com.generallycloud.baseio.container.http11.service.FutureAcceptorHttpFilter)1 FutureAcceptorServiceFilter (com.generallycloud.baseio.container.service.FutureAcceptorServiceFilter)1