List of usage examples for io.netty.handler.codec.haproxy HAProxyProxiedProtocol UNKNOWN
HAProxyProxiedProtocol UNKNOWN
To view the source code for io.netty.handler.codec.haproxy HAProxyProxiedProtocol UNKNOWN.
Click Source Link
From source file:org.dcache.xrootd.plugins.ProxyAccessLogHandler.java
License:Open Source License
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof HAProxyMessage) { HAProxyMessage proxyMessage = (HAProxyMessage) msg; if (proxyMessage.command() == HAProxyCommand.PROXY) { InetSocketAddress remoteAddress = (InetSocketAddress) ctx.channel().remoteAddress(); InetSocketAddress localAddress = (InetSocketAddress) ctx.channel().localAddress(); String sourceAddress = proxyMessage.sourceAddress(); String destinationAddress = proxyMessage.destinationAddress(); if (proxyMessage.proxiedProtocol() == HAProxyProxiedProtocol.UNKNOWN) { NetLoggerBuilder log = new NetLoggerBuilder(INFO, "org.dcache.xrootd.connection.start") .omitNullValues(); log.add("session", CDC.getSession()); log.add("socket.remote", remoteAddress); log.add("socket.local", localAddress); log.toLogger(logger);//from www . ja v a 2 s . c o m replaceWith(ctx, handler); } else if (!Objects.equals(destinationAddress, localAddress.getAddress().getHostAddress())) { /* The above check is a workaround for what looks like a bug in HAProxy - health checks * should generate a LOCAL command, but it appears they do actually use PROXY. */ NetLoggerBuilder log = new NetLoggerBuilder(INFO, "org.dcache.xrootd.connection.start") .omitNullValues(); log.add("session", CDC.getSession()); log.add("socket.remote", HostAndPort.fromParts(sourceAddress, proxyMessage.sourcePort())); log.add("socket.proxy", HostAndPort.fromParts(destinationAddress, proxyMessage.destinationPort())); log.add("socket.local", localAddress); log.toLogger(logger); replaceWith(ctx, handler); } } } super.channelRead(ctx, msg); }