tailscale: experimental russh + ratatui support#178
Open
npry wants to merge 2 commits into
Open
Conversation
2a249c5 to
146e1c1
Compare
5c6e256 to
36768ee
Compare
Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: I464cf0501b290530079a858484d521ae6a6a6964
Provide a happy-path integration with `russh` and `ratatui` that makes it easier to build in-process SSH TUIs with tailscale-rs. Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: I1c49b666d92dcc76076e35585ae4fe7e6a6a6964
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finally got this cleaned up — provide a
tailscale::sshmodule, which provides integration withrusshandratatui. The levels of indirection are a bit convoluted, but I left a comment on thesshmodule explaining the rough organization.As a quick summary here, there are a few moving pieces: the ssh connection, ssh channels, and the actual tui implementation. The ssh connection is 1:1 with an overlay TCP connection, on which multiple channels may be muxed (this is baseline SSH behavior). Those channels may run an interface built with ratatui, but I leave that optional here (the user can in principle plug in whatever behavior they want).
While
russhintegrates the connection-level and channel-level operations into a singleHandlertrait, I break out the per-channel stuff into aChannelHandlertrait, and our top-levelrussh::HandlerisChannelServer(which takes aChannelHandlerparametrically and automatically spawnsChannelHandlers as channels are opened). ThenRatatuiTermimplementsChannelHandlerover a parametricRatatuiApp(the user logic to take input and actually draw the interface).I'm not entirely happy with it — it feels opinionated/frameworky in places rather than elegant/generic, but I also think it captures a bunch of annoying boilerplate in a way that's useful. I feel it's worth merging but also probably not its final form, quite open to critique/suggestions/reworks. Also, my instinct consistent with the granular crates would be to split it out to its own crate, but we said we were gonna do that less — I'm fine wherever we want to put it.