From 690c2a1e5fd462aaba1c32f48e99c2228087c820 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sat, 1 Apr 2023 22:56:49 +0000 Subject: [PATCH] Account for forwarding in IP address for rate limiting --- server/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/main.go b/server/main.go index 55f6234..89f4da4 100644 --- a/server/main.go +++ b/server/main.go @@ -270,6 +270,9 @@ func completion(w http.ResponseWriter, req *http.Request) { // where I do the IP rate limiting userKey := req.RemoteAddr + if req.Header.Get("X-Forwarded-For") != "" { + userKey = req.Header.Get("X-Forwarded-For") + } createdTime, ok := ipAddyTenFree[userKey] if !ok { ipAddyTenFree[userKey] = currentTime()