Skip to content

feat(tunnels): import SSH forwards as tunnels + working per-tunnel au…#81

Open
BungeeDEV wants to merge 1 commit into
macnev2013:mainfrom
BungeeDEV:feat/ssh-forward-import-autostart
Open

feat(tunnels): import SSH forwards as tunnels + working per-tunnel au…#81
BungeeDEV wants to merge 1 commit into
macnev2013:mainfrom
BungeeDEV:feat/ssh-forward-import-autostart

Conversation

@BungeeDEV

Copy link
Copy Markdown
Contributor

This pull request improves the SSH config import process by making port-forwarding (tunnel) imports idempotent and more robust. It introduces a natural-key lookup for port-forwarding rules to avoid duplicate tunnels when re-importing the same SSH config, and adds support for parsing and importing SSH port-forwarding directives directly from config files. The changes are covered by new tests to ensure correctness.

SSH config import improvements:

  • Added parsing and extraction of port-forwarding directives (LocalForward, RemoteForward, DynamicForward) from SSH config files, mapping them to a new SshForward struct and including them in SshConfigEntry and SshConfigImportEntry (src-tauri/src/import/mod.rs). [1] [2] [3] [4] [5] [6]

  • On import, port-forwarding rules are now created per host entry, but only if an identical rule does not already exist (idempotency). This is achieved by checking for an existing rule using a new natural-key lookup before creating a new one (src-tauri/src/import/commands.rs). [1] [2] [3]

Database enhancements:

  • Added find_pf_rule_id_by_natural_key and get_pf_rule methods to HostDb to support natural-key lookup and retrieval of port-forwarding rules, enabling idempotent import and easier rule management (src-tauri/src/db/mod.rs). [1] [2]

Testing and reliability:

  • Added tests to ensure that importing forwards is idempotent (no duplicate tunnels are created on repeated imports) and that the new database methods work as expected (src-tauri/src/db/mod.rs, src-tauri/src/import/commands.rs). [1] [2]

…to-start

Parse LocalForward/RemoteForward/DynamicForward from ~/.ssh/config and
import each as a tunnel bound to the host. Make auto-start actually fire:
tunnels flagged auto_start start when their host connects and stop on the
host's last disconnect, with a global "auto-start by default" setting that
seeds new (and imported) tunnels.

- parser: Local/Remote/Dynamic directives ([bind:]port, [ipv6]:port,
  host:hostport); idempotent re-import via a natural key + host reuse
- backend forwarding: Local + Dynamic (SOCKS5) + Remote (tcpip_forward);
  each tunnel owns its own SSH connection with clean teardown and is
  ProxyJump-aware for Local/Dynamic
- lifecycle: start on connect_saved_host, stop when the host's last
  session disconnects; per-instance teardown guard so a reconnect can't
  let a stale listener clobber the restarted tunnel
- surface bind/start failures as toasts (friendly hint for ports <1024)
- frontend: forward-type selector, type/SOCKS badges, global Settings
  toggle seeding new tunnels' auto_start

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BungeeDEV BungeeDEV force-pushed the feat/ssh-forward-import-autostart branch from 8e8ee5a to 1bbb492 Compare June 16, 2026 02:44
@BungeeDEV BungeeDEV marked this pull request as ready for review June 16, 2026 03:23
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.

1 participant