fixed data collection "disabling"

This commit is contained in:
Mathieu Broillet 2025-08-28 15:38:59 +02:00
parent 3bee2790a4
commit 240094d741
Signed by: mathieub
GPG Key ID: 4428608CDA3A98D3
3 changed files with 26 additions and 6 deletions

View File

@ -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: <the 4 IPs you found above>
- Content: <the IPs you found above>
- `plex_do_not_proxy`
- Type: Host(s)
- Content: <your plex server IP> and <your proxy server IP>
@ -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
{

View File

@ -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")

View File

@ -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)