Ok... Well I have got some progress. The func ssh_channel_listen_forward is actually working in block mode, which means it will hold until get the server reply. I think this makes sense, see maybe server doesn't open this option and directly reject this request. This also makes server have completely control when should open the reverse channel, I have test it and seems it works.
Now my problem is how can I code a message_callback in client side? I have tried set_message_callback, but it seems not have any affect. The func ssh_channel_accept_forward implement as look for message_list in a time range, out of range will cause it directly return NULL. I want is before server decide to open a reverse channel, the client do nothing except in a mainloop, once server decide to open it, ok, the client can through message_callback to determine whether it's SSH_MSG_CHANNEL_FORWARD type forwarded-tcpip, and accept and reject it. Thanks, Yuanzhe ------------------ ???????? ------------------ ??????: "Andreas Schneider"<[email protected]>; ????????: 2020??4??9??(??????) ????2:52 ??????: "libssh"<[email protected]>; ????: "??????"<[email protected]>; ????: Re: ??????HOW to use ssh_channel_open_reverse_forward function to implement a reverse tunnel? On Wednesday, 8 April 2020 17:21:44 CEST ?????? wrote: > Re-Update: > After compared the different result > between&nbsp;ssh_message_global_request_reply_success > before&nbsp;ssh_channel_open_reverse_forward or after it I > found&nbsp;ssh_channel_listen_forward want a reply, so if I reply it > immediately, the ssh client then said "ssh_global_request: Global request > tcpip-forward success"and&nbsp; can't > receive&nbsp;ssh_channel_open_reverse_forward request. Otherwise if I > choose to reply it after ssh_channel_open_reverse_forward, > the&nbsp;&nbsp;ssh_channel_listen_forward will hang there, continue wait > for the&nbsp; reply. I've never used that code, we don't have example code nor a test for it. So as always I would argue: Untested code is broken code. I think we need to implement a test to actually fix the code. However I don't have time for this. Contributions in this area are very welcome. See the server testing code Anderson implemented for a start. Best regards, Andreas -- Andreas Schneider [email protected] GPG-ID: 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
