MCPcopy Create free account
hub / github.com/cli/cli / Connect

Method Connect

internal/codespaces/connection/connection.go:89–108  ·  view source on GitHub ↗

Connect connects the client to the tunnel.

(ctx context.Context)

Source from the content-addressed store, hash-verified

87
88// Connect connects the client to the tunnel.
89func (c *CodespaceConnection) Connect(ctx context.Context) error {
90 // Lock the mutex to prevent race conditions with the underlying SSH connection
91 c.TunnelClient.mu.Lock()
92 defer c.TunnelClient.mu.Unlock()
93
94 // If already connected, return
95 if c.TunnelClient.connected {
96 return nil
97 }
98
99 // Connect to the tunnel
100 if err := c.TunnelClient.Client.Connect(ctx, ""); err != nil {
101 return fmt.Errorf("error connecting to tunnel: %w", err)
102 }
103
104 // Set the connected flag so we know we're connected
105 c.TunnelClient.connected = true
106
107 return nil
108}
109
110// Close closes the underlying tunnel client SSH connection.
111func (c *CodespaceConnection) Close() error {

Callers 2

ForwardPortMethod · 0.80
UpdatePortVisibilityMethod · 0.80

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected