Hub 2.11.0: ports checked on both servers before an install; frp config on each server's page
- A new install reserves candidate ports, asks the central and church servers which are free (probe-ports), and runs on the first pair free on both (3 rounds, then called off). - Each server's page reads and changes frps's / frpc's config (agent 1.4.0): secrets stay on the server, two-factor, verify, backup, restart, put back if frp doesn't start. - Alerts name the config file the agent uses; a missing config gets its own alert. - Vendors contracts 1.15.0. Migration 20261121110000_server_frp_config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,8 @@ function serverSummary(s, now = new Date()) {
|
||||
versions: st?.versions || null,
|
||||
frpcRunning: st?.frpcRunning ?? null,
|
||||
central: st?.central || null,
|
||||
// Agent 1.4.0+: the frp config it uses (null: none found; undefined: an older agent).
|
||||
frpConfigPath: st?.frpConfigPath ?? (st && 'frpConfigPath' in st ? null : undefined),
|
||||
deployments: s.deployments ? s.deployments.filter(d => d.status !== 'removed').length : undefined,
|
||||
alerts: s.alerts ? s.alerts.map(a => ({ type: a.type, level: a.level, message: a.message, createdAt: a.createdAt })) : undefined,
|
||||
};
|
||||
@@ -103,9 +105,39 @@ router.get('/servers/:id', wrap(async (req, res) => {
|
||||
jobs: recentJobs,
|
||||
alerts: s.alerts,
|
||||
ports: s.ports,
|
||||
frp: await frpState(s),
|
||||
}));
|
||||
}));
|
||||
|
||||
// ─── frp's config (Hub 2.11.0, agent 1.4.0) ───────────────────────────────────
|
||||
|
||||
/** The frp card on a server's page: the path set here, the last read, and a read or change on its way. */
|
||||
async function frpState(s) {
|
||||
const pending = await prisma.job.findFirst({ where: { serverId: s.id, type: { in: ['frp-read', 'frp-write'] }, status: { in: ['queued', 'delivered'] } }, orderBy: { createdAt: 'desc' }, select: { id: true, type: true, status: true } });
|
||||
const last = await prisma.job.findFirst({ where: { serverId: s.id, type: { in: ['frp-read', 'frp-write'] }, status: { notIn: ['queued', 'delivered', 'scheduled'] } }, orderBy: { createdAt: 'desc' }, select: { id: true, type: true, status: true, message: true, finishedAt: true } });
|
||||
return {
|
||||
service: s.mode === 'central' ? 'frps' : 'frpc',
|
||||
path: s.frpConfigPath,
|
||||
read: s.frpConfig || null,
|
||||
pending,
|
||||
last,
|
||||
minAgent: agent.FRP_JOBS_MIN_AGENT,
|
||||
hidden: agent.FRP_HIDDEN,
|
||||
};
|
||||
}
|
||||
|
||||
router.post('/servers/:id/frp/read', wrap(async (req, res) => {
|
||||
const job = await jobs.readFrp(req.params.id, req.body && 'path' in req.body ? { path: req.body.path } : {}, req.admin);
|
||||
if (req.body && 'path' in req.body) await audit(req, 'server_frp_path_set', req.params.id, { path: req.body.path || null });
|
||||
res.status(201).json({ job });
|
||||
}));
|
||||
|
||||
router.post('/servers/:id/frp/write', wrap(async (req, res) => {
|
||||
const job = await jobs.writeFrp(req.params.id, { content: req.body?.content, restart: req.body?.restart !== false, totp: req.body?.totp }, req.admin);
|
||||
await audit(req, 'server_frp_config_changed', req.params.id, { path: job.args.path, restart: job.args.restart });
|
||||
res.status(201).json({ job });
|
||||
}));
|
||||
|
||||
router.patch('/servers/:id', wrap(async (req, res) => {
|
||||
const data = {};
|
||||
if (req.body?.name != null) data.name = String(req.body.name).trim().slice(0, 100) || undefined;
|
||||
|
||||
Reference in New Issue
Block a user