1
0
mirror of https://github.com/rancher/rke.git synced 2025-04-27 11:21:08 +00:00

Unset proxy env vars when ssh bastion is configured with option ignore_proxy_env_vars

This commit is contained in:
Pascal Morillon 2021-05-31 16:49:01 +02:00
parent a21294e915
commit 8b9385040f
2 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"reflect"
"strings"
"time"
@ -778,6 +779,12 @@ func (c *Cluster) SetupDialers(ctx context.Context, dailersOptions hosts.Dialers
if err != nil {
return err
}
if c.BastionHost.IgnoreProxyEnvVars {
logrus.Debug("Unset http proxy environment variables")
for _, v := range util.ProxyEnvVars {
os.Unsetenv(v)
}
}
}
return nil
}

View File

@ -20,7 +20,7 @@ const (
WorkerThreads = 50
)
var proxyEnvVars = [3]string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
var ProxyEnvVars = [3]string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
func StrToSemVer(version string) (*semver.Version, error) {
v, err := semver.NewVersion(strings.TrimPrefix(version, "v"))
@ -146,7 +146,7 @@ func GetEnvVar(key string) (string, string, bool) {
func PrintProxyEnvVars() {
// Print proxy related environment variables
for _, proxyEnvVar := range proxyEnvVars {
for _, proxyEnvVar := range ProxyEnvVars {
var err error
// Lookup environment variable
if key, value, ok := GetEnvVar(proxyEnvVar); ok {