Reverse forwarding (-R) + event-driven migration detection - #11
Merged
Conversation
added 2 commits
June 18, 2026 19:08
Replace the 2s routing-table poll with OS routing events (Linux NETLINK_ROUTE multicast, macOS PF_ROUTE), debounced to one rebind check per burst. Events are only a trigger; source_ip_for stays the decision. run()'s signature is unchanged, so supervisor.rs is untouched. Any unsupported platform or socket-setup failure falls back to polling.
Expose a local service on the remote: the agent binds a remote listener and opens a QUIC stream back to the client for each connection, which the client dials to a local target and splices. - forward.rs: ReverseSpec grammar [NS@][BINDADDR:]REMOTEPORT->[HOST:]LOCALPORT - conn.rs: Conn::accept_bi (QUIC; errors on --via-ssh) - reverse.rs: agent-side remote bind + stream-back; client ReverseSet + per-epoch registration over an @reverse control stream, reusing the discovery convention and the forward health model - agent.rs: thread the Connection into stream dispatch for open-bi-back - cli/control/config/main/tui: -R flag, AddReverse/DropReverse, persisted reverse_forwards, dimmed reverse rows in the TUI table - QUIC-only in v1; reverse over --via-ssh is rejected with a clear message Tests: reverse e2e + reverse reconnect (loopback), ReverseSpec parse/ roundtrip, control JSON roundtrip + legacy back-compat.
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.
Builds out two features on top of the TUI/SOCKS/via-ssh work.
1. Event-driven migration detection (
netwatchv2)Replaces the 2s routing-table poll with OS routing events — Linux
NETLINK_ROUTEmulticast, macOSPF_ROUTE— hand-rolled overnix::libc+tokio::AsyncFd(no new dependency). The event is only a trigger;source_ip_forstays the decision, so the rebind logic andnetwatch::run's signature are unchanged (supervisor untouched). Debounced to one rebind check per burst; any unsupported platform or socket-setup failure falls back to the original poll.2. Reverse forwarding (
-R, thessh -Requivalent)Expose a local service on the remote: the agent binds a remote listener and opens a QUIC stream back to the client for each connection, which the client dials to a local target and splices.
forward.rs):ReverseSpec=[NS@][BINDADDR:]REMOTEPORT->[HOST:]LOCALPORT, reusing existing parse helpers.reverse.rs,conn.rs,agent.rs): reuses the discovery convention — the client registers reverse forwards over an@reversecontrol stream; the agent binds remote listeners and opens streams back via the newConn::accept_bi. No wire-version bump.cli/control/config/main/tui):-Rlaunch flag,add/drop --reverse,list/statusoutput, persistedreverse_forwards, dimmed← R:<port>rows in the TUI, per-epoch re-registration across reconnects.--via-sshwith a clear message; remote bind in a namespace is deferred.Tests / CI parity
ReverseSpecparse/roundtrip; control-protocol JSON roundtrip incl. legacy back-compat;netwatchsource_ip_for+ debounce units.cargo fmt --check,cargo clippy --all-targets -D warnings, full test suite, and the Linux musl cross-build (netlink path) all pass.Not covered
Manual smoke test against a real SSH host (
portmanager myhost -R 3000->3000) and observing a real interface-toggle migration event — both need a live host/interface and are left to manual verification.