12 Commits

Author SHA1 Message Date
18eec1f5cb
chore(release): update .goreleaser.yaml for cmd/tcpfwd 2026-03-01 00:29:33 -07:00
fc9f070285
chore(cmd/tcpfwd): update .goreleaser.yaml for monorepo 2026-03-01 00:22:44 -07:00
115efc0afb
chore(cmd/tcpfwd): goreleaser init 2026-03-01 00:18:32 -07:00
0762e64857
chore(cmd/tcpfwd): add go.mod (for git-tag-based releases) 2026-02-27 23:50:37 -07:00
d30ceb004d
chore(cmd/tcpfwd): minor cleanup, add license, lint 2026-02-27 23:35:00 -07:00
3e4ce3ac91
ref(cmd/tcpfwd): extract waitWithTimeout to simplify shutdown block
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 22:52:07 -07:00
0d356c0b26
feat(cmd/tcpfwd): add description to version/help output
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 22:16:49 -07:00
f9e06f131b
ref(cmd/tcpfwd): simplify parseForward with strings.Cut
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 22:13:10 -07:00
3f16e89f5c
ref(cmd/tcpfwd): remove implicit time.Now() for testability
- connEntry.isIdle(now, threshold): caller supplies now instead of time.Since
- connRegistry.closeIdle(now, threshold): passes now through to isIdle
- trackingConn gains a clock func() time.Time field used in Read/Write
- handleConn takes clock func() time.Time; uses it to init lastRead/lastWrite
  and passes it to trackingConn
- Call sites in main pass time.Now or time.Now() explicitly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 22:08:56 -07:00
89f6e04516
feat(cmd/tcpfwd): add graceful shutdown with idle connection tracking
On SIGINT/SIGTERM:
- Stop accepting new connections
- Close connections idle longer than --idle-timeout (default 5s),
  determined by LastRead/LastWrite timestamps tracked per connection pair
- Wait for active connections to drain up to --shutdown-timeout (default 30s)
- Force-close any remaining connections if the timeout is exceeded

Also switches isClosedConn to use errors.Is(err, net.ErrClosed) and
exits the accept loop cleanly when a listener is closed during shutdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 22:05:04 -07:00
b08525b024
feat(cmd/tcpfwd): add multi-forward positional args and version/help
Accept any number of local-port:remote-host:remote-port forwards as
positional arguments. Backward-compatible with existing --port/--target
flags. Adds --version/-V/version and --help/help handling matching the
auth-proxy pattern, including printVersion printed to stderr at startup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 21:54:51 -07:00
ec64afe390
feat: add tcpfwd to pipe connections 2026-02-27 21:25:33 -07:00