From 84301e9c2328acf4ced2012afa7b89ddcbce4ec3 Mon Sep 17 00:00:00 2001 From: leonarliu Date: Wed, 26 Oct 2022 15:31:11 +0800 Subject: [PATCH] feat(platform): ssh suport use env proxy --- pkg/util/ssh/ssh.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/util/ssh/ssh.go b/pkg/util/ssh/ssh.go index 48afe860c..6ab14d462 100644 --- a/pkg/util/ssh/ssh.go +++ b/pkg/util/ssh/ssh.go @@ -34,6 +34,7 @@ import ( "github.com/pkg/sftp" "github.com/segmentio/ksuid" "golang.org/x/crypto/ssh" + "golang.org/x/net/proxy" "gopkg.in/go-playground/validator.v9" "k8s.io/apimachinery/pkg/util/wait" "tkestack.io/tke/pkg/util/log" @@ -433,7 +434,8 @@ type realSSHDialer struct{} var _ sshDialer = &realSSHDialer{} func (d *realSSHDialer) Dial(network, addr string, config *ssh.ClientConfig) (*ssh.Client, error) { - conn, err := net.DialTimeout(network, addr, config.Timeout) + dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: config.Timeout}) + conn, err := dialer.Dial(network, addr) if err != nil { return nil, err }