mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-08 07:12:39 +02:00
try: ip fix for cludflare
- Introduced AI File Sorting functionality to automatically organize documents into a smart folder hierarchy based on source, date, and topic. - Updated README.md to include the new feature. - Enhanced homepage components with new illustrations and descriptions for AI File Sorting. - Refactored rate limiting logic to extract real client IPs more accurately.
This commit is contained in:
parent
99995c67b2
commit
2cb30c604d
6 changed files with 143 additions and 12 deletions
|
|
@ -51,12 +51,17 @@ def _get_or_create_session_id(request: Request, response: Response) -> str:
|
|||
|
||||
|
||||
def _get_client_ip(request: Request) -> str:
|
||||
"""Extract the real client IP, preferring Cloudflare's header."""
|
||||
cf_ip = request.headers.get("cf-connecting-ip")
|
||||
if cf_ip:
|
||||
return cf_ip.strip()
|
||||
real_ip = request.headers.get("x-real-ip")
|
||||
if real_ip:
|
||||
return real_ip.strip()
|
||||
forwarded = request.headers.get("x-forwarded-for")
|
||||
return (
|
||||
forwarded.split(",")[0].strip()
|
||||
if forwarded
|
||||
else (request.client.host if request.client else "unknown")
|
||||
)
|
||||
if forwarded:
|
||||
return forwarded.split(",")[0].strip()
|
||||
return request.client.host if request.client else "unknown"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue