Skip to content

Commit 0310192

Browse files
dilyevskyclaude
andcommitted
[tunnel] add CloseConnection method for single connection disconnect
Add CloseConnection(connID string) to TunnelServer that cancels a single tunnel connection by its ID. Used by tunnelproxy's TunnelEndpointReconciler to disconnect agents when their infra Endpoint is externally deleted (GC, manual). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c26d6f2 commit 0310192

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/tunnel/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,15 @@ func (t *TunnelServer) setupConn(
740740
return nil
741741
}
742742

743+
// CloseConnection closes the tunnel connection with the given ID.
744+
// No-op if the connection does not exist.
745+
func (t *TunnelServer) CloseConnection(connID string) {
746+
if c, exists := t.conns.Get(connID); exists {
747+
slog.Info("Closing connection by ID", slog.String("connID", connID))
748+
c.cancel()
749+
}
750+
}
751+
743752
// CloseConnectionsByName closes all active connections for the TunnelNode with the given name.
744753
func (t *TunnelServer) CloseConnectionsByName(name string) {
745754
t.conns.ForEach(func(connID string, c *conn) bool {

0 commit comments

Comments
 (0)