Architecture
etrans is two crates in one workspace.
etrans-core
Everything that is not drawing, and has no UI dependency:
| Module | |
|---|---|
ssh |
Connecting: TCP or a tunnel through a jump host, the host key check, and the login (agent, keys, password, keyboard-interactive). Anything that needs a person is put to an Asker, and the connection waits for the answer. |
known_hosts |
~/.ssh/known_hosts read as OpenSSH reads it: patterns, negation, hashed names, @revoked and @cert-authority, and host certificates checked against it. |
ssh_config |
The parts of ~/.ssh/config etrans uses. |
remote |
A server's files, whatever the way to them: Remote lists, reads, writes, moves and removes, and each way to a server is a variant of it: SFTP, an S3 bucket, a WebDAV server. Uploads go through begin_upload and finish_upload, so each way can keep a file half sent and put it in place whole as it can. What needs SSH (a terminal, a tar stream, a command) asks Remote::ssh, which is None for the others. |
s3 |
Remote over S3: signed with rusty-s3, sent with reqwest; uploads in parts that carry on. |
dav |
Remote over WebDAV: PROPFIND, GET, PUT and MOVE, over reqwest. |
sftp |
Remote over an SFTP channel on an SSH connection. |
local |
The local filesystem, listed the same way, plus keys in ~/.ssh and user and group names. |
transfer |
The transfer queue: planning, copying with partial files and resume, retries, conflicts, and replacing in one step with posix-rename. A transfer can also be given its items ready-made, as a sync's are. transfer::tar_stream sends a whole new folder as one tar stream over a command channel. |
sync |
Folder sync: both trees listed, compared, and planned as folders to make, files to copy and things to remove. |
walk |
Listing a tree a dozen folders at a time, for planning, sync and Get Info. |
trash |
The server's trash: deletions moved to ~/.etrans-trash, put back, and emptied after 30 days. |
listening |
What listens on the server, from ss, /proc/net/tcp or netstat. |
forward |
Local, remote and SOCKS5 forwarding. |
shell |
An interactive shell in a pseudo-terminal. |
site, settings, secrets, import, accounts |
Saved servers, settings, Keychain, importing, owners by name. |
runtime |
The tokio runtime the SSH work runs on. |
SSH and SFTP are russh and russh-sftp.
russh needs tokio, and gpui has its own executor, so the two meet in
runtime: work is spawned onto a runtime that lives for the whole process,
and the caller gets back a plain future any executor can wait on. Dropping that
future stops the work, which is how cancelling a connection really cancels it.
etrans
The app, on GPUI:
| Module | |
|---|---|
tabs |
The window: its tabs, each a Browser, and the row they are shown in. |
browser |
One tab: connecting and reconnecting, the server list, dialogs, the right-click menu, the transfer drawer, port forwarding, Get Info, Synchronize, Copy and Paste, Quick Look, About and the update strip. |
pane |
One file pane: listing, selection, navigation, the filter, typing to select, drag and drop. |
mac |
What gpui does not reach: Quick Look, files on the pasteboard, and drags out to Finder (file promises for files on the server). |
terminal |
A shell window: alacritty's emulator fed from the SSH channel, drawn cell by cell. |
preferences |
Settings as the app holds them, and the Settings window. |
update |
The updater: the feed, the download, the signature check and the swap. |
text_input, ui, theme, actions, keys |
Text fields, shared controls, colours, actions and their keys, and keystrokes to terminal bytes. |
Two things worth knowing
Questions from the background. A connection that meets an unknown host key,
or needs a password, does not know about windows. It calls an Asker — a
function from a Question to a future answer — and waits. The window turns the
question into a sheet and sends the answer back over a oneshot channel. A
reconnect wraps the asker in one that answers passwords typed earlier from
memory.
Partial files are named for their source. A transfer writes
.<name>.<size>-<mtime>.etrans-part beside the destination and renames it into
place when it is whole. Resuming is looking for that exact name: if the source
changed, the name changed, and the copy starts over instead of continuing a
different file.