From 84fbbfa3c4c5d22478229ab366f6b004287deb14 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sat, 9 May 2026 09:48:53 -0500 Subject: [PATCH] refactor: Clean up get_client_ip() function in utils.py --- CHANGELOG.md | 1 + dispatcharr/utils.py | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 670e3360..c071d05a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **`get_client_ip()` in `dispatcharr/utils.py` cleaned up.** Removed dead `.split(',')[0]` call and misleading variable name left over from a copy-paste of the `X-Forwarded-For` pattern. `X-Real-IP` is always a single IP (set by nginx from `$remote_addr`), so no splitting is needed. Behavior is unchanged. - **`ts_proxy` module refactored and renamed to `live_proxy`.** The live-streaming proxy was reorganized into a structured package (`apps/proxy/live_proxy/`) with explicit submodules for each stage of the pipeline: `input/` (HTTP streamer, stream manager, TS ring buffer), `output/ts/` (MPEG-TS client generator), `output/fmp4/` (fMP4 remux manager, Redis buffer, client generator), and `output/profile/` (output profile transcode manager). A dedicated `redis_keys.py` module centralizes all Redis key name construction for the proxy. Existing behavior for MPEG-TS clients is unchanged. - **XC API `allowed_output_formats` now includes `mp4`.** The `user_info` block returned by `player_api.php` and `get.php` previously advertised only `["ts"]`. It now advertises `["ts", "mp4"]` for all users, enabling XC-compatible clients that support fMP4 to request `.mp4` stream URLs which are proxied as fMP4. - **Browser preview URLs always force `mpegts` output.** The four in-app preview buttons (Channels table, channel stream list, Streams table, Stats client row) now append `?output_format=mpegts` (and the web player profile, if set) to the preview URL so the built-in `mpegts.js` player always receives a compatible stream, regardless of the user's configured default output format. diff --git a/dispatcharr/utils.py b/dispatcharr/utils.py index 02fe7853..c31e56e0 100644 --- a/dispatcharr/utils.py +++ b/dispatcharr/utils.py @@ -29,13 +29,7 @@ def validate_logo_file(file): def get_client_ip(request): - x_forwarded_for = request.META.get("HTTP_X_REAL_IP") - if x_forwarded_for: - # X-Forwarded-For can be a comma-separated list of IPs - ip = x_forwarded_for.split(",")[0].strip() - else: - ip = request.META.get("REMOTE_ADDR") - return ip + return request.META.get("HTTP_X_REAL_IP") or request.META.get("REMOTE_ADDR") def network_access_allowed(request, settings_key, user=None):