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
80
apps/streamd/internal/egress/conf.go
Normal file
80
apps/streamd/internal/egress/conf.go
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
package egress
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// wgInterfaceAddrs extracts Address= values from the [Interface] section of a
|
||||
// wg-quick style conf. Private keys are never returned or logged.
|
||||
func wgInterfaceAddrs(conf string) []string {
|
||||
var addrs []string
|
||||
section := ""
|
||||
sc := bufio.NewScanner(strings.NewReader(conf))
|
||||
for sc.Scan() {
|
||||
line := strings.TrimSpace(sc.Text())
|
||||
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
|
||||
section = strings.ToLower(strings.TrimSpace(line[1 : len(line)-1]))
|
||||
continue
|
||||
}
|
||||
if section != "interface" {
|
||||
continue
|
||||
}
|
||||
key, val, ok := strings.Cut(line, "=")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if strings.EqualFold(strings.TrimSpace(key), "Address") {
|
||||
for _, part := range strings.Split(val, ",") {
|
||||
if a := strings.TrimSpace(part); a != "" {
|
||||
addrs = append(addrs, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return addrs
|
||||
}
|
||||
|
||||
// wgSetconfBody strips wg-quick-only keys so the result is valid for `wg setconf`.
|
||||
func wgSetconfBody(conf string) string {
|
||||
var b strings.Builder
|
||||
section := ""
|
||||
sc := bufio.NewScanner(strings.NewReader(conf))
|
||||
for sc.Scan() {
|
||||
raw := sc.Text()
|
||||
line := strings.TrimSpace(raw)
|
||||
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
|
||||
section = strings.ToLower(strings.TrimSpace(line[1 : len(line)-1]))
|
||||
b.WriteString(line)
|
||||
b.WriteByte('\n')
|
||||
continue
|
||||
}
|
||||
key, _, ok := strings.Cut(line, "=")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
k := strings.ToLower(strings.TrimSpace(key))
|
||||
if section == "interface" {
|
||||
switch k {
|
||||
case "privatekey", "listenport", "fwmark":
|
||||
b.WriteString(line)
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
continue
|
||||
}
|
||||
if section == "peer" {
|
||||
switch k {
|
||||
case "publickey", "presharedkey", "allowedips", "endpoint", "persistentkeepalive":
|
||||
b.WriteString(line)
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue