"use client"; // NETWORK EXITS on /settings (lane network-exits). Every control is the twin // of a `pnpm ops` call and gets the same refusals: // Save exit / Enable / Disable network {"upsertExit": {...}} // Remove network {"removeExit": ""} // a platform's Save / Clear network {"platforms": {"

": {...} | null}} // Echo URL Save network {"echoUrl": "..."} // Startup probe on / off network {"startupProbe": true | false} // Probe exits get network --probe // Assign network-exit {"slug", "exit"} // No proxy credentials ever reach this page: an exit is scheme, host, port // and "credentials: yes/no"; the user and password live in the key file // network.credentialsFile names (one NETWORK_EXIT_=user:password line). import { useState, useTransition } from "react"; import { assignChannelExitAction, probeNetworkAction, saveNetworkAction, type NetworkReport, } from "../networkActions"; const BUTTON = "rounded-md border border-border px-2 py-1 text-xs hover:bg-muted disabled:opacity-50"; const INPUT = "rounded-md border border-border bg-background px-2 py-1 text-sm"; const TRIAL_PLATFORMS = ["rumble", "twitch"] as const; function probeText(p: NetworkReport["exits"][number]["probe"]): string { if (!p) return "not probed"; if (!p.reachable) return `unreachable: ${p.reason ?? "?"}`; const addr = p.address ? `, shows ${p.address}` : p.echoError ? `, echo failed: ${p.echoError}` : ""; return `answers${p.ms !== undefined ? ` (${p.ms} ms)` : ""}${addr}`; } export function NetworkExitsSection({ initial }: { initial: NetworkReport }) { const [report, setReport] = useState(initial); const [error, setError] = useState(null); const [pending, start] = useTransition(); const [draft, setDraft] = useState({ id: "", label: "", proxy: "", credentials: false }); const [echoUrl, setEchoUrl] = useState(initial.echoUrl); const [assign, setAssign] = useState({ slug: "", exit: "direct" }); const exits = report.exits.filter((e) => e.id !== "direct"); const run = (fn: () => Promise<{ ok: true; report: NetworkReport } | { ok: false; error: string }>) => start(async () => { setError(null); const r = await fn(); if (r.ok) setReport(r.report); else setError(r.error); }); const save = (body: Record) => run(() => saveNetworkAction(body)); const policyExits = (p: string): string[] => report.platforms[p]?.exits ?? []; const togglePolicy = (p: string, id: string, on: boolean) => { const cur = policyExits(p); const next = on ? [...cur, id] : cur.filter((x) => x !== id); save({ platforms: { [p]: next.length ? { exits: next, mode: "sticky", kinds: ["listing"] } : null } }); }; const counts = Object.entries(report.usage["7d"]).sort(([a], [b]) => a.localeCompare(b)); return (

Network exits

Trial: rumble and twitch listings only. Logged-in requests stay direct. Not a disguise: no fingerprint or user-agent changes.

{report.exits.map((e) => ( ))}
Exit Proxy Probe
{e.id} {e.label !== e.id && {e.label}} {!e.enabled && (disabled)} {e.display} {e.channels > 0 && · {e.channels} channel{e.channels === 1 ? "" : "s"}} {probeText(e.probe)} {e.id !== "direct" && ( )}
{ ev.preventDefault(); save({ upsertExit: { id: draft.id.trim(), label: draft.label.trim() || draft.id.trim(), proxy: draft.proxy.trim(), credentials: draft.credentials, }, }); }} >
{TRIAL_PLATFORMS.map((p) => (
{p} {["direct", ...exits.map((e) => e.id)].map((id) => ( ))} {report.platforms[p] ? ( listings spread over {report.platforms[p]!.pool?.join(", ") || "no enabled exit (direct)"} {report.platforms[p]!.allRest ? " — every exit rests" : ""} ) : ( no policy: direct )}
))}
{ ev.preventDefault(); run(() => assignChannelExitAction(assign.slug.trim(), assign.exit)); }} >

Credentials: {report.credentialsFile} (mode 600), one{" "} NETWORK_EXIT_<ID>=user:password line per exit, percent-encoded.

{report.settingsProblem && (

{report.settingsProblem}

)} {report.rests.length > 0 && ( )} {counts.length > 0 && ( {counts.map(([k, c]) => ( ))}
Platform / exit Requests 1d / 7d 429s Bot checks Rests Proxy failures
{k} {report.usage["1d"][k]?.requests ?? 0} / {c.requests} {c.rateLimits} {c.botChecks} {c.rests} {c.proxyFailures}
)} {error && (

{error}

)}
); }