fix(api): temporarily use custom client-ip header for ratelimiting

This commit is contained in:
spiral 2023-03-19 14:17:03 -04:00
parent a888e9693b
commit b2f47f8e53
2 changed files with 4 additions and 1 deletions
services
api/src/middleware
web-proxy

View File

@ -62,7 +62,7 @@ pub async fn do_request_ratelimited<B>(
) -> Response {
if let Some(redis) = redis {
let headers = request.headers().clone();
let source_ip = header_or_unknown(headers.get("Fly-Client-IP"));
let source_ip = header_or_unknown(headers.get("X-PluralKit-Client-IP"));
// https://github.com/rust-lang/rust/issues/53667
let (rl_key, rate) = if let Some(header) = request.headers().clone().get("X-PluralKit-App")

View File

@ -37,6 +37,9 @@ func (p ProxyHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return
}
r.Header.Del("X-PluralKit-Client-IP")
r.Header.Set("X-PluralKit-Client-IP", r.Header.Get("Fly-Client-IP"))
startTime := time.Now()
r = r.WithContext(context.WithValue(r.Context(), "req-time", startTime))