com.arangodb.shaded.vertx.core.net.impl.HAProxyMessageCompletionHandler Maven / Gradle / Ivy
package com.arangodb.shaded.vertx.core.net.impl;
import com.arangodb.shaded.netty.channel.Channel;
import com.arangodb.shaded.netty.channel.ChannelHandlerContext;
import com.arangodb.shaded.netty.handler.codec.MessageToMessageDecoder;
import com.arangodb.shaded.netty.handler.codec.haproxy.HAProxyMessage;
import com.arangodb.shaded.netty.handler.codec.haproxy.HAProxyProxiedProtocol;
import com.arangodb.shaded.netty.handler.timeout.IdleState;
import com.arangodb.shaded.netty.handler.timeout.IdleStateEvent;
import com.arangodb.shaded.netty.util.concurrent.Promise;
import com.arangodb.shaded.vertx.core.impl.logging.Logger;
import com.arangodb.shaded.vertx.core.impl.logging.LoggerFactory;
import com.arangodb.shaded.vertx.core.net.SocketAddress;
import java.io.IOException;
import java.util.List;
public class HAProxyMessageCompletionHandler extends MessageToMessageDecoder {
//Public because its used in tests
public static final IOException UNSUPPORTED_PROTOCOL_EXCEPTION = new IOException("Unsupported HA PROXY transport protocol");
private static final Logger log = LoggerFactory.getLogger(HAProxyMessageCompletionHandler.class);
private static final boolean proxyProtocolCodecFound;
static {
boolean proxyProtocolCodecCheck = true;
try {
Class.forName("com.arangodb.shaded.netty.handler.codec.haproxy.HAProxyMessageDecoder");
} catch (Throwable ex) {
proxyProtocolCodecCheck = false;
}
proxyProtocolCodecFound = proxyProtocolCodecCheck;
}
public static boolean canUseProxyProtocol(boolean requested) {
if (requested && !proxyProtocolCodecFound)
log.warn("Proxy protocol support could not be enabled. Make sure that netty-codec-haproxy is included in your classpath");
return proxyProtocolCodecFound && requested;
}
private final Promise promise;
public HAProxyMessageCompletionHandler(Promise promise) {
this.promise = promise;
}
@Override
protected void decode(ChannelHandlerContext ctx, HAProxyMessage msg, List