Hub 2.20.0: port list labels; frps allow_ports checked against it
- GET /api/admin/ports names each port's install (church, product, web/API, domain); the port list shows it, linked to the install, and says which ports are held for a port check. - A church server's hand-written frpc tunnels are listed as taken (note: frpc tunnel "<name>" on <server>) on each frp-read/frp-write, and taken off when they leave the file. - Central servers: allow_ports must cover the port range and every listed port outside it. An allow_ports alert names what's missing and the value to set; the frp card warns, and Edit has "Use the Hub's allow_ports" (INI or TOML). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.19.0",
|
||||
"version": "2.20.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.19.0",
|
||||
"version": "2.20.0",
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.536.0",
|
||||
"next": "^15.5.24",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.19.0",
|
||||
"version": "2.20.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3200",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { Plus, Trash2 } from "lucide-react";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { fmtDate } from "@/lib/format";
|
||||
@@ -9,7 +10,30 @@ import { Field, Fields, FormError, Loading, Modal, ModalButtons, PageMessage, Pa
|
||||
import { ServersNav } from "@/components/servers";
|
||||
|
||||
type Msg = { type: "ok" | "err"; text: string } | null;
|
||||
type Port = { port: number; role: string; note: string | null; releasedAt: string | null; deploymentId: string | null; server: { id: string; name: string } | null };
|
||||
type Port = {
|
||||
port: number; role: string; note: string | null; releasedAt: string | null; deploymentId: string | null; server: { id: string; name: string } | null;
|
||||
deployment: { id: string; shortName: string; product: string; productName: string; domain: string; status: string } | null;
|
||||
};
|
||||
|
||||
const ROLE: Record<string, string> = { web: "web", api: "API" };
|
||||
|
||||
/** Hub 2.20.0: what a port is used for: the install and its part, a port check, or something else. */
|
||||
function PortUse({ p }: { p: Port }) {
|
||||
const d = p.deployment;
|
||||
const freeFrom = p.releasedAt ? fmtDate(new Date(new Date(p.releasedAt).getTime() + 30 * 24 * 3600 * 1000), false) : null;
|
||||
if (d && (p.role === "web" || p.role === "api")) {
|
||||
return (
|
||||
<div>
|
||||
<Link className="text-indigo-700 hover:underline" href={`/servers/installs/${d.id}`}>{d.shortName} · {d.productName} {ROLE[p.role]}</Link>
|
||||
<div className="text-xs text-slate-500">{d.domain}{freeFrom ? ` · uninstalled, free from ${freeFrom}` : d.status !== "live" ? ` · ${d.status}` : ""}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (freeFrom) return <>free from {freeFrom}</>;
|
||||
if (p.role === "candidate") return <span className="text-slate-500">held for an install's port check</span>;
|
||||
if (p.role === "taken") return <>taken{p.note ? "" : " (by hand)"}</>;
|
||||
return <>{ROLE[p.role] || p.role}</>;
|
||||
}
|
||||
|
||||
type Defaults = { defaults: [string, string][]; range: { from: string; to: string }; ip: string };
|
||||
|
||||
@@ -124,12 +148,12 @@ export default function ServerSettingsPage() {
|
||||
<h2 className="font-medium">Port list</h2>
|
||||
<button type="button" className="btn-secondary px-2.5 py-1.5" onClick={() => setPopup("port")}><Plus className="h-3.5 w-3.5" /> Mark as taken</button>
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-slate-500">Every port frps opens on the central server must be unique across servers. Mark ports used by anything else (today's tunnels written by hand) as taken.</p>
|
||||
<p className="mt-1 text-sm text-slate-500">Every port frps opens on the central server must be unique across servers. A church server's frpc tunnels written by hand are listed as taken each time its frp config is read (Servers → the server → frp config → Read now); mark anything else as taken by hand. frps's allow_ports must cover the port range and every listed port outside it: the central server's page warns when it doesn't.</p>
|
||||
{!ports ? <Loading /> : (
|
||||
<table className="mt-3 w-full text-sm tabular-nums">
|
||||
<thead><tr className="text-left text-xs text-slate-500"><th className="py-1">Port</th><th>Use</th><th>Server</th><th>Note</th><th /></tr></thead>
|
||||
<tbody>{portsPaged.rows.map(p => (
|
||||
<tr key={p.port} className="border-t"><td className="py-1.5">{p.port}</td><td>{p.releasedAt ? `free from ${fmtDate(new Date(new Date(p.releasedAt).getTime() + 30 * 24 * 3600 * 1000), false)}` : p.role}</td><td>{p.server?.name || "–"}</td><td className="text-xs text-slate-500">{p.note}</td>
|
||||
<tr key={p.port} className="border-t"><td className="py-1.5">{p.port}</td><td className="py-1.5"><PortUse p={p} /></td><td>{p.server?.name || "–"}</td><td className="text-xs text-slate-500">{p.note}</td>
|
||||
<td>{(p.role === "taken" || p.releasedAt) && <button className="btn-secondary px-2 py-1 text-xs" onClick={() => free(p.port)}>Remove</button>}</td></tr>
|
||||
))}</tbody>
|
||||
</table>
|
||||
|
||||
@@ -29,6 +29,8 @@ export type FrpState = {
|
||||
last: { id: string; type: string; status: string; message: string | null; finishedAt: string | null } | null;
|
||||
minAgent: string;
|
||||
hidden: string;
|
||||
/** Hub 2.20.0, central servers: what allow_ports must cover, what it leaves out, and the file fixed. */
|
||||
allowPorts?: { needed: string; missing: string; suggested: string | null; fixedContent: string | null } | null;
|
||||
};
|
||||
|
||||
type Msg = { type: "ok" | "err"; text: string } | null;
|
||||
@@ -64,6 +66,12 @@ function FrpEditModal({ serverId, frp, read, onClose, onSent }: { serverId: stri
|
||||
return (
|
||||
<Modal title={<>Edit <span className="font-mono">{read.path}</span></>} onClose={onClose} dirty={edited} wide>
|
||||
<form className="space-y-3" onSubmit={save}>
|
||||
{frp.allowPorts?.fixedContent && (
|
||||
<div className="flex flex-wrap items-center gap-2 rounded-lg border border-amber-200 bg-amber-50 p-2 text-sm text-amber-900">
|
||||
<span className="flex-1">allow_ports leaves out <b>{frp.allowPorts.missing}</b>. The Hub's value: <span className="font-mono">{frp.allowPorts.suggested}</span></span>
|
||||
<button type="button" className="btn-secondary px-2 py-1 text-xs" disabled={edited} title={edited ? "Only on the file as read (undo your edits first)" : undefined} onClick={() => setContent(frp.allowPorts!.fixedContent!)}>Use the Hub's allow_ports</button>
|
||||
</div>
|
||||
)}
|
||||
<textarea className="input h-80 w-full font-mono text-xs" spellCheck={false} value={content} onChange={e => setContent(e.target.value)} aria-label={`${frp.service} config`} />
|
||||
<p className="text-xs text-slate-500">
|
||||
Secret values ({read.hidden.length ? read.hidden.join(", ") : "none here"}) never leave the server: they show as <code>{frp.hidden}</code> and the server's own value is put back when you save. Secrets are changed on the server, not here.
|
||||
@@ -140,6 +148,12 @@ export function FrpConfig({ serverId, agentVersion, frp, onChange }: { serverId:
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{read?.found && frp.allowPorts?.missing && (
|
||||
<p className="text-sm text-amber-800">
|
||||
allow_ports doesn't allow <b>{frp.allowPorts.missing}</b> (the Hub's port range and the listed ports outside it), so frps refuses tunnels there.
|
||||
Set it to <span className="font-mono">{frp.allowPorts.suggested}</span>: Edit → Use the Hub's allow_ports, then save with a restart.
|
||||
</p>
|
||||
)}
|
||||
{frp.last && frp.last.status !== "succeeded" && (
|
||||
<p className="text-sm text-red-700">Last {frp.last.type === "frp-write" ? "change" : "read"}: <StatusPill status={frp.last.status} /> {frp.last.message} <Link className="text-indigo-700 hover:underline" href={`/jobs/${frp.last.id}`}>Open</Link></p>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user