Skip to content

feat(forward): ForwardTracker Protocol for local-forward lifecycle hooks#807

Open
AlexMKX wants to merge 1 commit into
ronf:developfrom
AlexMKX:feat/forward-tracker
Open

feat(forward): ForwardTracker Protocol for local-forward lifecycle hooks#807
AlexMKX wants to merge 1 commit into
ronf:developfrom
AlexMKX:feat/forward-tracker

Conversation

@AlexMKX
Copy link
Copy Markdown

@AlexMKX AlexMKX commented May 21, 2026

Adds optional tracker kwarg to SSHClientConnection.forward_local_port that accepts a ForwardTracker (typing.Protocol) with two hooks:

connection_made(orig_host, orig_port) -> None
connection_lost(orig_host, orig_port, exc) -> None

The hooks fire on every client connect/disconnect on the local listener. Hook exceptions are swallowed so a buggy tracker cannot break the forwarder.

Backward compatible: tracker defaults to None, preserving existing behavior with no overhead.

Use case: passive observation of local-forward activity (idle-based auto-shutdown, byte counters, etc.) without modifying transport code.

Adds optional tracker kwarg to SSHClientConnection.forward_local_port
that accepts a ForwardTracker (typing.Protocol) with two hooks:

  connection_made(orig_host, orig_port) -> None
  connection_lost(orig_host, orig_port, exc) -> None

The hooks fire on every client connect/disconnect on the local
listener. Hook exceptions are swallowed so a buggy tracker cannot
break the forwarder.

Backward compatible: tracker defaults to None, preserving existing
behavior with no overhead.

Use case: passive observation of local-forward activity (idle-based
auto-shutdown, byte counters, etc.) without modifying transport code.
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