Enables the CCP to manage CML instances on remote servers via a lightweight HTTP agent. Key components: - ExecutionDriver abstraction (local-driver.ts / remote-driver.ts) routes operations to local Docker or remote agent transparently - Remote agent package (agent/) with mTLS authentication, Docker Compose operations, file management, backup/upgrade delegation - Certificate service using openssl CLI for CA management and cert issuance - Phone-home registration: remote agents register via invite code, CCP admin approves, agent receives mTLS cert bundle automatically - config.sh integration with configure_control_panel() section - ccp-agent Docker Compose service (profile-gated) - Frontend: AgentRegistrationsPage, InviteCodesPage, Remote Agents sidebar menu - Security hardened: cert bundle wiped after delivery, shell injection prevention via execFile, command allowlist with metachar rejection, rate-limited public endpoints, auto-populated fingerprint pinning Also wires ENABLE_SOCIAL/PEOPLE/ANALYTICS through env.ts, seed.ts, and docker-compose env passthrough (from previous session). Bunker Admin
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { Router, Request, Response } from 'express';
|
|
import { param } from '../utils/params';
|
|
import { registerSlug, unregisterSlug, listSlugs } from '../services/registry.service';
|
|
|
|
const router = Router();
|
|
|
|
// POST /instances/register — Register a slug→basePath mapping
|
|
router.post('/instances/register', async (req: Request, res: Response) => {
|
|
const { slug, basePath, composeProject } = req.body;
|
|
if (!slug || !basePath || !composeProject) {
|
|
res.status(400).json({ error: 'VALIDATION', message: 'slug, basePath, and composeProject required' });
|
|
return;
|
|
}
|
|
await registerSlug(slug, basePath, composeProject);
|
|
res.json({ registered: slug });
|
|
});
|
|
|
|
// DELETE /instances/:slug — Unregister slug
|
|
router.delete('/instances/:slug', async (req: Request, res: Response) => {
|
|
await unregisterSlug(param(req, 'slug'));
|
|
res.json({ unregistered: param(req, 'slug') });
|
|
});
|
|
|
|
// GET /instances — List all managed slugs
|
|
router.get('/instances', async (_req: Request, res: Response) => {
|
|
const slugs = await listSlugs();
|
|
res.json(slugs);
|
|
});
|
|
|
|
export default router;
|