Skip to content

Commit 42e7a9e

Browse files
committed
feat(network): added local port forwarding
- To get this working correctly, the data and state management in `session` needed to be refactored. This is because tcpip requests create new channels on top of the initial one used via pty requests. Now the state stops at `Authenticated` and the functions themselves hold their own state (like russh_sftp taking ownership of the channel). - Error handling is a little tricky, there's no way to return an error on the incoming tcpip channel (no idea what the protocol is after all). So, it is possible to broadcast to a `writer` from anywhere in the session. In the case of the dashboard, this results in an error that pops up for the user. - Ratatui can't handle ANSI, so now the `color_eyre` output is correctly converted into a `Text` widget. - The dashboard now takes an `impl AsyncRead` along with the `impl Writer` that it used to. This required changing the `stdin` reader in the dashboard dev command. - `channel_eof` now correctly only closes the channel it was meant for and not the entire session (especially if a dashboard was running). - As data is now owned by the request that created it, the session level data handler only tracks total bytes.
1 parent 832d4d4 commit 42e7a9e

24 files changed

+1153
-395
lines changed

Cargo.lock

+29-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ keywords = ["cli", "kubernetes", "ssh", "tui", "terminal"]
2121
categories = ["command-line-interface"]
2222

2323
[dependencies]
24+
ansi-to-tui = "=5.0.0-rc.1"
2425
async-trait = "0.1.81"
2526
cata = { version = "0.1.1" }
2627
chrono = { version = "0.4.38", features = ["serde"] }
@@ -61,15 +62,15 @@ russh = "0.45.0"
6162
russh-keys = "0.45.0"
6263
russh-sftp = "2.0.3"
6364
schemars = { version = "0.8.21", features = ["chrono"] }
64-
serde = { version = "1.0.208", features = ["derive"] }
65-
serde_json = "1.0.124"
65+
serde = { version = "1.0.209", features = ["derive"] }
66+
serde_json = "1.0.127"
6667
serde_path_to_error = "0.1.16"
6768
serde_yaml = "0.9.34"
6869
ssh-key = "0.6.6"
6970
strum_macros = "0.26.4"
7071
syntect = "5.2.0"
7172
syntect-tui = "3.0.3"
72-
tokio = { version = "1.39.3", features = ["full"] }
73+
tokio = { version = "1.40.0", features = ["full", "tracing"] }
7374
tokio-util = { version = "0.7.11", features = ["io-util"] }
7475
tracing = "0.1.40"
7576
tracing-error = { version = "0.2.0", features = ["traced-error"] }

DEVELOPMENT.md

+19
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,22 @@ When you run `just dev-push`, an image at `kuberift:5432/kuberift:latest` will
4141
be available to run inside the cluster.
4242

4343
[k3d]: https://k3d.io/v5.6.3/#releases
44+
45+
## Forwarding
46+
47+
If testing port forwarding and running the service locally (aka not on the
48+
cluster), you won't have access to any of the DNS or IP addresses that might be
49+
forwarded. To work around this, modify `/etc/hosts`:
50+
51+
```txt
52+
127.0.0.1 localhost.default.svc
53+
```
54+
55+
Then you'll be able to test forwarding to localhost via:
56+
57+
```bash
58+
ssh -L 9090:svc/default/localhost:9091 me@localhost -p 2222
59+
```
60+
61+
Testing `pods` and `nodes` requires running on the cluster as the response from
62+
`addr` for those is IP addresses.

0 commit comments

Comments
 (0)