streamd: preview quality picker, dashboard polish, C4 wrap keys
- Preview player can select FHD/HD/SD (or ABR master) from publish links - Embed dashboard screenshots in README; Linux streamd+agent setup guide - C4 Widevine wrap license mode + require --wvd; prefer Widevine PSSH - Channel 4 and My5 modules; streamd auth, variants, schedules, HLS gate
This commit is contained in:
parent
b3955bd81e
commit
066e018749
113 changed files with 19002 additions and 1541 deletions
|
|
@ -1,14 +1,20 @@
|
|||
// Package ui serves the embedded dashboard: one HTML shell plus ES modules
|
||||
// and a vendored copy of hls.js. There is no build step, which is why the
|
||||
// JavaScript is plain modules rather than a bundle.
|
||||
package ui
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed index.html app.css app.js
|
||||
//go:embed index.html all:static
|
||||
var files embed.FS
|
||||
|
||||
// Handler serves the single-page shell for every non-asset path, so the hash
|
||||
// router can own navigation.
|
||||
func Handler() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" && r.URL.Path != "/index.html" {
|
||||
|
|
@ -17,18 +23,37 @@ func Handler() http.Handler {
|
|||
}
|
||||
b, err := files.ReadFile("index.html")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
// The shell references hashed-by-content assets only loosely, so keep
|
||||
// it uncached to avoid serving a stale page against new modules.
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
_, _ = w.Write(b)
|
||||
})
|
||||
}
|
||||
|
||||
// Static serves the dashboard assets. Directory listings are refused: the
|
||||
// asset tree is not interesting, and an index is one more thing to leak.
|
||||
func Static() http.Handler {
|
||||
sub, err := fs.Sub(files, ".")
|
||||
sub, err := fs.Sub(files, "static")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return http.FileServer(http.FS(sub))
|
||||
fileServer := http.FileServer(http.FS(sub))
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "" || r.URL.Path == "/" || strings.HasSuffix(r.URL.Path, "/") {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
// The vendored library is immutable for a given version; the rest is
|
||||
// revalidated so an updated build is picked up on reload.
|
||||
if strings.HasPrefix(r.URL.Path, "/vendor/") {
|
||||
w.Header().Set("Cache-Control", "public, max-age=86400")
|
||||
} else {
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
}
|
||||
fileServer.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue