Skip to content

Commit

Permalink
Revert "Establish socks proxy if BOSH_ALL_PROXY set"
Browse files Browse the repository at this point in the history
This reverts commit b01c84c.

We tried to revert both commits (b01c84c and d106c15) in the previous
commit, but only reverted d106c15.

[#157779432]
  • Loading branch information
Josh Hill committed May 30, 2018
1 parent 13af7df commit 07e0806
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions ssh/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import (

"strings"

"log"
"net"
"os"

boshhttp "github.com/cloudfoundry/bosh-utils/httpclient"
"github.com/cloudfoundry/socks5-proxy"
"github.com/pkg/errors"
"golang.org/x/crypto/ssh"
)
Expand Down Expand Up @@ -105,29 +99,8 @@ func (w *sessionClosingOnErrorWriter) Write(data []byte) (int, error) {
return n, err
}

func (c Connection) getConnection() (*ssh.Client, error) {
dialFunc := net.Dial

if os.Getenv("BOSH_ALL_PROXY") != "" {
socksProxy := proxy.NewSocks5Proxy(proxy.NewHostKey(), log.New(os.Stdout, "sock5-proxy", log.LstdFlags))
dialFunc = boshhttp.SOCKS5DialFuncFromEnvironment(net.Dial, socksProxy)
}

conn, err := dialFunc("tcp", c.host)
if err != nil {
return nil, err
}

client, chans, reqs, err := ssh.NewClientConn(conn, c.host, c.sshConfig)
if err != nil {
return nil, err
}

return ssh.NewClient(client, chans, reqs), nil
}

func (c Connection) runInSession(cmd string, stdout, stderr io.Writer, stdin io.Reader) (int, error) {
connection, err := c.getConnection()
connection, err := ssh.Dial("tcp", c.host, c.sshConfig)
if err != nil {
return -1, errors.Wrap(err, "ssh.Dial failed")
}
Expand Down

0 comments on commit 07e0806

Please sign in to comment.