mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-25 11:04:07 +00:00
More refactoring.
This commit is contained in:
parent
8f1c233d64
commit
59245b1401
2 changed files with 14 additions and 9 deletions
|
|
@ -34,4 +34,16 @@ def detect_stream_type(url):
|
|||
return 'hls'
|
||||
|
||||
# Default to TS
|
||||
return 'ts'
|
||||
return 'ts'
|
||||
|
||||
def get_client_ip(request):
|
||||
"""
|
||||
Extract client IP address from request.
|
||||
Handles cases where request is behind a proxy by checking X-Forwarded-For.
|
||||
"""
|
||||
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||
if x_forwarded_for:
|
||||
ip = x_forwarded_for.split(',')[0]
|
||||
else:
|
||||
ip = request.META.get('REMOTE_ADDR')
|
||||
return ip
|
||||
|
|
@ -10,6 +10,7 @@ from apps.proxy.config import TSConfig as Config
|
|||
from . import proxy_server
|
||||
from .channel_status import ChannelStatus
|
||||
from .stream_generator import create_stream_generator
|
||||
from .utils import get_client_ip
|
||||
import logging
|
||||
from apps.channels.models import Channel, Stream
|
||||
from apps.m3u.models import M3UAccount, M3UAccountProfile
|
||||
|
|
@ -21,14 +22,6 @@ from rest_framework.permissions import IsAuthenticated
|
|||
logger = logging.getLogger("ts_proxy")
|
||||
|
||||
|
||||
def get_client_ip(request):
|
||||
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||
if x_forwarded_for:
|
||||
ip = x_forwarded_for.split(',')[0]
|
||||
else:
|
||||
ip = request.META.get('REMOTE_ADDR')
|
||||
return ip
|
||||
|
||||
@api_view(['GET'])
|
||||
def stream_ts(request, channel_id):
|
||||
"""Stream TS data to client with immediate response and keep-alive packets during initialization"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue