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
|
|
@ -192,12 +192,186 @@ export function settingsView(root) {
|
|||
),
|
||||
),
|
||||
);
|
||||
wrap.append(await egressCard());
|
||||
}
|
||||
|
||||
load();
|
||||
return () => {};
|
||||
}
|
||||
|
||||
async function egressCard() {
|
||||
const box = el("div.card",
|
||||
el("div.card-head",
|
||||
el("h2", { text: "Egress tunnels" }),
|
||||
el("span.spacer"),
|
||||
el("button.sm", { type: "button", text: "+ Add profile", onclick: () => openEgressDialog(reload) }),
|
||||
),
|
||||
el("p.hint", {
|
||||
text: "Named WireGuard (Linux netns + local SOCKS) or SOCKS URL profiles. " +
|
||||
"Assign a profile per stream so only that stream’s origin fetch exits via the tunnel. " +
|
||||
"Full-tunnel WG stays inside a network namespace — SSH and the dashboard keep the host route.",
|
||||
}),
|
||||
);
|
||||
const list = el("div");
|
||||
box.append(list);
|
||||
|
||||
async function reload() {
|
||||
clear(list);
|
||||
let data;
|
||||
try {
|
||||
data = await api.egress();
|
||||
} catch (err) {
|
||||
list.append(el("p.msg.err", { text: err.message }));
|
||||
return;
|
||||
}
|
||||
const profiles = data.profiles || [];
|
||||
if (!profiles.length) {
|
||||
list.append(el("p.hint", { text: "No profiles yet. Add london (or dublin, …) from a WireGuard client .conf." }));
|
||||
return;
|
||||
}
|
||||
for (const p of profiles) {
|
||||
const status = p.status || "stopped";
|
||||
const meta = [
|
||||
p.kind,
|
||||
status,
|
||||
p.listen_port ? `:${p.listen_port}` : null,
|
||||
p.egress_ip || null,
|
||||
p.has_conf ? "conf" : null,
|
||||
p.enabled ? "autostart" : null,
|
||||
].filter(Boolean).join(" · ");
|
||||
const row = el("div.row", {
|
||||
style: { alignItems: "center", gap: "8px", flexWrap: "wrap", padding: "8px 0", borderBottom: "1px solid var(--border)" },
|
||||
},
|
||||
el("div", { style: { flex: "1 1 160px" } },
|
||||
el("div.mono", { text: p.name }),
|
||||
el("small.muted", { text: meta }),
|
||||
p.last_error ? el("div.msg.err", { text: p.last_error, style: { marginTop: "4px" } }) : null,
|
||||
),
|
||||
el("button.ghost.sm", {
|
||||
type: "button", text: "Up",
|
||||
onclick: async () => {
|
||||
try { await api.egressUp(p.name); toast(`${p.name} up`); reload(); }
|
||||
catch (err) { toast(err.message, true); }
|
||||
},
|
||||
}),
|
||||
el("button.ghost.sm", {
|
||||
type: "button", text: "Down",
|
||||
onclick: async () => {
|
||||
try { await api.egressDown(p.name); toast(`${p.name} down`); reload(); }
|
||||
catch (err) { toast(err.message, true); }
|
||||
},
|
||||
}),
|
||||
el("button.ghost.sm", {
|
||||
type: "button", text: "Test IP",
|
||||
onclick: async () => {
|
||||
try {
|
||||
const r = await api.egressTest(p.name);
|
||||
toast(`${p.name} egress IP: ${r.egress_ip || r.ip || JSON.stringify(r)}`);
|
||||
reload();
|
||||
} catch (err) { toast(err.message, true); }
|
||||
},
|
||||
}),
|
||||
el("button.ghost.sm", {
|
||||
type: "button", text: "Edit",
|
||||
onclick: () => openEgressDialog(reload, p),
|
||||
}),
|
||||
el("button.ghost.sm.danger", {
|
||||
type: "button", text: "Delete",
|
||||
onclick: async () => {
|
||||
if (!confirm(`Delete egress profile ${p.name}?`)) return;
|
||||
try { await api.deleteEgress(p.name); toast("Deleted"); reload(); }
|
||||
catch (err) { toast(err.message, true); }
|
||||
},
|
||||
}),
|
||||
);
|
||||
list.append(row);
|
||||
}
|
||||
}
|
||||
|
||||
await reload();
|
||||
return box;
|
||||
}
|
||||
|
||||
function openEgressDialog(onDone, existing) {
|
||||
const isEdit = !!existing;
|
||||
const name = el("input", {
|
||||
required: true, placeholder: "london",
|
||||
value: existing?.name || "",
|
||||
disabled: isEdit,
|
||||
});
|
||||
const kind = el("select",
|
||||
el("option", { value: "wireguard", text: "WireGuard (Linux netns)", selected: !existing || existing.kind === "wireguard" }),
|
||||
el("option", { value: "socks", text: "SOCKS/HTTP URL only", selected: existing?.kind === "socks" }),
|
||||
);
|
||||
const enabled = el("input", { type: "checkbox", checked: existing ? !!existing.enabled : true });
|
||||
const socksURL = el("input", {
|
||||
placeholder: "socks5://127.0.0.1:1081",
|
||||
value: existing?.socks_url || "",
|
||||
});
|
||||
const conf = el("textarea", {
|
||||
rows: "12",
|
||||
placeholder: "[Interface]\nPrivateKey = …\nAddress = …\n\n[Peer]\nPublicKey = …\nEndpoint = …\nAllowedIPs = 0.0.0.0/0, ::/0\n",
|
||||
spellcheck: "false",
|
||||
});
|
||||
const msg = el("p.msg");
|
||||
|
||||
function syncKind() {
|
||||
socksURL.closest("label").hidden = kind.value !== "socks";
|
||||
conf.closest("label").hidden = kind.value !== "wireguard";
|
||||
}
|
||||
kind.addEventListener("change", syncKind);
|
||||
|
||||
const form = el("form",
|
||||
el("div.grid",
|
||||
el("label", el("span.lbl", { text: "Name (slug)" }), name),
|
||||
el("label", el("span.lbl", { text: "Kind" }), kind),
|
||||
el("label.inline-check", enabled, el("span", { text: "Auto-start with streamd serve" })),
|
||||
el("label.span2", el("span.lbl", { text: "SOCKS/HTTP URL" }), socksURL),
|
||||
el("label.span2", el("span.lbl", { text: "WireGuard client config" }), conf,
|
||||
el("small.hint", { text: isEdit ? "Leave blank to keep the stored conf. Pasting replaces it." : "Paste a client .conf (e.g. vps-london.conf). Private keys stay on the server." })),
|
||||
),
|
||||
msg,
|
||||
el("div.row.end", { style: { marginTop: "12px" } },
|
||||
el("button.ghost", { type: "button", text: "Cancel", onclick: () => close() }),
|
||||
el("button", { type: "submit", text: isEdit ? "Save" : "Create" }),
|
||||
),
|
||||
);
|
||||
syncKind();
|
||||
|
||||
form.addEventListener("submit", async (ev) => {
|
||||
ev.preventDefault();
|
||||
msg.textContent = "";
|
||||
msg.classList.remove("err");
|
||||
const slug = name.value.trim();
|
||||
try {
|
||||
if (isEdit) {
|
||||
const body = { kind: kind.value, enabled: enabled.checked };
|
||||
if (kind.value === "socks") body.socks_url = socksURL.value.trim();
|
||||
if (kind.value === "wireguard" && conf.value.trim()) body.conf = conf.value;
|
||||
await api.saveEgress(existing.name, body);
|
||||
} else {
|
||||
const body = { name: slug, kind: kind.value, enabled: enabled.checked };
|
||||
if (kind.value === "socks") body.socks_url = socksURL.value.trim();
|
||||
await api.createEgress(body);
|
||||
if (kind.value === "wireguard" && conf.value.trim()) {
|
||||
await api.saveEgress(slug, { conf: conf.value });
|
||||
}
|
||||
}
|
||||
toast(isEdit ? "Saved" : "Created");
|
||||
close();
|
||||
onDone();
|
||||
} catch (err) {
|
||||
msg.textContent = err.message;
|
||||
msg.classList.add("err");
|
||||
}
|
||||
});
|
||||
|
||||
const close = openModal(
|
||||
el("h2", { text: isEdit ? `Edit egress · ${existing.name}` : "Add egress profile" }),
|
||||
form,
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- people and API keys ----------
|
||||
|
||||
export function peopleView(root) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue