streamd: serve start/stop/update, streamd.yaml, egress, module panel fixes
- 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
This commit is contained in:
parent
da8e1123ec
commit
8fc7e4c0b8
57 changed files with 4031 additions and 257 deletions
|
|
@ -41,7 +41,8 @@ type Stream struct {
|
|||
MPD string `json:"mpd"`
|
||||
Key string `json:"key"`
|
||||
HeadersJSON string `json:"headers_json"`
|
||||
Proxy string `json:"proxy"` // socks5:// or http:// for origin fetch (NRE)
|
||||
Proxy string `json:"proxy"` // socks5:// or http:// for origin fetch (NRE)
|
||||
Egress string `json:"egress"` // named egress profile (wireguard/socks); used when Proxy empty
|
||||
VideoSelect string `json:"video_select"`
|
||||
AudioSelect string `json:"audio_select"`
|
||||
Enabled bool `json:"enabled"`
|
||||
|
|
@ -81,6 +82,7 @@ type Stream struct {
|
|||
HasKey bool `json:"has_key"`
|
||||
HasHeaders bool `json:"has_headers"`
|
||||
HasProxy bool `json:"has_proxy"`
|
||||
HasEgress bool `json:"has_egress"`
|
||||
KeyValid bool `json:"key_valid"`
|
||||
// DRMRequired is DRMMode resolved: whether this stream needs keys at all.
|
||||
DRMRequired bool `json:"drm_required"`
|
||||
|
|
@ -103,6 +105,7 @@ type CreateStream struct {
|
|||
Key string `json:"key"`
|
||||
HeadersJSON string `json:"headers_json"`
|
||||
Proxy string `json:"proxy"`
|
||||
Egress string `json:"egress"`
|
||||
VideoSelect string `json:"video_select"`
|
||||
AudioSelect string `json:"audio_select"`
|
||||
Rewriter string `json:"rewriter"`
|
||||
|
|
@ -128,6 +131,7 @@ type PatchStream struct {
|
|||
Key *string `json:"key"`
|
||||
HeadersJSON *string `json:"headers_json"`
|
||||
Proxy *string `json:"proxy"`
|
||||
Egress *string `json:"egress"`
|
||||
VideoSelect *string `json:"video_select"`
|
||||
AudioSelect *string `json:"audio_select"`
|
||||
Rewriter *string `json:"rewriter"`
|
||||
|
|
@ -230,6 +234,7 @@ CREATE TABLE IF NOT EXISTS agent_claims (
|
|||
`ALTER TABLE streams ADD COLUMN on_demand INTEGER NOT NULL DEFAULT 0`,
|
||||
`ALTER TABLE streams ADD COLUMN idle_timeout_s INTEGER NOT NULL DEFAULT 300`,
|
||||
`ALTER TABLE streams ADD COLUMN public INTEGER NOT NULL DEFAULT 1`,
|
||||
`ALTER TABLE streams ADD COLUMN egress TEXT NOT NULL DEFAULT ''`,
|
||||
} {
|
||||
_, _ = s.DB.Exec(stmt)
|
||||
}
|
||||
|
|
@ -239,7 +244,10 @@ CREATE TABLE IF NOT EXISTS agent_claims (
|
|||
if err := s.migrateSettings(); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.migrateSchedules()
|
||||
if err := s.migrateSchedules(); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.migrateEgress()
|
||||
}
|
||||
|
||||
func now() string {
|
||||
|
|
@ -264,10 +272,13 @@ func slug(name string) string {
|
|||
return out
|
||||
}
|
||||
|
||||
// Slug normalises a name the same way stream and egress profile names are stored.
|
||||
func Slug(name string) string { return slug(name) }
|
||||
|
||||
const streamSelect = `
|
||||
SELECT s.id, s.name, s.title, COALESCE(s.description,''), COALESCE(s.tags,''),
|
||||
s.app, s.channel, s.mpd, s.key_kid_key, s.headers_json,
|
||||
COALESCE(s.proxy,''), s.video_select, s.audio_select, s.enabled, s.rewriter,
|
||||
COALESCE(s.proxy,''), COALESCE(s.egress,''), s.video_select, s.audio_select, s.enabled, s.rewriter,
|
||||
COALESCE(s.variants_json,''), COALESCE(s.outputs_json,''), COALESCE(s.settings_json,''),
|
||||
COALESCE(s.drm_mode,'auto'), COALESCE(s.on_demand,0),
|
||||
COALESCE(s.idle_timeout_s,300), COALESCE(s.public,1),
|
||||
|
|
@ -318,7 +329,7 @@ func scanStream(row rowScanner) (Stream, error) {
|
|||
err := row.Scan(
|
||||
&st.ID, &st.Name, &st.Title, &st.Description, &st.Tags,
|
||||
&st.App, &st.Channel, &st.MPD, &st.Key, &st.HeadersJSON,
|
||||
&st.Proxy, &st.VideoSelect, &st.AudioSelect, &enabled, &st.Rewriter,
|
||||
&st.Proxy, &st.Egress, &st.VideoSelect, &st.AudioSelect, &enabled, &st.Rewriter,
|
||||
&st.VariantsJSON, &st.OutputsJSON, &st.SettingsJSON,
|
||||
&st.DRMMode, &onDemand, &st.IdleTimeoutS, &public,
|
||||
&st.CreatedAt, &st.UpdatedAt,
|
||||
|
|
@ -361,6 +372,7 @@ func (st *Stream) fillDerived() {
|
|||
hdr := strings.TrimSpace(st.HeadersJSON)
|
||||
st.HasHeaders = hdr != "" && hdr != "{}" && hdr != "null"
|
||||
st.HasProxy = strings.TrimSpace(st.Proxy) != ""
|
||||
st.HasEgress = strings.TrimSpace(st.Egress) != ""
|
||||
switch strings.ToLower(strings.TrimSpace(st.DRMMode)) {
|
||||
case DRMYes:
|
||||
st.DRMRequired = true
|
||||
|
|
@ -557,12 +569,13 @@ func (s *Store) CreateStream(in CreateStream) (Stream, error) {
|
|||
}
|
||||
ts := now()
|
||||
res, err := s.DB.Exec(`
|
||||
INSERT INTO streams(name,title,description,tags,app,channel,mpd,key_kid_key,headers_json,proxy,
|
||||
INSERT INTO streams(name,title,description,tags,app,channel,mpd,key_kid_key,headers_json,proxy,egress,
|
||||
video_select,audio_select,enabled,rewriter,variants_json,outputs_json,
|
||||
settings_json,drm_mode,on_demand,idle_timeout_s,public,created_at,updated_at)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
||||
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
||||
name, in.Title, strings.TrimSpace(in.Description), normalizeTags(in.Tags),
|
||||
in.App, in.Channel, in.MPD, in.Key, in.HeadersJSON, strings.TrimSpace(in.Proxy),
|
||||
slug(strings.TrimSpace(in.Egress)),
|
||||
in.VideoSelect, in.AudioSelect, enabled, in.Rewriter, variantsJSON, outputsJSON,
|
||||
settingsJSON, normalizeDRMMode(in.DRMMode), onDemand, idle, public, ts, ts)
|
||||
if err != nil {
|
||||
|
|
@ -654,6 +667,9 @@ func (s *Store) PatchStream(id int64, in PatchStream) (Stream, error) {
|
|||
if in.Proxy != nil {
|
||||
cur.Proxy = strings.TrimSpace(*in.Proxy)
|
||||
}
|
||||
if in.Egress != nil {
|
||||
cur.Egress = slug(strings.TrimSpace(*in.Egress))
|
||||
}
|
||||
if in.VideoSelect != nil {
|
||||
cur.VideoSelect = *in.VideoSelect
|
||||
}
|
||||
|
|
@ -730,11 +746,11 @@ func (s *Store) PatchStream(id int64, in PatchStream) (Stream, error) {
|
|||
ts := now()
|
||||
_, err = s.DB.Exec(`
|
||||
UPDATE streams SET title=?, description=?, tags=?, app=?, channel=?, mpd=?, key_kid_key=?,
|
||||
headers_json=?, proxy=?, video_select=?, audio_select=?, enabled=?, rewriter=?,
|
||||
headers_json=?, proxy=?, egress=?, video_select=?, audio_select=?, enabled=?, rewriter=?,
|
||||
variants_json=?, outputs_json=?, settings_json=?, drm_mode=?, on_demand=?,
|
||||
idle_timeout_s=?, public=?, updated_at=? WHERE id=?`,
|
||||
cur.Title, cur.Description, cur.Tags, cur.App, cur.Channel, cur.MPD, cur.Key,
|
||||
cur.HeadersJSON, cur.Proxy, cur.VideoSelect, cur.AudioSelect, enabled, cur.Rewriter,
|
||||
cur.HeadersJSON, cur.Proxy, cur.Egress, cur.VideoSelect, cur.AudioSelect, enabled, cur.Rewriter,
|
||||
cur.VariantsJSON, cur.OutputsJSON, cur.SettingsJSON, cur.DRMMode, onDemand,
|
||||
cur.IdleTimeoutS, public, ts, id)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue