mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-17 22:36:17 +00:00
15 lines
386 B
Python
15 lines
386 B
Python
from fastapi import Request
|
|
from slowapi import Limiter
|
|
|
|
AUTH_RATE_LIMIT = "5/minute"
|
|
|
|
|
|
def get_real_client_ip(request: Request) -> str:
|
|
forwarded_for = request.headers.get("x-forwarded-for", "")
|
|
if forwarded_for:
|
|
return forwarded_for.split(",")[0].strip()
|
|
return request.client.host if request.client else "unknown"
|
|
|
|
|
|
limiter = Limiter(key_func=get_real_client_ip)
|