JinHeap opened a new issue, #705:
URL: https://github.com/apache/mina-sshd/issues/705

   ### Description
   
   We have a use case that requires port forwarding, but we need to send a 
token ‌before‌ forwarding the port. After reviewing the source code, we found 
that a potential solution is to add a ChannelListener and send the token using 
the port when channelOpenSuccess is triggered.
   
   However, the port property in TcpipServerChannel does not appear to be 
directly accessible to users. Could this property be exposed (e.g., via a 
public method or event argument) to allow developers to retrieve the port 
number during the channelOpenSuccess phase?
   
   Welcome any suggestions
   
   our demo
   
   ```
       private static ChannelListener getListener() {
           return new ChannelListener() {
               @Override
               public void channelOpenSuccess(Channel channel) {
                   if (channel instanceof TcpipServerChannel) {
                       System.out.println("channel open success");
                       TcpipServerChannel direct = (TcpipServerChannel) channel;
                       try {
                           Buffer buf = new ByteArrayBuffer(token);
                           
direct.getPort().getPortSession().writeBuffer(buf).addListener(future1 -> {
                               if (future1.isWritten()) {
                                   System.out.println("write success");
                               } else {
                                   System.err.println(future1.getException());
                               }
                           });
                       } catch (IOException e) {
                           System.err.println(e);
                       }
                   }
               }
           };
       }
   ```
   
   ### Motivation
   
   improve
   
   ### Alternatives considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to