43349579e1
* feat(wireguard): WireGuard peer manager UI with QR, .conf download, and per-client exit node selection
- models/wg_peer.js — Redis-backed peer store with auto IP allocation (10.100.0.x)
- models/wg_site.js — Redis-backed exit node store (admin-managed sites)
- utils/wg_keys.js — X25519 keypair gen via Node crypto (no wg binary needed)
- utils/wg_conf.js — client wg0.conf renderer
- routes/wireguard.js — REST API: CRUD sites/peers, GET /conf, GET /qr (QRCode PNG)
- views/wireguard.ejs — full dark-mode UI: exit node table, peer table, QR modal,
.conf download, exit node picker per client
- conf/base.js — conf.wireguard block (serverPublicKey, serverEndpoint, dns, poolBase)
- Nav: WireGuard link added (admin-gated)
- No wg binary dep in Node process — key gen is pure JS X25519
* fix(test): update test script to run unit tests without native bcrypt binary dependency in CI
* fix(ui): replace native browser alert/confirm with app.messages in WireGuard view
53 lines
2.2 KiB
JavaScript
53 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const express = require('express');
|
|
const router = require('express').Router();
|
|
const conf = require('@simpleworkjs/conf');
|
|
const buildInfo = require('../utils/build_info');
|
|
const registry = require('../services/session_registry');
|
|
const { safeInternalPath } = require('@simpleworkjs/oidc-client');
|
|
const { mountStaticModules } = require('@simpleworkjs/app-stack');
|
|
|
|
const values = {
|
|
title: conf.environment !== 'production' ? 'dev' : '',
|
|
titleIcon: conf.environment !== 'production' ? '<i class="fa-brands fa-dev"></i>' : '',
|
|
name: conf.name,
|
|
logo: conf.logo,
|
|
// The SSH front door's port -- the dashboard's "quick jump" copy buttons
|
|
// need this to build a real, working `ssh ...` command (the web UI and
|
|
// SSH front door share a hostname but not a port).
|
|
sshPort: (conf.ssh && conf.ssh.listenPort) || 22,
|
|
...buildInfo,
|
|
};
|
|
|
|
// Serve front-end vendor libraries straight from node_modules (same convention
|
|
// as the sibling apps), and the app's own JS/CSS/img from public/.
|
|
mountStaticModules(router, {
|
|
root: path.join(__dirname, '..'),
|
|
deps: ['bootstrap', 'mustache', 'jquery', '@fortawesome', 'moment', 'jq-repeat', '@simpleworkjs/frontend'],
|
|
});
|
|
|
|
// Liveness probe — no auth.
|
|
router.get('/health', (req, res) => {
|
|
res.json({status: 'ok', activeSessions: registry.count(), buildVersion: buildInfo.buildVersion, buildHash: buildInfo.buildHash});
|
|
});
|
|
|
|
router.get('/', (req, res) => res.redirect(302, '/dashboard'));
|
|
|
|
// Page shells. The client framework (app-base.js + app.js) loads data via the
|
|
// authenticated /api/* endpoints and gates the UI on /api/user/me, so these
|
|
// render unauthenticated (like the sibling apps) and the client redirects to
|
|
// /login when there's no valid session.
|
|
router.get('/login', (req, res) => res.render('login', {
|
|
...values,
|
|
redirect: safeInternalPath(req.query.redirect || '/'),
|
|
oidcEnabled: !!(conf.oidc && conf.oidc.enabled),
|
|
}));
|
|
router.get('/dashboard', (req, res) => res.render('dashboard', {...values}));
|
|
router.get('/sessions', (req, res) => res.render('sessions', {...values}));
|
|
router.get('/audit', (req, res) => res.render('audit', {...values}));
|
|
router.get('/wireguard', (req, res) => res.render('wireguard', {...values}));
|
|
|
|
module.exports = router;
|