mirror of
https://github.com/Viren070/MediaFusion.git
synced 2025-12-01 23:21:11 +01:00
add user IP to RealDebrid POST requests
This commit is contained in:
+1
-17
@@ -11,23 +11,7 @@ from starlette.routing import Match
|
||||
from db.config import settings
|
||||
from db.schemas import UserData
|
||||
from utils import crypto, const
|
||||
|
||||
|
||||
def get_client_ip(request: Request) -> str | None:
|
||||
"""
|
||||
Extract the client's real IP address from the request headers or fallback to the client host.
|
||||
"""
|
||||
x_forwarded_for = request.headers.get("X-Forwarded-For")
|
||||
if x_forwarded_for:
|
||||
# In some cases, this header can contain multiple IPs
|
||||
# separated by commas.
|
||||
# The first one is the original client's IP.
|
||||
return x_forwarded_for.split(",")[0].strip()
|
||||
# Fallback to X-Real-IP if X-Forwarded-For is not available
|
||||
x_real_ip = request.headers.get("X-Real-IP")
|
||||
if x_real_ip:
|
||||
return x_real_ip
|
||||
return request.client.host if request.client else "Unknown"
|
||||
from utils.network import get_client_ip
|
||||
|
||||
|
||||
async def find_route_handler(app, request: Request) -> Optional[Callable]:
|
||||
|
||||
Reference in New Issue
Block a user