// 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. Providers live under modules// 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" "drmdecryption/apps/cli/catalogcmd" "drmdecryption/apps/cli/modulescmd" "drmdecryption/apps/proxy/proxyctlcmd" "drmdecryption/apps/streamd/servecmd" "drmdecryption/bootstrap" "drmdecryption/modhost" ) func main() { args := os.Args[1:] modulesDir, args := peelGlobalFlags(args) if len(args) < 1 { usage() os.Exit(2) } cmd, args := args[0], args[1:] 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.EnsureAndLogFor(cmd); err != nil { fmt.Fprintln(os.Stderr, "[!] bootstrap:", err) os.Exit(1) } } var err error switch cmd { case "capture": err = capturecmd.Run(args) case "catalog": err = catalogcmd.Run(args) case "modules": err = modulescmd.Run(args) case "agent": err = agentcmd.Run(args) case "serve": err = servecmd.Run(append([]string{"serve"}, args...)) case "proxy": err = proxyctlcmd.Run(args) case "help", "-h", "--help": usage() return default: usage() err = fmt.Errorf("unknown command %q", cmd) } if err != nil { fmt.Fprintln(os.Stderr, "[!]", err) os.Exit(1) } } // 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-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 …] drm serve [--bind …] [--data …] [--token …] drm proxy build|push|install-ca|start|stop|reset|discover|pull|clear-proxy|transparent Global flags: --modules-dir DIR provider folder (default: /modules, or $DRM_MODULES_DIR) Providers live under modules// (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. `) }