Hi

We have a Netconf protocol implementation on top of Apache MINA and Apache 
SSHD, and currently working on new feature "reverse SSH"


1. Apache MINA's NioSocketAcceptor is used to accept incoming connections and a 
StreamIOhandler is set to it.

2. So, when a connection is accepted, we have a IoSession, InputStream and 
OutputStream with us

3.  As per the concept of reverseSSH, all further request's should use the same 
channel.

Here comes the need to attach the IoSession to Apache SSHD's SshClient

The following is the code snippet written for achieving this


sshClient.setIoServiceFactoryFactory(new IoServiceFactoryFactory() {
            @Override
            public IoServiceFactory create(final FactoryManager manager) {
                return new MinaServiceFactory(manager) {
                    @Override
                    public IoConnector createConnector(final IoHandler handler) 
{
                        try {
                            return new Nio2Connector(manager, handler, 
AsynchronousChannelGroup.withThreadPool(MoreExecutors.sameThreadExecutor())) {
                                @Override
                                public IoConnectFuture connect(final 
SocketAddress address) {
                                    DefaultIoConnectFuture 
defaultIoConnectFuture = new DefaultIoConnectFuture(null);
                                    
defaultIoConnectFuture.setSession(ioSession);
                                    return defaultIoConnectFuture;
                                }
                            };
                        } catch (IOException e) {
                            // FIXME
                            e.printStackTrace();
                        }
                        return null;
                    }
                };
            }
        });


sshClient.start();

Are these steps correct? If not, can you please let us know the correct steps.

4. For further communication can we use this SshClient API to talk to the 
devices in usual manner?



Thanks
Vikram


This email and attachments may contain privileged or confidential information 
intended only for the addressee(s) indicated. The sender does not waive any of 
its rights, privileges or protections respecting this information. If you are 
not the named addressee, an employee, or agent responsible for sending this 
message to the named addressee (or this message was received by mistake), you 
are not authorized to read, print, retain, copy or disseminate this message or 
any part of it. If received in error, please notify us immediately by e-mail, 
discard any paper copies and delete all electronic files of the email.

Computer viruses can be transmitted via email. The recipient should check this 
email and any attachments for viruses. Email transmission cannot be guaranteed 
to be secured or error-free as information could be intercepted, corrupted, 
lost, destroyed, arrive late or incomplete, or contain viruses. The sender 
accepts no liability for any damage caused by any transmitted viruses or errors 
or omissions in the contents of this message.

Overture Networks, Inc. 637 Davis Drive, Morrisville, NC USA 27560 
www.overturenetworks.com

Reply via email to