use fallback if not x-forwarded-for is present

This commit is contained in:
2022-05-17 23:47:24 +02:00
parent 2300d740d2
commit b8b9f82067
2 changed files with 9 additions and 2 deletions

View File

@@ -815,3 +815,11 @@ func PlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, rl *r
return nPlayers, nil
}
func RealIP(header *http.Header, fallback string) string {
if header.Get("X-Forwarded-For") != "" {
return header.Get("X-Forwarded-For")
} else {
return fallback
}
}