Refactor X-Forwarded-* headers
This commit is contained in:
parent
f478084cd8
commit
f38f49e770
5 changed files with 85 additions and 15 deletions
|
|
@ -19,6 +19,7 @@ package template
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
|
@ -37,6 +38,10 @@ const (
|
|||
bindAddress = "bind-address"
|
||||
)
|
||||
|
||||
var (
|
||||
realClientRegex = regexp.MustCompile(`auto|http-proxy|tcp-proxy`)
|
||||
)
|
||||
|
||||
// ReadConfig obtains the configuration defined by the user merged with the defaults.
|
||||
func ReadConfig(src map[string]string) config.Configuration {
|
||||
conf := map[string]string{}
|
||||
|
|
@ -119,6 +124,11 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
glog.Warningf("unexpected error merging defaults: %v", err)
|
||||
}
|
||||
|
||||
if !realClientRegex.MatchString(to.RealClientFrom) {
|
||||
glog.Warningf("unexpected value for RealClientFromSetting (%v). Using default \"auto\"", to.RealClientFrom)
|
||||
to.RealClientFrom = "auto"
|
||||
}
|
||||
|
||||
return to
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue