diff --git a/README.md b/README.md index 380228f..85ef0b0 100644 --- a/README.md +++ b/README.md @@ -133,13 +133,19 @@ dig clients.plex.tv +short dig plex.tv +short # 52.17.59.150 # 52.49.56.127 + +dig features.plex.tv +short +# global-latency.plex.bz. -> we can ignore this one it points to the 3 IPs below +# 34.246.123.195 +# 52.210.35.163 +# 54.216.30.15 ``` Then go into `Firewall` > `Aliases` and create two aliases: - `plex_ips` - Type: Host(s) - - Content: + - Content: - `plex_do_not_proxy` - Type: Host(s) - Content: and @@ -168,7 +174,7 @@ Finally go to `Firewall` > `NAT` > `Outbound` and create a new rule *(select Hyb ##### Test the redirection -Now if you try to go to `https://clients.plex.tv/api/hack` you should see a JSON response along the lines of : +Now if you try to go to `https://clients.plex.tv/proxy` you should see a JSON response along the lines of : ```json { diff --git a/main_app.py b/main_app.py index a025625..83ac1ef 100644 --- a/main_app.py +++ b/main_app.py @@ -1,13 +1,13 @@ import xml.etree.ElementTree as ET from urllib.parse import parse_qs -from fastapi import FastAPI, Request, HTTPException +from fastapi import FastAPI, Request from starlette.responses import FileResponse from const import FEATURES_DICT, ENTITLEMENTS, CURRENT_DATE_MINUS_ONE_DAY, FEATURES, \ CURRENT_DATE_MINUS_ONE_DAY_Z, NEXT_MONTH_DATE_Z, PLEXAMP_FEATURES, TIMESTAMP_CURRENT_PLUS_30DAYS, \ TIMESTAMP_CURRENT_MINUS_30MIN, PLEXAMP_SUBSCRIPTION_XML, Hosts -from utils import call_official, return_edited_response, host_required +from utils import call_official, return_edited_response, host_required, fake_response app = FastAPI() @@ -241,8 +241,9 @@ async def fake_list_user_webhooks(request: Request, _=host_required([Hosts.CLIEN @app.post("/v1/rgstr", tags=[Hosts.FEATURES.value]) @app.options("/v1/rgstr", tags=[Hosts.FEATURES.value]) @app.post("/collect/event", tags=[Hosts.ANALYTICS.value]) -async def fake_initialize(request: Request, _=host_required([Hosts.FEATURES])): - raise HTTPException(status_code=200, detail="Features/analytics data collection disabled by proxy") +@app.options("/collect/event", tags=[Hosts.ANALYTICS.value]) +async def block_telemetry(): + return fake_response({"status": "disabled by proxy :)"}, status_code=200) @app.get("/favicon.ico") diff --git a/utils.py b/utils.py index e20fa91..6a9fe73 100644 --- a/utils.py +++ b/utils.py @@ -101,3 +101,16 @@ async def return_edited_response( headers=response.headers, media_type=content_type ) + + +def fake_response(content: dict | None = None, status_code: int = 200) -> Response: + headers = { + "Access-Control-Allow-Origin": "*", # request.headers["origin"] + "Access-Control-Allow-Methods": "POST, OPTIONS", + "Access-Control-Allow-Headers": "*", + } + + if content is None: + return Response(status_code=status_code, headers=headers) + + return JSONResponse(content=content, status_code=status_code, headers=headers)