Skip to content

Commit

Permalink
Fix backend misusage
Browse files Browse the repository at this point in the history
Fix a bug that could lead to using only the last backend for all
hostnames due to variable redefining.

See https://play.golang.org/p/yjiEENusQs as an illustration
  • Loading branch information
Artyom Pervukhin committed Jul 15, 2016
1 parent d14c25f commit fba2586
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions leproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func setProxy(mapping map[string]string) (http.Handler, error) {
}
mux := http.NewServeMux()
for hostname, backendAddr := range mapping {
hostname, backendAddr := hostname, backendAddr // intentional shadowing
if strings.ContainsRune(hostname, os.PathSeparator) {
return nil, fmt.Errorf("invalid hostname: %q", hostname)
}
Expand Down

0 comments on commit fba2586

Please sign in to comment.