[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

=?gb18030?b?u9i4tKO6ILvYuLSjukhPVyB0byB1c2Ugc3NoX2No?==?gb18030?b?YW5uZWxfb3Blbl9yZXZlcnNlX2ZvcndhcmQgZnVu?==?gb18030?b?Y3Rpb24gdG8gaW1wbGVtZW50IGEgcmV2ZXJzZSB0?==?gb18030?b?dW5uZWw/?=


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


------------------ 原始邮件 ------------------
发件人:&nbsp;"Andreas Schneider"<asn@xxxxxxxxxxxxxx&gt;;
发送时间:&nbsp;2020年4月9日(星期四) 下午2:52
收件人:&nbsp;"libssh"<libssh@xxxxxxxxxx&gt;;
抄送:&nbsp;"刘元哲"<945695107@xxxxxx&gt;;
主题:&nbsp;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:
&gt; Re-Update:
&gt; After compared the different result
&gt; between&amp;nbsp;ssh_message_global_request_reply_success
&gt; before&amp;nbsp;ssh_channel_open_reverse_forward or after it
&nbsp;I
&gt; found&amp;nbsp;ssh_channel_listen_forward want a reply, so if I reply it
&gt; immediately, the ssh client then said "ssh_global_request: Global request
&gt; tcpip-forward success"and&amp;nbsp; can't
&gt; receive&amp;nbsp;ssh_channel_open_reverse_forward request. Otherwise if I
&gt; choose to reply it after ssh_channel_open_reverse_forward,
&gt; the&amp;nbsp;&amp;nbsp;ssh_channel_listen_forward will hang there, continue wait
&gt; for the&amp;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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; asn@xxxxxxxxxxxxxx
GPG-ID:&nbsp;&nbsp;&nbsp;&nbsp; 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D

Archive administrator: postmaster@lists.cynapses.org