Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 8c5bc75

Browse files
committed
Merge pull request #345 from databus23/no_proxy_env
add NO_PROXY variable to shellinit with boot2docker ip
2 parents 0a3a250 + 59c644f commit 8c5bc75

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

cmds.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,30 @@ func exports(socket, certPath string) map[string]string {
228228
out["DOCKER_TLS_VERIFY"] = "1"
229229
}
230230

231+
//if a http_proxy is set, we need to make sure the boot2docker ip
232+
//is added to the NO_PROXY environment variable
233+
if os.Getenv("http_proxy") != "" || os.Getenv("HTTP_PROXY") != "" {
234+
//get the ip from socket/DOCKER_HOST
235+
re := regexp.MustCompile("tcp://([^:]+):")
236+
if matches := re.FindStringSubmatch(socket); len(matches) == 2 {
237+
ip := matches[1]
238+
name := "no_proxy"
239+
val := os.Getenv("no_proxy")
240+
if val == "" {
241+
name = "NO_PROXY"
242+
val = os.Getenv("NO_PROXY")
243+
}
244+
245+
switch {
246+
case val == "":
247+
out[name] = ip
248+
case strings.Contains(val, ip):
249+
out[name] = val
250+
default:
251+
out[name] = fmt.Sprintf("%s,%s", val, ip)
252+
}
253+
}
254+
}
231255
return out
232256
}
233257

0 commit comments

Comments
 (0)