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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user