mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-17 21:58:22 +03:00
fix: handle missing x-forwarded-for header in get_remote_addr
When accessing Frigate directly without a reverse proxy, the x-forwarded-for header is absent. Calling .split() on the None return value from headers.get() raises AttributeError, crashing the rate limiter on every login attempt. Fall back to request.remote_addr when the header is missing.
This commit is contained in:
parent
722ef6a1fe
commit
35d4fc1433
@ -244,7 +244,12 @@ rateLimiter = RateLimiter()
|
||||
|
||||
|
||||
def get_remote_addr(request: Request):
|
||||
route = list(reversed(request.headers.get("x-forwarded-for").split(",")))
|
||||
forwarded_for = request.headers.get("x-forwarded-for")
|
||||
if forwarded_for is None:
|
||||
if hasattr(request, "remote_addr"):
|
||||
return request.remote_addr or "127.0.0.1"
|
||||
return "127.0.0.1"
|
||||
route = list(reversed(forwarded_for.split(",")))
|
||||
logger.debug(f"IP Route: {[r for r in route]}")
|
||||
trusted_proxies = []
|
||||
for proxy in request.app.frigate_config.auth.trusted_proxies:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user