File-Tunnel/ft/Commands
fiddyschmitt 0b97eed490 Add SOCKS dynamic forwarding (-D and -R), like SSH
Adds ft equivalents of SSH's dynamic forwarding: -D [bind:]port opens a
local SOCKS proxy (the remote side dials each destination), and a bare
-R [bind:]port (no destination) opens one on the remote side (the local
side dials). Supports the same surface modern OpenSSH implements: SOCKS4,
SOCKS4a and SOCKS5; CONNECT only; no authentication; no BIND or UDP
ASSOCIATE.

A new SocksServer performs the per-connection handshake and produces a
tcp://host:port destination that flows through the existing Connect/relay
path unchanged - so hostnames (SOCKS4a/5) and IPv6 resolve on the exit
side, exactly like SSH. -R rides the existing CreateListener command via
a "socks" protocol sentinel and a listen-spec partition in
ProvideRemoteForwardsToCounterpart.

SOCKS replies carry accurate result codes. Since ft had no positive
per-connection dial signal, a new ConnectResult command (id 12) reports
the outcome (SocketError mapped to a SOCKS reply code) from the dialing
side back to the SOCKS host, which blocks until it arrives before
answering its client. The reply is written before any relaying so it is
the first thing the client sees. No existing wire command changed; -L/-U
behaviour is untouched.

Tested hermetically (SOCKS4/4a/5 negotiator byte-level tests, listen-spec
parsing, ConnectResult serialization, and in-process end-to-end -D/-R
transfers incl. far-side resolution and an accurate-failure-reply case)
and verified with a real curl client in both directions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SjajJ7d3BhSZGfsMrGRS5S
2026-07-23 21:00:08 +10:00
..
Command.cs Add SOCKS dynamic forwarding (-D and -R), like SSH 2026-07-23 21:00:08 +10:00
Connect.cs Forwards are now provided using SSH-style args 2024-08-08 23:32:12 +10:00
ConnectResult.cs Add SOCKS dynamic forwarding (-D and -R), like SSH 2026-07-23 21:00:08 +10:00
CreateListener.cs Add remote forwarding 2024-08-14 19:08:59 +10:00
Forward.cs Bound and EOF-guard Forward payload deserialization 2026-07-06 22:56:21 +10:00
Ping.cs Display if counterpart is online or offline 2024-05-27 21:03:11 +10:00
Purge.cs Display if counterpart is online or offline 2024-05-27 21:03:11 +10:00
TearDown.cs Display if counterpart is online or offline 2024-05-27 21:03:11 +10:00