streamd v0.2.2: session uptimes, egress DNS, Support, agent/Widevine
All checks were successful
release / build-and-upload (push) Successful in 7m2s

Dashboard Live uptimes + Recent runs from stream_sessions; overview.recent_sessions.
WireGuard netns resolv.conf + missing-deps WARN. Support donations card.
Agent start/stop/update, job_backoff default off, wvkey ensure/venv, phonecap retries,
modhost YAML enrich, DRM SetCredentials requires keys.
This commit is contained in:
404errordeveloper 2026-10-10 19:26:39 +02:00
parent 3ae1dd58b3
commit a091922efa
34 changed files with 2391 additions and 154 deletions

View file

@ -77,6 +77,13 @@ func (m *Manager) ensureWireGuardUp(p db.EgressProfile) error {
return err
}
}
// DNS inside the netns: host /etc/resolv.conf often points at
// 127.0.0.53 (systemd-resolved), which is unreachable from the ns.
// ip netns exec bind-mounts /etc/netns/<name>/resolv.conf over /etc/resolv.conf.
if err := writeNetnsResolv(nsName); err != nil {
_ = m.Store.SetEgressRuntime(p.ID, db.EgressError, err.Error(), "", 0)
return err
}
// Loopback inside ns.
_ = nsExec("ip", "link", "set", "lo", "up")
@ -221,6 +228,26 @@ func (m *Manager) teardownWireGuard(name string, _ int64) error {
runQuiet("ip", "link", "del", wgDev) // if still in init ns
runQuiet("ip", "netns", "del", nsName)
_ = os.Remove(filepath.Join(m.profileDir(name), "wg.setconf"))
_ = os.RemoveAll(filepath.Join("/etc/netns", nsName))
return nil
}
// writeNetnsResolv installs public resolvers for processes inside the netns
// (microsocks, curl probe). Without this, SOCKS5 hostname connects fail with
// error 0x01 when the host uses systemd-resolved's 127.0.0.53 stub.
func writeNetnsResolv(nsName string) error {
dir := filepath.Join("/etc/netns", nsName)
if err := os.MkdirAll(dir, 0o755); err != nil {
return fmt.Errorf("netns resolv dir: %w", err)
}
body := "# streamd egress — public DNS (host 127.0.0.53 is unreachable in netns)\n" +
"nameserver 1.1.1.1\n" +
"nameserver 1.0.0.1\n" +
"nameserver 8.8.8.8\n"
path := filepath.Join(dir, "resolv.conf")
if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
return fmt.Errorf("netns resolv.conf: %w", err)
}
return nil
}
@ -247,16 +274,29 @@ func hostVethName(name string) string {
func probeEgressIP(nsName string) string {
// Best-effort: ask a public echo over the ns default route.
cmd := exec.Command("ip", "netns", "exec", nsName,
"curl", "-4", "-fsS", "--max-time", "5", "https://ifconfig.me/ip")
out, err := cmd.Output()
if err != nil {
cmd = exec.Command("ip", "netns", "exec", nsName,
"wget", "-qO-", "--timeout=5", "https://ifconfig.me/ip")
out, err = cmd.Output()
for _, url := range []string{
"https://api.ipify.org",
"https://ifconfig.me/ip",
"https://1.1.1.1/cdn-cgi/trace", // fallback parse below if needed
} {
cmd := exec.Command("ip", "netns", "exec", nsName,
"curl", "-4", "-fsS", "--max-time", "5", url)
out, err := cmd.Output()
if err != nil {
return ""
continue
}
s := strings.TrimSpace(string(out))
if strings.Contains(url, "cdn-cgi/trace") {
for _, line := range strings.Split(s, "\n") {
if strings.HasPrefix(line, "ip=") {
return strings.TrimPrefix(line, "ip=")
}
}
continue
}
if s != "" && !strings.Contains(s, " ") {
return s
}
}
return strings.TrimSpace(string(out))
return ""
}