Skip to content

Commit 50e7e3c

Browse files
committed
Detach tsnet cancellation from SSH server termination
Shutting down the tsnet interface at the same time as the SSH server results in connected clients not getting the notification that their connection was terminated. So, create a child context for the tsnet service that doesn't cancel immediately; instead, set it up with its own cancellation handler that gets invoked once the SSH server is shut down.
1 parent 03e82d0 commit 50e7e3c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ssh.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ func (s *TailnetSSH) Run(ctx context.Context) error {
8585
return fmt.Errorf("could not setup a tsnet server: %w", err)
8686
}
8787

88-
_, err = srv.Up(ctx)
88+
// Do not shut down the tsnet server as soon as we're meant
89+
// to close client connections; it shuts down after the
90+
// SSH server terminates.
91+
netCtx := context.WithoutCancel(ctx)
92+
_, err = srv.Up(netCtx)
8993
if err != nil {
9094
return fmt.Errorf("could not connect to tailnet: %w", err)
9195
}

0 commit comments

Comments
 (0)