Compare commits

...
2 Commits
Author SHA1 Message Date
ubuntuandClaude Sonnet 5 0fa98c7283 Read the client IP from X-Real-IP behind the nginx reverse proxy
Since TLS termination moved to nginx, aiohttp's request.remote is
nginx's own address on the docker network (172.21.0.1), a private IP
that resolve_ip_country() correctly refuses to geolocate. Nginx
already forwards the real client address via X-Real-IP
(iptv.mrk.ovh.conf); read that first so device IP/country tracking
works again.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-30 23:29:10 +00:00
ubuntuandClaude Sonnet 5 6881839e31 Fix crashing /init_db and remove dead proxy_image handler
/init_db dropped the channels/playlists collections then crashed on
an undefined `res` variable, so the "Reset DB" button in the UI
always surfaced a 500 even though the wipe had already happened.
proxy_image used aiohttp.ClientSession without importing aiohttp and
was never routed or called from the frontend, so it's just removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-30 23:29:04 +00:00
+6 -15
View File
@@ -440,7 +440,7 @@ async def init_db(request):
db_iptv.drop_collection("channels")
db_iptv.drop_collection("playlists")
return web.Response(text=str(res),content_type='text/html')
return web.json_response({'status': 'ok'})
@@ -1138,19 +1138,6 @@ async def get_logo(request):
return web.Response(body=image_data, content_type="image/jpeg")
async def proxy_image(request):
url = request.query.get("url")
if not url:
return web.Response(status=400, text="Missing URL")
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
if resp.status == 200:
headers = {"Content-Type": resp.headers["Content-Type"]}
return web.Response(body=await resp.read(), headers=headers)
else:
return web.Response(status=resp.status)
async def list_logo(request):
result = logos.find({}).limit(1000)
search_string = "harry potter"
@@ -1475,8 +1462,12 @@ def messageReceived():
def connect(sid, environ):
# engineio's aiohttp integration hardcodes REMOTE_ADDR to 127.0.0.1;
# the real peer address is only available via the underlying aiohttp request.
# Behind the nginx reverse proxy, that peer is nginx itself, so prefer the
# client IP nginx forwards via X-Real-IP (set in iptv.mrk.ovh.conf).
aiohttp_request = environ.get('aiohttp.request')
ip_address = aiohttp_request.remote if aiohttp_request else ''
ip_address = ''
if aiohttp_request:
ip_address = aiohttp_request.headers.get('X-Real-IP') or aiohttp_request.remote or ''
sio_session_ips[sid] = ip_address
print("connect ", sid, ip_address, flush=True)