2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.netty;
10 import io.netty.buffer.ByteBuf;
11 import io.netty.channel.ChannelHandlerContext;
12 import io.netty.channel.ChannelInboundHandlerAdapter;
13 import java.nio.charset.StandardCharsets;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 class ProxyClientHandler extends ChannelInboundHandlerAdapter {
18 private static final Logger LOG = LoggerFactory.getLogger(ProxyClientHandler.class);
20 private final ChannelHandlerContext remoteCtx;
23 ProxyClientHandler(ChannelHandlerContext remoteCtx) {
24 this.remoteCtx = remoteCtx;
28 public void channelActive(ChannelHandlerContext ctx) {
29 LOG.info("client active");
33 public void channelRead(ChannelHandlerContext ctx, Object msg) {
34 ByteBuf bb = (ByteBuf) msg;
35 LOG.info(">{}", bb.toString(StandardCharsets.UTF_8));
40 public void channelReadComplete(ChannelHandlerContext ctx) {
41 LOG.debug("Flushing server ctx");
46 public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
47 // Close the connection when an exception is raised.
48 LOG.warn("Unexpected exception from downstream", cause);
52 // called both when local or remote connection dies
54 public void channelInactive(ChannelHandlerContext ctx) {
55 LOG.debug("channelInactive() called, closing remote client ctx");