This commit is contained in:
jr-k 2024-06-13 19:58:16 +02:00
parent 1b37d5f074
commit 515d56509c
2 changed files with 5 additions and 7 deletions

View File

@ -6,7 +6,7 @@ from flask import Flask, render_template, redirect, request, url_for, send_from_
from src.service.ModelStore import ModelStore
from src.interface.ObController import ObController
from src.util.utils import get_safe_cron_descriptor
from src.util.UtilNetwork import get_ip_address, host_to_safe_ipaddr
from src.util.UtilNetwork import get_ip_address, get_safe_remote_addr
from src.model.enum.AnimationSpeed import animation_speed_duration
@ -90,7 +90,7 @@ class PlayerController(ObController):
def _get_dynamic_playlist_id(self, playlist_slug_or_id: Optional[str]) -> str:
if not playlist_slug_or_id and self._model_store.variable().get_one_by_name('fleet_player_enabled'):
node_player = self._model_store.node_player().get_one_by("host = '{}' and enabled = {}".format(
host_to_safe_ipaddr(request.headers.getlist("Host")[0]),
get_safe_remote_addr(request.remote_addr),
True
))

View File

@ -35,9 +35,7 @@ def get_ip_address() -> Optional[str]:
return get_network_ipaddr()
def host_to_safe_ipaddr(host: str) -> str:
host = host.split(':')[0]
if host == '127.0.0.1' or host == 'localhost':
def get_safe_remote_addr(remote_addr: str) -> str:
if remote_addr == '127.0.0.1' or remote_addr == 'localhost':
return get_ip_address()
return host
return remote_addr