From 71d641eca60e7fa4d3501711cda670289dd485c9 Mon Sep 17 00:00:00 2001 From: 404errordeveloper Date: Thu, 8 Oct 2026 19:55:28 +0200 Subject: [PATCH] builds --- .forgejo/workflows/release.yml | 70 +++++++++++++++++++++++++ docs/README.md | 3 ++ docs/capture.md | 93 +++++++++++++++++++++++++++++++++- docs/providers/bbc.md | 51 ++++++++++++++++--- docs/release.md | 54 ++++++++++++++++++++ 5 files changed, 264 insertions(+), 7 deletions(-) create mode 100644 .forgejo/workflows/release.yml create mode 100644 docs/release.md diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..58b86e4 --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,70 @@ +# Build multi-platform drm binaries + Android MITM and attach them to a Forgejo release. +# +# Trigger: push a version tag +# git tag v1.2.3 && git push origin v1.2.3 +# +# Requires a Forgejo Actions runner registered against this instance +# (label must match runs-on below — default act_runner often uses "docker"). +# See deploy/forgejo/README.md § Actions / releases. + +name: release + +on: + push: + tags: + - "v*" + +jobs: + build-and-upload: + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + # apps/proxy/device requires the newer toolchain; apps/cli is fine with it. + go-version-file: apps/proxy/device/go.mod + cache-dependency-path: | + apps/cli/go.sum + apps/proxy/device/go.sum + + - name: Build release artifacts + run: | + chmod +x scripts/build-release.sh + ./scripts/build-release.sh "${{ github.ref_name }}" + ls -la dist/release + + - name: Upload to Forgejo release + uses: https://data.forgejo.org/actions/forgejo-release@v2.7.2 + with: + direction: upload + # Defaults to this runner's Forgejo URL when omitted. + url: https://git.nulldrm.com + repo: ${{ github.repository }} + # Built-in job token (write:repository). Override with a PAT secret if needed. + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + sha: ${{ github.sha }} + release-dir: dist/release + title: ${{ github.ref_name }} + override: true + release-notes: | + Multi-platform `drm` host CLI + on-device MITM (`proxy-android-arm64`). + + | Asset | Platform | + |---|---| + | `drm-windows-amd64.exe` | Windows x86_64 | + | `drm-windows-arm64.exe` | Windows ARM64 | + | `drm-linux-amd64` | Linux x86_64 | + | `drm-linux-arm64` | Linux ARM64 | + | `drm-darwin-amd64` | macOS Intel | + | `drm-darwin-arm64` | macOS Apple Silicon | + | `proxy-android-arm64` | On-device MITM (push with `drm proxy`) | + | `SHA256SUMS.txt` | Checksums | + + Built with `CGO_ENABLED=0` via `scripts/build-release.sh`. + Phone capture still needs Magisk + `drm proxy install-ca --reinject`. diff --git a/docs/README.md b/docs/README.md index f4ddeb0..bcbbd52 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,10 +3,13 @@ | Doc | Read it when | |---|---| | [quickstart.md](quickstart.md) | You just cloned the repo and want something working | +| [release.md](release.md) | Cross-compile Windows / macOS / Linux (+ Android MITM) for Forgejo releases | | [architecture.md](architecture.md) | You want to know how the pieces fit and why | | [modules.md](modules.md) | You are adding support for a new streaming app | | [capture.md](capture.md) | You need to discover an app's URLs, IDs and UI selectors | +| [capture.md § Transparent](capture.md#transparent-capture-vpn-on-the-phone) | Phone VPN must stay on (BBC / NordVPN UK) — iptables MITM + pull | | [streamd.md](streamd.md) | You are running the control plane + agent | +| [providers/bbc.md](providers/bbc.md) | BBC iPlayer clear live DASH — transparent capture with UK VPN | | [providers/rte.md](providers/rte.md) | You are filling in `apps/modules/rte/module.yaml` | | [providers/tg4.md](providers/tg4.md) | You are filling in `apps/modules/tg4/module.yaml` | diff --git a/docs/capture.md b/docs/capture.md index 992d6dd..5a06bf5 100644 --- a/docs/capture.md +++ b/docs/capture.md @@ -40,6 +40,92 @@ adb shell settings put system screen_off_timeout 1800000 Restore the timeout afterwards (default is usually 60000). +## Transparent capture (VPN on the phone) + +When the phone must stay on a VPN (BBC + NordVPN UK, geo-locked apps, etc.), +**do not** use classic Wi‑Fi `http_proxy`. That fights the VPN tunnel. + +Use **transparent** mode instead: root `iptables` redirects only the target +app’s TCP/443 into on-device `appproxy`. NordVPN (or any VPN) stays connected. +Nothing sets the global HTTP proxy. + +### Why this shape + +| Approach | VPN on phone | Sees HTTPS bodies (MPD / license) | +|---|---|---| +| Wi‑Fi `http_proxy` → appproxy | Often breaks / fights VPN | Yes | +| `tcpdump` / pcap on `tun0` only | Yes | No (TLS ciphertext) | +| **Transparent appproxy** | Yes | Yes | +| `drm capture --app …` for BBC | Yes (uses transparent under the hood) | Yes | + +Install the binary on the phone, play while it records to +`/data/local/tmp/capture//`, then pull. Ctrl+C on the host stops +iptables and pulls into `outputs/transparent//`. + +### Working flow + +```powershell +# 1. NordVPN (or other VPN) ON on the phone — UK egress for BBC + +# 2. CA once (or after reboot if the conscrypt mount dropped) +.\bin\drm.exe proxy install-ca --reinject +adb shell am force-stop # e.g. bbc.iplayer.android + +# 3. Start transparent MITM (VPN stays on) +.\bin\drm.exe proxy transparent --package + +# 4. Open the app and play on the phone +# 5. Ctrl+C when done → stops iptables + pulls captures +``` + +On Linux/macOS the same commands use `./bin/drm` instead of `.\bin\drm.exe`. + +### On-device artifacts + +```text +/data/local/tmp/capture// + cap.json structured mpd / license / auth / pssh when detected + traffic.jsonl every HTTP(S) exchange (-log-all) + appproxy.log [MPD] [LIC] [TPROXY] [PASS] lines +``` + +Pull without stopping the session: + +```powershell +adb pull /data/local/tmp/capture/bbc.iplayer.android .\bbc-cap +``` + +### Cleanup (always, if interrupted) + +A leftover REDIRECT breaks playback even after the host command exits. Clear it: + +```powershell +.\bin\drm.exe proxy stop +adb shell "su -c 'sh /data/local/tmp/tproxy_iptables.sh stop; killall -9 appproxy 2>/dev/null; true'" +``` + +Do not leave a hung `drm capture` or `proxy transparent` in another terminal — +it will reinstall the redirect and break the app. + +### CA cert/key mismatch + +If start fails with `appproxy failed to start (transparent)`, check the log: + +```powershell +adb shell "cat /data/local/tmp/capture//appproxy.log" +``` + +`CA: tls: private key does not match public key` means +`/data/local/tmp/appproxy-ca.key` does not match `appproxy-ca.crt`. Prefer the +matching legacy pair (certs are often identical): + +```powershell +adb shell "su -c 'cp /data/local/tmp/rteproxy-ca.key /data/local/tmp/appproxy-ca.key; chmod 600 /data/local/tmp/appproxy-ca.key'" +``` + +Then re-run `proxy transparent`. Re-run `install-ca --reinject` and force-stop +the app so the trusted CA hash still matches the cert appproxy signs with. + ## Three modes ### Passive — no module needed @@ -248,15 +334,20 @@ Also sanity-check that the KID you captured matches whatever you recorded in |---|---| | `tls: unknown certificate` in the app | CA not mounted into conscrypt; reinject, then force-stop the app | | `timed out waiting for capture ([auth pid pssh mpd])` | playback never started, or `Hints` asks for a field this app does not send | +| `appproxy failed to start (transparent)` | see log; often CA key mismatch (`appproxy-ca.key` ≠ cert) — copy matching `rteproxy-ca.key` | +| App loads catalog but stream spins / fails after a capture | leftover `APPROXY_TPROXY` iptables REDIRECT — run cleanup above | | `launch: ui node not found within Ns` | launch marker does not match — dump the tree and pick a resource id | | `launch: exit status 1` | monkey raced a force-stop; usually transient, retry | | `auto-play failed: ... not found` | UI changed, or the phone is on a different screen than expected | | manifest field holds an EPG or config URL | add that host to `score.deny` | | `CA inject skipped/failed` | transient after repeated runs; re-run `proxy reinject-ca` | | Screen asleep mid-run | `adb shell svc power stayon true` | +| VPN on + classic `http_proxy` capture | use transparent mode instead (see above) | -Clear the phone's proxy if a run is interrupted: +Clear the phone's proxy / transparent redirect if a run is interrupted: ```bash +./bin/drm proxy stop ./bin/drm proxy clear-proxy +adb shell "su -c 'sh /data/local/tmp/tproxy_iptables.sh stop; killall -9 appproxy 2>/dev/null; true'" ``` diff --git a/docs/providers/bbc.md b/docs/providers/bbc.md index c0cc6bc..ee3e276 100644 --- a/docs/providers/bbc.md +++ b/docs/providers/bbc.md @@ -38,21 +38,60 @@ channels: vpid: bbc_two_england ``` -## Capture +## Capture (NordVPN UK on the phone) -```bash -# Leave NordVPN UK ON. Magisk CA should already be mounted (skip --reinject). -./bin/drm capture --app bbc --channel bbcone --wait 120 +BBC needs a **UK egress IP**. Keep **NordVPN UK on the phone**. Capture must use +**transparent** MITM (iptables REDIRECT) so it does not fight the VPN. Classic +Wi‑Fi `http_proxy` is the wrong tool here. + +Full background: [capture.md — Transparent capture](../capture.md#transparent-capture-vpn-on-the-phone). + +### Manual transparent (recommended when debugging) + +```powershell +# NordVPN UK ON +.\bin\drm.exe proxy install-ca --reinject +adb shell am force-stop bbc.iplayer.android +.\bin\drm.exe proxy transparent --package bbc.iplayer.android +# Play BBC One on the phone. Ctrl+C → stop iptables + pull. +``` + +Artifacts on device: `/data/local/tmp/capture/bbc.iplayer.android/` +(`cap.json`, `traffic.jsonl`, `appproxy.log`). Host pull lands in +`outputs/transparent//`. + +Pull without stopping: + +```powershell +adb pull /data/local/tmp/capture/bbc.iplayer.android .\bbc-cap +``` + +### Module-driven capture + +Same transparent path under the hood; waits for `mpd` and writes a session: + +```powershell +# NordVPN UK ON. Magisk CA should already be mounted. +.\bin\drm.exe capture --app bbc --channel bbcone --wait 120 # Play BBC One on the phone when prompted. ``` Console prints the MPD in a banner; `outputs/bbc//session.json` holds the same fields (`mpd` required; no `key` / `pssh` for clear streams). -Replay: +### Cleanup if playback breaks after a run + +```powershell +.\bin\drm.exe proxy stop +adb shell "su -c 'sh /data/local/tmp/tproxy_iptables.sh stop; killall -9 appproxy 2>/dev/null; true'" +``` + +### Replay ```powershell ffplay -user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0 Safari/537.36" -i "" ``` -PC needs a UK egress IP (VPN). Some CDNs reject HEAD; use GET / ffplay as above. +PC needs a UK egress IP (VPN) as well. Some CDNs reject HEAD; use GET / ffplay as above. +Confirm UK with `https://ipinfo.io` on the phone (`country` = `GB`) before play — +catalog can load from outside the UK while mediaselector / streams return 403. diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 0000000..b9d9ae5 --- /dev/null +++ b/docs/release.md @@ -0,0 +1,54 @@ +# Multi-platform releases + +Host CLI (`drm`) and the on-device MITM (`proxy-android-arm64`) are plain Go +binaries (`CGO_ENABLED=0`), so one machine can cross-compile every target. + +## Local build + +```bash +./scripts/build-release.sh v1.2.3 +``` + +Windows: + +```powershell +.\scripts\build-release.ps1 -Version v1.2.3 +``` + +Writes `dist/release/`: + +| File | Use | +|---|---| +| `drm-windows-amd64.exe` | Windows x86_64 host | +| `drm-windows-arm64.exe` | Windows ARM64 host | +| `drm-linux-amd64` | Linux x86_64 host | +| `drm-linux-arm64` | Linux ARM64 host | +| `drm-darwin-amd64` | macOS Intel | +| `drm-darwin-arm64` | macOS Apple Silicon | +| `proxy-android-arm64` | Phone MITM (`drm proxy push` / transparent) | +| `SHA256SUMS.txt` | SHA-256 of the above | + +Copy the matching host binary to `bin/drm` / `bin/drm.exe` (the scripts already +do this for the current OS) and keep `proxy-android-arm64` next to it under +`bin/`. + +## Forgejo (git.nulldrm.com) + +Push a version tag; Actions builds and attaches the same files to the release: + +```bash +git tag v1.2.3 +git push origin v1.2.3 +``` + +Workflow: [`.forgejo/workflows/release.yml`](../.forgejo/workflows/release.yml). +Runner setup: [deploy/forgejo/README.md](../deploy/forgejo/README.md) § Actions / releases. + +## Manual one-off cross-compile + +```bash +GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go -C apps/cli build -o bin/drm.exe . +GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go -C apps/cli build -o bin/drm-darwin-arm64 . +GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go -C apps/cli build -o bin/drm-linux-amd64 . +GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go -C apps/proxy/device build -o bin/proxy-android-arm64 . +```