Skip to content

Feat/ssh local port forwarding#274

Merged
su-fen merged 4 commits into
Stack-Cairn:mainfrom
hopingmiao:feat/ssh-local-port-forwarding
Jul 26, 2026
Merged

Feat/ssh local port forwarding#274
su-fen merged 4 commits into
Stack-Cairn:mainfrom
hopingmiao:feat/ssh-local-port-forwarding

Conversation

@hopingmiao

@hopingmiao hopingmiao commented Jul 25, 2026

Copy link
Copy Markdown

摘要

为桌面端增加会话级 SSH 本地端口转发(类似 ssh -L),并完成 Windows 下的生命周期与 UX 收尾。

在已连接的 SSH 终端会话上,可在本机 127.0.0.1 监听端口,经当前 SSH 将会话流量转到远端指定 host:port;会话关闭或应用退出时自动清理。

改动内容

  • 运行时:新增会话级 local forward(list / start / stop),仅绑定 127.0.0.1,支持指定本地端口或 0 自动分配
  • 约束与清理:仅已连接 SSH 可启动;校验远端 host/port;限制每会话 / 每条转发 / 全局连接数;close / stop / 退出时清理监听
  • SSH 状态:handle 改为 Arc 并提供 current_handle(),避免建连长时间占锁;close 规范化 session id 并清理该会话全部转发
  • Tauri 命令terminal_ssh_local_forward_start / list / stop,事件 terminal:ssh-local-forward(started / stopped / failed)
  • 前端:类型、状态归约、输入校验、Tauri client;SSH 隧道面板增加启动 / 停止 / 复制地址 / listening·waiting 状态
  • 其它:中英文案、单测,以及 CI 中的 ssh_local_forward 测试任务

主要文件

区域 路径
转发核心 crates/agent-gui/src-tauri/src/runtime/terminal/ssh_local_forward.rs
会话/关闭 state.rs / registry.rs / mod.rs / types.rs
命令注册 commands/runtime/terminal.rssrc/lib.rs
前端类型与 client src/lib/terminal/sshLocalForwardTypes.tstauriSshLocalForwardClient.ts
UI src/components/project-tools/SshTunnelPanel.tsx

安全说明

  • 仅桌面端,不暴露远程 Gateway 控制
  • 仅 loopback(127.0.0.1)监听
  • 必须已有已连接的 SSH 会话
  • 语义等同用户主动 ssh -Lremote_host 无额外业务白名单)

45458976 and others added 2 commits July 25, 2026 18:35
Introduce desktop-only SSH local forwarding on authenticated terminal sessions, with loopback-only listeners, start/list/stop UI, lifecycle cleanup, and targeted tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@su-fen
su-fen force-pushed the feat/ssh-local-port-forwarding branch from e3bd09b to 70c10b1 Compare July 26, 2026 06:23
su-fen added 2 commits July 26, 2026 15:00
Replace the inline three-input forwarding form in each SSH session card
with a Cable icon button (left of the close button) that opens a Base UI
dialog. The dialog validates the target, probes the requested loopback
port over the new terminal_ssh_local_forward_check_port command, and
reports a localized "port in use" error before starting; the bind in
start remains the authoritative backstop. Mapping rows stay under the
card with a Trash2 remove button on the far right.
Relay the four ssh_local_forward_* actions over the existing
TerminalRequest channel (proto fields only, no new envelope arm), gate
them behind enableWebSshTerminal on both the Go guard and the Rust
handler, and fan forward lifecycle events out to gateway subscribers as
kind "ssh_local_forward" terminal events.

On the web side, mirror sshLocalForwardTypes and a client-injected
SshPortForwardDialog (both added to the mirror manifest), add a
gateway-backed forward client, and port the tunnel panel UI, i18n copy,
and dialog CSS. normalizeTerminalEvent no longer drops session-less
forward events.
@su-fen
su-fen merged commit 43683d9 into Stack-Cairn:main Jul 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants