-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: x/crypto/ssh: add deadlines support for channels #65930
Comments
Change https://go.dev/cl/562756 mentions this issue: |
CC @golang/security |
The handshake (version, kex, etc) can stall unless the underlying Conn is closed. I would love to see deadlines on channels, but it may make sense to have a general read/write timeout capability, otherwise we still need the conn.Close() to unblock when communicating with misbehaving peers. |
@hdm isn't that just |
The challenge is that the deadlines need to be reset on each read/write and setting it at the connection level doesn't allow re-extension of the deadline by operation. For an example, with a long-lived session, you may want want a relatively short deadline for version exchange and kex, but then to re-extend it after each input line is passed in via the stdin reader. I get your point though, if a deadline on the Conn is enough to get us into the session, then a Channel deadline could take over from there for most use cases. |
I have a real life use-case in case that helps in any way... I have an outbound ssh tunnel over which I serve an HTTP reverse proxy (just an
Here's a related github issue opened by someone else: #67152 |
@adrianosela I rebased the linked CL, testing with a real use case would help us understand how useful this addition would be and speed up proposal approval. The main concern here is that deadlines work at a logical level and don't unblock the underlying Please try the CL and provide your feedbacks. Thank you! |
@drakkan code changes LGTM. I'll give your CL a go sometime in the next 2 weeks. |
Hey @drakkan -- just gave your code a test and I can now use websockets over ssh channels 🚀 and I don't see any unintended side effects. Would be good to run a performance test aside from functional testing. Here's the exact diff of my local code vs what's in PS 9 of your CL... TL;DR; I just
Click here to see whole diff
|
@adrianosela thanks for your testing, much appreciated. Changing the Please keep testing and let us know if you encounter any issues. Thanks! |
Comments left in PS 11 :) going forward let's use the CL for all communication @drakkan |
If anyone happens to be waiting for this to be released - here's a band-aid solution you can try at your own risk :) https://github.com/adrianosela/deaconn |
This is actually Nicola Murino's fix from google source: https://go-review.googlesource.com/c/crypto/+/562756 deadlines unblock reads waiting for data and writes waiting for window capacity Fixes golang/go#65930 Fixes golang/go#67152 Change-Id: Ica42573cdf11ddf58e48b51fa82466a14cc5e606
Proposal Details
Currently ssh channels does not support deadlines, so the only way to unblock reads/writes is to set a deadline on the underlying
net.Conn
, but this will affect all channels using the connection.Channels are typically blocked on reads while waiting for data and on writes while waiting for window capacity.
I propose adding deadlines to channels to fix these typically use cases, I don't think we can unblock reads/writes blocked on the underlying
net.Conn
.Proposed API
cc @golang/proposal-review
The text was updated successfully, but these errors were encountered: