Skip to content

Commit

Permalink
Revert "ssh: Recreate connection on retries in setupProxy"
Browse files Browse the repository at this point in the history
This reverts commit feda120.
  • Loading branch information
cfergeau committed Jan 16, 2024
1 parent feda120 commit 069c36e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/sshclient/ssh_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ func setupProxy(ctx context.Context, socketURI *url.URL, dest *url.URL, identity
return conn, err
}

conn, err := initialConnection(ctx, connectFunc)
if err != nil {
return &SSHForward{}, err
}

createBastion := func() (*Bastion, error) {
conn, err := connectFunc(ctx, nil)
if err != nil {
return nil, err
}
return CreateBastion(dest, passphrase, identity, conn, connectFunc)
}
bastion, err := retry(ctx, createBastion, "Waiting for sshd")
Expand Down Expand Up @@ -214,6 +215,13 @@ loop:
return returnVal, fmt.Errorf("timeout: %w", err)
}

func initialConnection(ctx context.Context, connectFunc ConnectCallback) (net.Conn, error) {
retryFunc := func() (net.Conn, error) {
return connectFunc(ctx, nil)
}
return retry(ctx, retryFunc, "Waiting for sshd socket")
}

func acceptConnection(ctx context.Context, listener net.Listener, bastion *Bastion, socketURI *url.URL) error {
con, err := listener.Accept()
if err != nil {
Expand Down

0 comments on commit 069c36e

Please sign in to comment.