Skip to content

Commit

Permalink
Loose http_proxy and https_proxy check
Browse files Browse the repository at this point in the history
  • Loading branch information
wjun committed Jul 19, 2018
1 parent e0dd53e commit 9585be8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/vic-machine/common/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ func (p *Proxies) ProcessProxies() (hproxy, sproxy *url.URL, err error) {
p.IsSet = true
}
if p.HTTPProxy != nil && *p.HTTPProxy != "" {
hproxy, err = url.Parse(*p.HTTPProxy)
if err != nil || hproxy.Host == "" || hproxy.Scheme != "http" {
err = cli.NewExitError(fmt.Sprintf("Could not parse HTTP proxy - expected format http://fqnd_or_ip:port: %s", *p.HTTPProxy), 1)
return
}
p.validate(hproxy, err)
}

if p.HTTPSProxy != nil && *p.HTTPSProxy != "" {
sproxy, err = url.Parse(*p.HTTPSProxy)
if err != nil || sproxy.Host == "" || sproxy.Scheme != "https" {
err = cli.NewExitError(fmt.Sprintf("Could not parse HTTPS proxy - expected format https://fqnd_or_ip:port: %s", *p.HTTPSProxy), 1)
return
}
p.validate(sproxy, err)
}
return
}

func (p *Proxies) validate(proxy *url.URL, err error) {
proxy, err = url.Parse(*p.HTTPProxy)
if err != nil || proxy.Host == "" || (proxy.Scheme != "http" && proxy.Scheme != "https") {
err = cli.NewExitError(fmt.Sprintf("Could not parse HTTP proxy - expected format http(s)://fqnd_or_ip:port: %s", *p.HTTPProxy), 1)
return
}
}

0 comments on commit 9585be8

Please sign in to comment.