Search in sources :

Example 1 with ProxyIpFilter

use of org.thingsboard.server.transport.mqtt.limits.ProxyIpFilter in project thingsboard by thingsboard.

the class MqttTransportServerInitializer method initChannel.

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();
    SslHandler sslHandler = null;
    if (context.isProxyEnabled()) {
        pipeline.addLast("proxy", new HAProxyMessageDecoder());
        pipeline.addLast("ipFilter", new ProxyIpFilter(context));
    } else {
        pipeline.addLast("ipFilter", new IpFilter(context));
    }
    if (sslEnabled && context.getSslHandlerProvider() != null) {
        sslHandler = context.getSslHandlerProvider().getSslHandler();
        pipeline.addLast(sslHandler);
    }
    pipeline.addLast("decoder", new MqttDecoder(context.getMaxPayloadSize()));
    pipeline.addLast("encoder", MqttEncoder.INSTANCE);
    MqttTransportHandler handler = new MqttTransportHandler(context, sslHandler);
    pipeline.addLast(handler);
    ch.closeFuture().addListener(handler);
}
Also used : IpFilter(org.thingsboard.server.transport.mqtt.limits.IpFilter) ProxyIpFilter(org.thingsboard.server.transport.mqtt.limits.ProxyIpFilter) ProxyIpFilter(org.thingsboard.server.transport.mqtt.limits.ProxyIpFilter) MqttDecoder(io.netty.handler.codec.mqtt.MqttDecoder) HAProxyMessageDecoder(io.netty.handler.codec.haproxy.HAProxyMessageDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline) SslHandler(io.netty.handler.ssl.SslHandler)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)1 HAProxyMessageDecoder (io.netty.handler.codec.haproxy.HAProxyMessageDecoder)1 MqttDecoder (io.netty.handler.codec.mqtt.MqttDecoder)1 SslHandler (io.netty.handler.ssl.SslHandler)1 IpFilter (org.thingsboard.server.transport.mqtt.limits.IpFilter)1 ProxyIpFilter (org.thingsboard.server.transport.mqtt.limits.ProxyIpFilter)1