Replace base64 encoding with random uuid

This commit is contained in:
Manuel de Brito Fontes 2017-08-22 09:33:56 -03:00
parent def5155aa6
commit c4fc497646
2 changed files with 5 additions and 4 deletions

View file

@ -342,8 +342,7 @@ var (
func buildWhitelistVariable(s string) string { func buildWhitelistVariable(s string) string {
if _, ok := whitelistVarMap[s]; !ok { if _, ok := whitelistVarMap[s]; !ok {
str := base64.URLEncoding.EncodeToString([]byte(s)) whitelistVarMap[s] = fmt.Sprintf("whitelist_%v", uuid.New())
whitelistVarMap[s] = strings.Replace(str, "=", "", -1)
} }
return whitelistVarMap[s] return whitelistVarMap[s]

View file

@ -289,13 +289,15 @@ http {
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if ne $location.RateLimit.Name "" }} {{ if ne $location.RateLimit.Name "" }}
geo ${{ buildWhitelistVariable $location.RateLimit.Name }}_whitelist { # Ratelimit {{ $location.RateLimit.Name }}
geo $whitelist_{{ buildWhitelistVariable $location.RateLimit.Name }} {
default 0; default 0;
{{ range $ip := $location.RateLimit.Whitelist }} {{ range $ip := $location.RateLimit.Whitelist }}
{{ $ip }} 1;{{ end }} {{ $ip }} 1;{{ end }}
} }
map ${{ buildWhitelistVariable $location.RateLimit.Name }}_whitelist ${{ buildWhitelistVariable $location.RateLimit.Name }}_limit { # Ratelimit {{ $location.RateLimit.Name }}
map $whitelist_{{ buildWhitelistVariable $location.RateLimit.Name }} ${{ buildWhitelistVariable $location.RateLimit.Name }}_limit {
0 {{ $cfg.LimitConnZoneVariable }}; 0 {{ $cfg.LimitConnZoneVariable }};
1 ""; 1 "";
} }