Initial commit: Null DRM Official

Capture, decrypt, and restream toolkit with compiled-in app modules
(RTE, TG4, BBC), on-device MITM proxy, streamd control plane, and www.
BBC module.yaml is published (clear streams); other module values stay local.
This commit is contained in:
404errordeveloper 2026-10-06 00:25:35 +02:00
commit 2fa8f2435f
121 changed files with 17802 additions and 0 deletions

View file

@ -0,0 +1,84 @@
package rte
import (
"strings"
"testing"
appreg "drmdecryption/app"
"drmdecryption/mpd"
)
// Compile-time proof the plugin satisfies every interface the host expects.
var (
_ appreg.App = (*App)(nil)
_ appreg.StreamDefaults = (*App)(nil)
_ mpd.Rewriter = (*Rewriter)(nil)
_ mpd.KIDResolver = (*Rewriter)(nil)
_ mpd.Primer = (*Rewriter)(nil)
)
func testConfig() Config {
return Config{
Channels: map[string]Channel{
"chanone": {Label: "Chan One", ChipDesc: []string{"^chanone$"}},
"chantwo": {Label: "Chan Two"},
},
Origins: map[string]string{
"vc11": "https://origin.test/live/tc-1/vc11/vc11.isml/",
"vc12": "https://origin.test/live/tc-1/vc12/vc12.isml/",
},
KIDs: map[string]string{
"vc11": "df163382-1ddd-fdd5-bec9-822c1ec0f052",
},
}.withDefaults()
}
func TestResolveKIDMapsBackToOrigin(t *testing.T) {
r := NewRewriterWith(testConfig())
ch, base, ok := r.ResolveKID("df1633821dddfdd5bec9822c1ec0f052")
if !ok {
t.Fatal("KID should resolve to a channel")
}
if ch != "vc11" {
t.Errorf("channel = %q, want vc11", ch)
}
if !strings.Contains(base, "vc11.isml") {
t.Errorf("origin base = %q", base)
}
if _, _, ok := r.ResolveKID("00000000000000000000000000000000"); ok {
t.Error("unknown KID must not resolve")
}
}
func TestOriginFromXMLUsesConfiguredMarker(t *testing.T) {
r := NewRewriterWith(testConfig())
xml := `<MPD><BaseURL>https://origin.test/live/tc-1/vc12/vc12.isml/dash/</BaseURL></MPD>`
ch, base := r.originFromXML(xml)
if ch != "vc12" {
t.Errorf("channel = %q, want vc12", ch)
}
if base != "https://origin.test/live/tc-1/vc12/vc12.isml/" {
t.Errorf("base = %q", base)
}
}
// With no channel identifiable at all, the rewrite must fail rather than emit a
// manifest pointing nowhere.
func TestRewriteWithoutChannelFails(t *testing.T) {
r := NewRewriterWith(testConfig())
if _, err := r.Rewrite([]byte(`<MPD/>`), ""); err == nil {
t.Fatal("expected an error with no channel and no KID")
}
}
// No provider identity may be compiled in: an empty config must yield no origins
// and no KIDs, so a fresh clone cannot stream without its local values file.
func TestNoHardcodedOrigins(t *testing.T) {
cfg := Config{}.withDefaults()
if len(cfg.Origins) != 0 || len(cfg.KIDs) != 0 {
t.Fatal("origins/KIDs must come from module.yaml, not from code")
}
if cfg.Package != "" || cfg.LicenseURL != "" {
t.Fatal("package/license URL must not be defaulted in code")
}
}