- Add streamd serve start|stop|restart|status|update with auto-written streamd.yaml - Panel modules: STREAMD_MODULES_DIR for describe, YAML channel fallback, textarea value fix - Per-stream WireGuard/SOCKS egress profiles + Settings UI - Drop drm-* from release builds; track streamd-bg.sh / streamd-update.sh wrappers - Docs: streamd-server-setup lifecycle and update flow
125 lines
3.6 KiB
Go
125 lines
3.6 KiB
Go
// Command streamd 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/<name>/ and are discovered,
|
|
// built, and executed by the host — they are not linked into this binary.
|
|
package main
|
|
|
|
import (
|
|
// The scheduler resolves IANA zone names so a weekly event stays at its
|
|
// local wall-clock time. Windows ships no zone database, so embed one.
|
|
_ "time/tzdata"
|
|
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"streamd/apps/agent/agentcmd"
|
|
"streamd/apps/capture/capturecmd"
|
|
"streamd/apps/cli/catalogcmd"
|
|
"streamd/apps/cli/modulescmd"
|
|
"streamd/apps/proxy/proxyctlcmd"
|
|
"streamd/apps/streamd/servecmd"
|
|
"streamd/bootstrap"
|
|
"streamd/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, "[!] STREAMD_MODULES_DIR / DRM_MODULES_DIR:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Materialise apps/, bin/, modules/, outputs/, … next to this exe when
|
|
// missing so a lone downloaded streamd.exe becomes a usable 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, `streamd — capture / restream toolchain
|
|
|
|
Usage:
|
|
streamd [--modules-dir DIR] modules
|
|
streamd [--modules-dir DIR] capture --app NAME [--channel ID | --all] [--wvd PATH]
|
|
streamd [--modules-dir DIR] catalog --app NAME --channel ID [--keys] [--json]
|
|
streamd agent run|status|devices|enqueue|cancel [--config …]
|
|
streamd serve start|stop|restart|status|update|run [flags]
|
|
streamd serve [--bind …] [--data …] # foreground (same as run)
|
|
streamd proxy build|push|install-ca|start|stop|reset|discover|pull|clear-proxy|transparent
|
|
|
|
Global flags:
|
|
--modules-dir DIR provider folder (default: <install>/modules, or $STREAMD_MODULES_DIR)
|
|
|
|
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.
|
|
`)
|
|
}
|