sam 45f4c9859d Add Authelia auth gateway, portal landing page, and subpath routing
Adds Authelia (forward-auth) and nginx portal container for single-endpoint
authenticated access via Caddy reverse proxy. Configures Grafana auth proxy
for header-based auto-login. Updates Vue UI base paths and API routes for
/exabgp/ and /traffic/ subpath serving. Adds traffic-gen responder container
on dedicated Docker network.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-15 14:23:09 -07:00

49 lines
1.7 KiB
JavaScript

const BASE = '/traffic/api'
async function req(method, path, body) {
const opts = { method, headers: { 'Content-Type': 'application/json' } }
if (body) opts.body = JSON.stringify(body)
const r = await fetch(BASE + path, opts)
if (!r.ok) throw new Error(`${method} ${path} -> ${r.status}`)
return r.json()
}
export const api = {
health: () => req('GET', '/healthz'),
interfaces: () => req('GET', '/interfaces'),
mode: () => req('GET', '/mode'),
setMode: (mode) => req('POST', '/mode', { mode }),
// Flows
flows: () => req('GET', '/flows'),
createFlow: (f) => req('POST', '/flows', f),
getFlow: (id) => req('GET', `/flows/${id}`),
updateFlow: (id, f) => req('PUT', `/flows/${id}`, f),
deleteFlow: (id) => req('DELETE', `/flows/${id}`),
startFlow: (id) => req('POST', `/flows/${id}/start`),
stopFlow: (id) => req('POST', `/flows/${id}/stop`),
flowStats: (id) => req('GET', `/flows/${id}/stats`),
// Tests
tests: () => req('GET', '/tests'),
createTest: (t) => req('POST', '/tests', t),
getTest: (id) => req('GET', `/tests/${id}`),
startTest: (id) => req('POST', `/tests/${id}/start`),
stopTest: (id) => req('POST', `/tests/${id}/stop`),
testResults: (id) => req('GET', `/tests/${id}/results`),
// Presets
presets: () => req('GET', '/presets'),
loadPreset: (name, overrides) => req('POST', `/presets/${name}`, overrides),
// Stats
statsHistory: () => req('GET', '/stats/history'),
// Ping
ping: (target, count) => req('POST', '/ping', { target, count: count || 5 }),
// Responder
responderStats: () => req('GET', '/responder/stats'),
responderReset: () => req('POST', '/responder/reset'),
}