use of org.opendaylight.netconf.shaded.sshd.server.session.ServerSession in project netconf by opendaylight.
the class RemoteNetconfCommand method start.
@Override
public void start(final ChannelSession channel, final Environment env) {
final ServerSession session = channel.getServerSession();
final SocketAddress remoteAddress = session.getIoSession().getRemoteAddress();
final String hostName;
final String port;
if (remoteAddress instanceof InetSocketAddress) {
hostName = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
port = Integer.toString(((InetSocketAddress) remoteAddress).getPort());
} else {
hostName = "";
port = "";
}
netconfHelloMessageAdditionalHeader = new NetconfHelloMessageAdditionalHeader(session.getUsername(), hostName, port, "ssh", "client");
LOG.trace("Establishing internal connection to netconf server for client: {}", getClientAddress());
final Bootstrap clientBootstrap = new Bootstrap();
clientBootstrap.group(clientEventGroup).channel(LocalChannel.class);
clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
@Override
public void initChannel(final LocalChannel ch) {
ch.pipeline().addLast(new SshProxyClientHandler(in, out, netconfHelloMessageAdditionalHeader, callback));
}
});
clientChannelFuture = clientBootstrap.connect(localAddress);
clientChannelFuture.addListener(future -> {
if (future.isSuccess()) {
clientChannel = clientChannelFuture.channel();
} else {
LOG.warn("Unable to establish internal connection to netconf server for client: {}", getClientAddress());
requireNonNull(callback, "Exit callback must be set").onExit(1, "Unable to establish internal connection to netconf server for client: " + getClientAddress());
}
});
}
Aggregations