v0.1.1: external modules, publish YAML, proxy reset, binary-first README
All checks were successful
release / build-and-upload (push) Successful in 6m8s
modules-release / build-and-upload (push) Successful in 4m47s

- Host discovers/builds modules under modules/ (bbc, rte, tg4)
- module-publish.yaml tracked; local module.yaml gitignored
- drm --modules-dir / DRM_MODULES_DIR
- drm proxy reset; Magisk reinject reliability
- modules-v* Forgejo release workflow + build scripts
- BBC full Explore channel map including S4C
- README quickstart based on release binaries
This commit is contained in:
404errordeveloper 2026-10-08 23:16:14 +02:00
parent 1d36961a7c
commit f9c28be3f1
52 changed files with 2915 additions and 636 deletions

View file

@ -5,8 +5,6 @@ import (
"testing"
"drmdecryption/apps/capture/capturecmd"
_ "drmdecryption/modules/all"
)
func TestCaptureRejectsChannelAsApp(t *testing.T) {

View file

@ -1,6 +1,6 @@
// Package catalogcmd resolves a channel's stream credentials from its provider's
// public catalog, with no phone involved. It is provider-agnostic: any app module
// implementing app.Catalog works here.
// public catalog, with no phone involved. Providers live under modules/<name>/
// and are invoked via modhost.
package catalogcmd
import (
@ -11,7 +11,7 @@ import (
"sort"
"strings"
"drmdecryption/app"
"drmdecryption/modhost"
"drmdecryption/repo"
"drmdecryption/session"
)
@ -19,7 +19,7 @@ import (
// Run performs a catalog lookup for one channel.
func Run(args []string) error {
fs := flag.NewFlagSet("catalog", flag.ExitOnError)
appName := fs.String("app", "", "app module to query")
appName := fs.String("app", "", "app module under modules/<name>/")
channel := fs.String("channel", "", "channel id")
asJSON := fs.Bool("json", false, "print streamd-ready JSON only")
list := fs.Bool("list", false, "list the app's channels and their catalog ids")
@ -27,8 +27,6 @@ func Run(args []string) error {
withKeys := fs.Bool("keys", false, "also fetch PSSH and resolve KID:KEY via the local CDM")
python := fs.String("python", "", "python for wvkey.py (default: .venv)")
wvd := fs.String("wvd", "", "path to .wvd device file (required with --keys)")
// Each module contributes --<app>.<field> overrides for its local values.
app.BindFlags(fs)
fs.Usage = func() {
fmt.Fprintf(fs.Output(), "catalog — resolve a channel from its public catalog (no phone)\n\nUsage:\n catalog --app <%s> --channel ID [--keys] [--json]\n\nFlags:\n", strings.Join(catalogApps(), "|"))
fs.PrintDefaults()
@ -40,33 +38,36 @@ func Run(args []string) error {
available := catalogApps()
if strings.TrimSpace(*appName) == "" {
if len(available) != 1 {
return fmt.Errorf("--app required (apps with a catalog: %s)", strings.Join(available, ", "))
msg := strings.Join(available, ", ")
if msg == "" {
msg = "(none — add a modules/<name>/ with catalog support)"
}
return fmt.Errorf("--app required (apps with a catalog: %s)", msg)
}
*appName = available[0]
}
a, err := app.Get(*appName)
a, err := modhost.Open(repo.Root(), *appName)
if err != nil {
return err
return modhost.FormatUnknown(repo.Root(), *appName)
}
cat, ok := a.(app.Catalog)
if !ok {
if !a.Desc.HasCatalog {
return fmt.Errorf("app %q has no catalog — capture it from the phone instead: drm capture --app %s", a.Name(), a.Name())
}
if *list {
return listChannels(a, cat)
return listChannels(a)
}
if strings.TrimSpace(*channel) == "" {
return fmt.Errorf("--channel required (see: drm catalog --app %s --list)", a.Name())
}
info, err := cat.Resolve(*channel)
info, err := a.Resolve(*channel)
if err != nil {
return err
}
if *withKeys {
fmt.Fprintln(os.Stderr, "[*] fetching PSSH + Widevine keys…")
if err := cat.EnrichWithKeys(&info, *python, *wvd); err != nil {
if err := a.EnrichWithKeys(&info, *python, *wvd); err != nil {
return err
}
fmt.Fprintf(os.Stderr, "[+] key %s (%d total)\n", info.Key, len(info.Keys))
@ -87,48 +88,23 @@ func Run(args []string) error {
return nil
}
// catalogApps lists compiled-in modules that can answer catalog lookups.
// catalogApps lists external modules that advertise HasCatalog.
func catalogApps() []string {
listed, err := modhost.ListAll(repo.Root())
if err != nil {
return nil
}
out := []string{}
for _, a := range app.All() {
if _, ok := a.(app.Catalog); ok {
out = append(out, a.Name())
for _, L := range listed {
if L.Desc.HasCatalog {
out = append(out, L.Desc.Name)
}
}
sort.Strings(out)
return out
}
func listChannels(a app.App, cat app.Catalog) error {
if l, ok := cat.(app.CatalogLister); ok {
rows, flags, err := l.ListChannels()
if err != nil {
return err
}
fmt.Printf("%-10s %-16s %s\n", "CHANNEL", "CATALOG ID", "LABEL")
sort.Slice(rows, func(i, j int) bool { return rows[i].ID < rows[j].ID })
for _, r := range rows {
id := r.CatalogID
if id == "" {
id = "-"
}
fmt.Printf("%-10s %-16s %s\n", r.ID, id, r.Label)
}
if len(flags) > 0 {
keys := make([]string, 0, len(flags))
for k := range flags {
keys = append(keys, k)
}
sort.Strings(keys)
parts := make([]string, 0, len(keys))
for _, k := range keys {
parts = append(parts, fmt.Sprintf("%s=%v", k, flags[k]))
}
fmt.Printf("\nprovider flags: %s\n", strings.Join(parts, " "))
}
return nil
}
// Fall back to the plain channel list every app can produce.
func listChannels(a *modhost.RemoteApp) error {
fmt.Printf("%-10s %s\n", "CHANNEL", "LABEL")
for _, ch := range a.Channels() {
fmt.Printf("%-10s %s\n", ch.ID, ch.Label)

View file

@ -8,7 +8,6 @@ require (
drmdecryption/apps/capture v0.0.0
drmdecryption/apps/proxy v0.0.0
drmdecryption/apps/streamd v0.0.0
drmdecryption/modules v0.0.0
)
require (
@ -32,5 +31,4 @@ replace (
drmdecryption/apps/capture => ../capture
drmdecryption/apps/proxy => ../proxy
drmdecryption/apps/streamd => ../streamd
drmdecryption/modules => ../modules
)

View file

@ -1,11 +1,13 @@
// Command drm is the single entry point for the toolchain: phone capture,
// catalog lookups, the always-on agent, the streamd control plane and the
// on-device MITM. Every app module under apps/modules is compiled in.
// on-device MITM. Providers live under modules/<name>/ and are discovered,
// built, and executed by the host — they are not linked into this binary.
package main
import (
"fmt"
"os"
"strings"
"drmdecryption/apps/agent/agentcmd"
"drmdecryption/apps/capture/capturecmd"
@ -14,22 +16,33 @@ import (
"drmdecryption/apps/proxy/proxyctlcmd"
"drmdecryption/apps/streamd/servecmd"
"drmdecryption/bootstrap"
// Links every app module into this binary.
_ "drmdecryption/modules/all"
"drmdecryption/modhost"
)
func main() {
if len(os.Args) < 2 {
args := os.Args[1:]
modulesDir, args := peelGlobalFlags(args)
if len(args) < 1 {
usage()
os.Exit(2)
}
cmd, args := os.Args[1], os.Args[2:]
cmd, args := args[0], args[1:]
// Materialise apps/, bin/, outputs/, … next to this exe when missing
// so a lone downloaded drm.exe becomes a GitHub-like install tree.
if modulesDir != "" {
if err := modhost.SetModulesDir(modulesDir); err != nil {
fmt.Fprintln(os.Stderr, "[!] --modules-dir:", err)
os.Exit(1)
}
} else if err := modhost.ApplyEnvModulesDir(); err != nil {
fmt.Fprintln(os.Stderr, "[!] DRM_MODULES_DIR:", err)
os.Exit(1)
}
// Materialise apps/, bin/, modules/, outputs/, … next to this exe when
// missing so a lone downloaded drm.exe becomes a GitHub-like install tree.
if cmd != "help" && cmd != "-h" && cmd != "--help" {
if err := bootstrap.EnsureAndLog(); err != nil {
if err := bootstrap.EnsureAndLogFor(cmd); err != nil {
fmt.Fprintln(os.Stderr, "[!] bootstrap:", err)
os.Exit(1)
}
@ -62,27 +75,45 @@ func main() {
}
}
// peelGlobalFlags extracts host-level flags that may appear before the subcommand.
func peelGlobalFlags(args []string) (modulesDir string, rest []string) {
rest = make([]string, 0, len(args))
for i := 0; i < len(args); i++ {
a := args[i]
switch {
case a == "--modules-dir" || a == "-modules-dir":
if i+1 >= len(args) {
fmt.Fprintln(os.Stderr, "[!] --modules-dir requires a path")
os.Exit(2)
}
modulesDir = args[i+1]
i++
case strings.HasPrefix(a, "--modules-dir="):
modulesDir = strings.TrimPrefix(a, "--modules-dir=")
default:
rest = append(rest, a)
}
}
return modulesDir, rest
}
func usage() {
fmt.Fprint(os.Stderr, `drm — DRM capture / restream toolchain
Usage:
drm modules list compiled-in app modules and their channels
drm capture --app NAME [--channel ID] [--auto-play] [--wvd PATH]
one-shot phone MITM capture
drm catalog --app NAME --channel ID [--keys] [--json] [--list]
resolve a channel from its public catalog (no phone)
drm [--modules-dir DIR] modules
drm [--modules-dir DIR] capture --app NAME [--channel ID] [--wvd PATH]
drm [--modules-dir DIR] catalog --app NAME --channel ID [--keys] [--json]
drm agent run|status|devices|enqueue|cancel [--config …]
always-on credential refresher
drm serve [--bind …] [--data …] [--token …]
streamd control plane + dashboard
drm proxy build|push|install-ca|start|stop|discover|pull|clear-proxy
on-device HTTPS MITM
drm proxy build|push|install-ca|start|stop|reset|discover|pull|clear-proxy|transparent
App module *code* is compiled in; module *values* are never inside the exe.
Put configs at apps/modules/<name>/module.yaml yourself (see the GitHub repo).
On first run, drm only creates the scaffold (apps/pkg, bin/proxy, outputs, …).
Global flags:
--modules-dir DIR provider folder (default: <install>/modules, or $DRM_MODULES_DIR)
Overrides: --<app>.<field> flags or <APP>_<FIELD> environment variables.
Providers live under modules/<name>/ (Go source + module-publish.yaml).
Local module.yaml holds secrets and is never published; release zips ship
module-publish.yaml renamed to module.yaml. The host builds modules on demand.
Run any subcommand with --help for its own flags.
`)

View file

@ -1,5 +1,5 @@
// Package modulescmd lists the app modules compiled into this binary, their
// channels, and where each one's local values came from.
// Package modulescmd lists provider modules discovered under modules/<name>/,
// building them on demand and showing channels + values paths.
package modulescmd
import (
@ -9,11 +9,11 @@ import (
"sort"
"text/tabwriter"
"drmdecryption/app"
"drmdecryption/modcfg"
"drmdecryption/modhost"
"drmdecryption/repo"
)
// Run prints the compiled-in app modules.
// Run prints external modules under modules/.
func Run(args []string) error {
fs := flag.NewFlagSet("modules", flag.ExitOnError)
verbose := fs.Bool("channels", true, "list each module's channels")
@ -21,54 +21,57 @@ func Run(args []string) error {
return err
}
names := app.Names()
if len(names) == 0 {
return fmt.Errorf("no app modules compiled in — check the blank imports in apps/modules/all/all.go")
root := repo.Root()
listed, err := modhost.ListAll(root)
if err != nil {
return err
}
if len(listed) == 0 {
return fmt.Errorf("no modules found under %s — add modules/<name>/ with Go source + module.yaml (see modules/README.md)", modhost.ModulesDir(root))
}
tw := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
fmt.Fprintln(tw, "APP\tPACKAGE\tKEY MODE\tREWRITER\tCHANNELS\tVALUES")
for _, name := range names {
a, err := app.Get(name)
if err != nil {
fmt.Fprintf(tw, "%s\t-\t-\t-\t-\t%v\n", name, err)
continue
for _, L := range listed {
d := L.Desc
rewriter := d.Rewriter
if rewriter == "" {
rewriter = "none"
}
rewriter := "none"
if sd, ok := a.(app.StreamDefaults); ok && sd.RewriterName() != "" {
rewriter = sd.RewriterName()
}
pkg := a.Package()
pkg := d.Package
if pkg == "" {
pkg = "(not configured)"
}
values := modcfg.Path(name)
values := d.ValuesPath
if values == "" {
values = L.Mod.Dir + string(os.PathSeparator) + "module.yaml"
}
if _, err := os.Stat(values); err != nil {
values = "missing: " + values
} else if !d.ValuesLoaded {
values = values + " (not loaded)"
}
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%d\t%s\n",
name, pkg, a.KeyMode(), rewriter, len(a.Channels()), values)
d.Name, pkg, d.KeyMode, rewriter, len(d.Channels), values)
}
_ = tw.Flush()
if !*verbose {
return nil
}
for _, name := range names {
a, err := app.Get(name)
if err != nil {
continue
}
chans := a.Channels()
for _, L := range listed {
d := L.Desc
chans := append([]modhost.Channel{}, d.Channels...)
sort.Slice(chans, func(i, j int) bool { return chans[i].ID < chans[j].ID })
fmt.Printf("\n%s channels:", name)
fmt.Printf("\n%s channels:", d.Name)
if len(chans) == 0 {
fmt.Printf(" none — add %s\n", modcfg.Path(name))
fmt.Printf(" none — add %s\n", d.ValuesPath)
continue
}
fmt.Println()
for _, ch := range chans {
catalog := ""
if _, ok := a.(app.Catalog); ok {
if d.HasCatalog {
catalog = " (catalog)"
}
fmt.Printf(" %-10s %s%s\n", ch.ID, ch.Label, catalog)