Private
Public Access
Minamp 1.3
- Fix NoSuchMethodError on Android 2.x: Dalvik before 4.0 can't link Object methods (toString/equals/...) called through an interface. Patch the bundled Bouncy Castle (tools/patch_bc_dalvik.py) and our own CertVerifier, and make build.sh fail if tools/scan_dalvik.py finds any such call - Treat a manually entered private address (10.x, 172.16-31.x, 192.168.x, .local) as home, so LAN servers that allow access without sign-in work - Send Plex client headers on media requests (files and transcodes) - Explain a 503 on a file as the server being unable to open it (drive or folder not available) - Connection log: home/away, token presence, Plex's file check and a direct file request in the streaming test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a4b875ef34
commit
58d21b6d68
14 files changed
+218
-13
No files matched your search
@@ -196,6 +196,32 @@ public class PlexTest {
|
||||
Server.Conn c3 = s3.pick();
|
||||
check(c3.kind == Server.LOCAL_HTTP, "falls back when TLS name check fails -> " + c3.uri);
|
||||
|
||||
// --- manual LAN address without a token (server allows this network without sign-in)
|
||||
Server lan = new Server();
|
||||
lan.name = "manual"; lan.token = "";
|
||||
lan.add(Server.normalizeManual("127.0.0.1"), Server.MANUAL);
|
||||
lan.pick();
|
||||
check(lan.isLocal(), "manual private address counts as home (original quality)");
|
||||
check(lan.url("/library/parts/501/1/file.mp3").indexOf("X-Plex-Token") < 0, "no empty X-Plex-Token on media URLs");
|
||||
Library lanLib = new Library(lan, "1");
|
||||
Item lanTrack = lanLib.tracksOf(album).get(0);
|
||||
String lid = proxy.newId();
|
||||
String lurl = proxy.register(lid, java.util.Collections.singletonList(lanLib.directUrl(lanTrack)), "mp3", false, lan.mediaHeaders());
|
||||
hc = (HttpURLConnection) new URL(lurl).openConnection(Proxy.NO_PROXY);
|
||||
byte[] lb = read(hc.getInputStream());
|
||||
check(hc.getResponseCode() == 200 && lb.length == 300000, "token-less LAN: original MP3 streams (" + hc.getResponseCode() + ")");
|
||||
Item flac = lanLib.tracksOf(album).get(1);
|
||||
String lid2 = proxy.newId();
|
||||
String lurl2 = proxy.register(lid2, lanLib.transcodeUrls(flac, 192, 0, "lan1"), "mp3", true, lan.mediaHeaders());
|
||||
hc = (HttpURLConnection) new URL(lurl2).openConnection(Proxy.NO_PROXY);
|
||||
byte[] lt = read(hc.getInputStream());
|
||||
check(hc.getResponseCode() == 200 && new String(lt, "ISO-8859-1").startsWith("TRANSCODE"), "token-less LAN: FLAC converts to MP3");
|
||||
// and the old behaviour reproduces the phone's log exactly
|
||||
Http.Response o1 = Http.get(lanLib.directUrl(lanTrack) + "?X-Plex-Token=", null, 10000); o1.readAll();
|
||||
Http.Response o2 = Http.get(lanLib.transcodeUrls(flac, 192, 0, "lan2").get(0) + "&X-Plex-Token=", null, 10000); o2.readAll();
|
||||
check(o1.code == 503 && o2.code == 400, "old empty-token URLs reproduce the log's 503 and 400");
|
||||
check(lanLib.checkPart(lanTrack).indexOf("exists=") >= 0 || lanLib.checkPart(lanTrack).length() > 0, "file check runs: " + lanLib.checkPart(lanTrack));
|
||||
|
||||
// --- trust checks
|
||||
CertVerifier.setRootStore(roots(args[1])); // real Mozilla roots: test CA must be rejected
|
||||
Http.evictAll();
|
||||
|
||||
+11
-2
@@ -107,16 +107,25 @@ class H(BaseHTTPRequestHandler):
|
||||
if n:
|
||||
self.rfile.read(n)
|
||||
u = urlparse(self.path)
|
||||
q = parse_qs(u.query)
|
||||
q = parse_qs(u.query, keep_blank_values=True)
|
||||
p = u.path
|
||||
host = self.headers.get("Host", "")
|
||||
tok = self.headers.get("X-Plex-Token") or (q.get("X-Plex-Token") or [None])[0]
|
||||
empty_token_param = "X-Plex-Token" in q and q["X-Plex-Token"][0] == "" and not self.headers.get("X-Plex-Token")
|
||||
log.append((method, host, self.path, tok, self.headers.get("Range")))
|
||||
if host.startswith("plex.tv"):
|
||||
return self.tv(method, p, tok)
|
||||
if p == "/identity":
|
||||
return self.send_json({"MediaContainer": {"machineIdentifier": MACHINE, "version": "1.40"}})
|
||||
if tok != TOKEN:
|
||||
# Like a server with "allowed without auth" for its LAN: no token at all is fine from here,
|
||||
# but media requests carrying an *empty* token are refused (503 files / 400 transcoder).
|
||||
lan_no_auth = tok is None and self.server.server_address[1] == 32400
|
||||
if empty_token_param:
|
||||
if p.startswith("/library/parts/"):
|
||||
return self.send_json({"error": "Service Unavailable"}, 503)
|
||||
if "/transcode/" in p:
|
||||
return self.send_json({"error": "Bad Request"}, 400)
|
||||
if tok != TOKEN and not lan_no_auth:
|
||||
return self.send_json({"error": "unauthorized"}, 401)
|
||||
if p == "/library/sections":
|
||||
return self.send_json({"MediaContainer": {"Directory": [
|
||||
|
||||
Reference in new issue
Block a user