fix(multiplayer): resolve client IP behind proxies

This commit is contained in:
Josh Creek
2026-09-02 19:08:34 +01:00
parent d59e0017f7
commit 6ebd6e59c1
7 changed files with 166 additions and 8 deletions
+2 -1
View File
@@ -127,6 +127,7 @@ type Service struct {
RankedProfileProvider RankedProfileProvider
TierPolicy domain.TierPolicy
RateLimiter *RateLimiter
ClientIPs *ClientIPResolver
Admission AdmissionController
// Log receives a credential-safe structured event for lifecycle-relevant
// reads and mutations. Nil
@@ -207,7 +208,7 @@ func (s *Service) Handler() http.Handler {
var handler http.Handler = mux
if s.RateLimiter != nil {
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !s.RateLimiter.AllowKeys(requestRateKeys(r), s.now()) {
if !s.RateLimiter.AllowKeys(requestRateKeys(r, s.ClientIPs), s.now()) {
writeError(w, http.StatusTooManyRequests, "rate_limited")
return
}