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:
2026-11-23 13:45:30 +02:00
co-authored by Claude Opus 5.5
parent 11c3259dab
commit 308d4e42ba
13 changed files with 391 additions and 12 deletions
+25 -1
View File
@@ -11,6 +11,8 @@ const { audit } = require('../utils/audit');
const { getSettings, setSettings } = require('../utils/settings');
const servers = require('../utils/servers');
const jobs = require('../utils/jobs');
const frpPorts = require('../utils/frpPorts');
const { PRODUCT_NAMES } = require('../utils/products');
const { latestAgentVersion } = require('../utils/releases');
const { pageOf, paged } = require('../utils/paging');
@@ -126,6 +128,21 @@ async function frpState(s) {
last,
minAgent: agent.FRP_JOBS_MIN_AGENT,
hidden: agent.FRP_HIDDEN,
allowPorts: await allowPortsState(s),
};
}
/**
* Hub 2.20.0, central servers: what allow_ports must cover (the port range and listed ports
* outside it), what the last read file leaves out, and that file with it fixed (for the editor).
*/
async function allowPortsState(s) {
if (s.mode !== 'central') return null;
const read = s.frpConfig?.found ? s.frpConfig : null;
const check = await servers.allowPortsCheck(read ? read.allowPorts : (s.lastStats?.central?.allowPorts ?? null));
return {
...check,
fixedContent: read && check.missing ? frpPorts.withAllowPorts(read.content, read.format, check.suggested) : null,
};
}
@@ -315,7 +332,14 @@ router.post('/jobs/:id/extend', wrap(async (req, res) => {
// ─── The port list and install defaults ───────────────────────────────────────
router.get('/ports', wrap(async (req, res) => {
const [ports, range] = await Promise.all([prisma.port.findMany({ orderBy: { port: 'asc' }, include: { server: { select: { id: true, name: true } } } }), servers.portRange()]);
const [rows, range] = await Promise.all([prisma.port.findMany({ orderBy: { port: 'asc' }, include: { server: { select: { id: true, name: true } } } }), servers.portRange()]);
// Hub 2.20.0: which install each port is for (Port has no relation to Deployment).
const ids = [...new Set(rows.map(r => r.deploymentId).filter(Boolean))];
const deployments = new Map((ids.length ? await prisma.deployment.findMany({ where: { id: { in: ids } } }) : []).map(d => [d.id, d]));
const ports = rows.map(r => {
const d = r.deploymentId ? deployments.get(r.deploymentId) : null;
return { ...r, deployment: d ? { id: d.id, shortName: d.shortName, product: d.product, productName: PRODUCT_NAMES[d.product] || d.product, domain: d.domain, status: d.status } : null };
});
res.json({ ports, range });
}));