fix(api): temporarily use custom client-ip header for ratelimiting
This commit is contained in:
parent
a888e9693b
commit
b2f47f8e53
@ -62,7 +62,7 @@ pub async fn do_request_ratelimited<B>(
|
|||||||
) -> Response {
|
) -> Response {
|
||||||
if let Some(redis) = redis {
|
if let Some(redis) = redis {
|
||||||
let headers = request.headers().clone();
|
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
|
// https://github.com/rust-lang/rust/issues/53667
|
||||||
let (rl_key, rate) = if let Some(header) = request.headers().clone().get("X-PluralKit-App")
|
let (rl_key, rate) = if let Some(header) = request.headers().clone().get("X-PluralKit-App")
|
||||||
|
@ -37,6 +37,9 @@ func (p ProxyHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.Header.Del("X-PluralKit-Client-IP")
|
||||||
|
r.Header.Set("X-PluralKit-Client-IP", r.Header.Get("Fly-Client-IP"))
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
r = r.WithContext(context.WithValue(r.Context(), "req-time", startTime))
|
r = r.WithContext(context.WithValue(r.Context(), "req-time", startTime))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user