Skip to content

Commit

Permalink
Run ssh.Dial outside of the go-routine, in order to print a much nice…
Browse files Browse the repository at this point in the history
…r error message in case things go wrong.

For example, "could not dial: dial tcp: lookup bastion.example.com: no such host", instead of a huge stack trace.
  • Loading branch information
stefansundin committed May 30, 2019
1 parent e7954a9 commit 8385526
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions data_source_ssh_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ func dataSourceSSHTunnelRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] port: %v", port)
d.Set("port", port)

go func() {
sshClientConn, err := ssh.Dial("tcp", host, sshConf)
if err != nil {
panic(err)
}
sshClientConn, err := ssh.Dial("tcp", host, sshConf)
if err != nil {
return fmt.Errorf("could not dial: %v", err)
}

go func() {
// The accept loop
for {
localConn, err := localListener.Accept()
Expand Down

0 comments on commit 8385526

Please sign in to comment.