From a18dceb01c49f4a0fee50b3afda11b5008da3085 Mon Sep 17 00:00:00 2001 From: Goldy <153996346+g0ldyy@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:48:14 +0100 Subject: [PATCH] feat: ability to disable max connection #4 --- comet/api/stream.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/comet/api/stream.py b/comet/api/stream.py index cdf8450..28e8960 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -601,17 +601,17 @@ async def playback(request: Request, b64config: str, hash: str, index: str): and settings.PROXY_DEBRID_STREAM_PASSWORD == config["debridStreamProxyPassword"] ): - active_ip_connections = await database.fetch_all( - "SELECT ip, COUNT(*) as connections FROM active_connections GROUP BY ip" - ) - if any( - connection["ip"] == ip - and connection["connections"] - >= settings.PROXY_DEBRID_STREAM_MAX_CONNECTIONS - and settings.PROXY_DEBRID_STREAM_MAX_CONNECTIONS != -1 - for connection in active_ip_connections - ): - return FileResponse("comet/assets/proxylimit.mp4") + if settings.PROXY_DEBRID_STREAM_MAX_CONNECTIONS != -1: + active_ip_connections = await database.fetch_all( + "SELECT ip, COUNT(*) as connections FROM active_connections GROUP BY ip" + ) + if any( + connection["ip"] == ip + and connection["connections"] + >= settings.PROXY_DEBRID_STREAM_MAX_CONNECTIONS + for connection in active_ip_connections + ): + return FileResponse("comet/assets/proxylimit.mp4") proxy = None