feat: rebranded from vpn-router to linux-manager.
This commit is contained in:
1 parent
8efe21bfa6
commit
85a1ffa21f
238 files changed
+5010
-3761
No files matched your search
@@ -11,11 +11,11 @@ import { useEffect, useState, type FormEvent } from 'react'
|
||||
import OtpDialog from './OtpDialog.tsx'
|
||||
import PasskeyDialog from './PasskeyDialog.tsx'
|
||||
import ProfileDialog from './ProfileDialog.tsx'
|
||||
import { Section } from './RouterPanel.tsx'
|
||||
import { Section } from './ServerPanel.tsx'
|
||||
import { ACCOUNT_SHAPE, CODE_PATTERN, USER_SHAPE, request, type Account, type User } from './api.ts'
|
||||
|
||||
/**
|
||||
* The account of the signed-in user, from the router's /account, in two columns: the details with Change password,
|
||||
* The account of the signed-in user, from the server's /account, in two columns: the details with Change password,
|
||||
* which opens the password dialog, and the passkeys in the first row, the enrolment for one-time passwords and the
|
||||
* OpenVPN and the Apple VPN profile of a user with a certificate in the second. Each change but the removal of a
|
||||
* passkey takes the current password and, for an enrolled user, a current code. A changed password ends the session,
|
||||
|
||||
+39
-17
@@ -17,7 +17,7 @@ import DnsPanel from './DnsPanel.tsx'
|
||||
import PageMenu, { CA_PATH, DOCKER_PATH, REMOTE_ACCESS_PATH, SHELL_PATH, SITES_PATH, SITE_TO_SITE_PATH, USERS_PATH, USER_PATH } from './PageMenu.tsx'
|
||||
import NetworkPanel from './NetworkPanel.tsx'
|
||||
import RemoteAccessPanel from './RemoteAccessPanel.tsx'
|
||||
import RouterPanel from './RouterPanel.tsx'
|
||||
import ServerPanel from './ServerPanel.tsx'
|
||||
import ServiceAccountsPanel from './ServiceAccountsPanel.tsx'
|
||||
import SettingsButton from './SettingsButton.tsx'
|
||||
import ShellPanel from './ShellPanel.tsx'
|
||||
@@ -30,7 +30,8 @@ import SiteToSiteStatusPanel from './SiteToSiteStatusPanel.tsx'
|
||||
import ThemeMenu from './ThemeMenu.tsx'
|
||||
import UsersPanel from './UsersPanel.tsx'
|
||||
import {
|
||||
ACCOUNT_SHAPE, SESSION_EXPIRED, SESSION_SHAPE, request, type Account, type Info, type RemoteAccessSystem, type Session,
|
||||
ACCOUNT_SHAPE, DETAILS_SHAPE, SESSION_EXPIRED, SESSION_SHAPE, request, type Account, type Info, type RemoteAccessSystem,
|
||||
type RouterDetails, type Session,
|
||||
} from './api.ts'
|
||||
|
||||
/** The tabs of the Router page, router being the Overview tab, of the Identities page, of the Connectivity page and of the Web Sites page. */
|
||||
@@ -43,7 +44,7 @@ type SitesView = 'sites' | 'files' | 'dns'
|
||||
const SITES_TOPICS: Record<SitesView, string> = { sites: 'sites.md', files: 'site-files.md', dns: 'dns.md' }
|
||||
|
||||
/** The prefix of the sessionStorage keys of the pages the account and the shell page were opened from, by their paths. */
|
||||
const RETURN_KEY = 'vpn-router-manager.return:'
|
||||
const RETURN_KEY = 'linux-manager-ui.return:'
|
||||
|
||||
/** The pages of an administrator besides Router, which every other path shows. */
|
||||
const PAGE_PATHS = [USER_PATH, USERS_PATH, SITE_TO_SITE_PATH, REMOTE_ACCESS_PATH, CA_PATH, SITES_PATH, DOCKER_PATH, SHELL_PATH]
|
||||
@@ -59,14 +60,14 @@ const HELP_TOPICS: Record<string, string> = {
|
||||
}
|
||||
|
||||
/** The localStorage key of whether the help is open. */
|
||||
const HELP_KEY = 'vpn-router-manager.help'
|
||||
const HELP_KEY = 'linux-manager-ui.help'
|
||||
|
||||
/**
|
||||
* The page asks for a sign-in until a session exists. At USER_PATH, and for a user who is not a member of admins at
|
||||
* every path, it then shows the user's own account; at USERS_PATH the router's users, groups or service accounts; at
|
||||
* every path, it then shows the user's own account; at USERS_PATH the server's users, groups or service accounts; at
|
||||
* SITE_TO_SITE_PATH its site-to-site connections, their state and its network with its routes; at REMOTE_ACCESS_PATH its IKEv2, OpenVPN and
|
||||
* WireGuard access; at CA_PATH its certificates; at SITES_PATH its web
|
||||
* sites, the files of a site, opened from the sites too, and its name server; at DOCKER_PATH the state of Docker; at SHELL_PATH a shell on the router; otherwise the state of the router, with the update information of its packages in
|
||||
* sites, the files of a site, opened from the sites too, and its name server; at DOCKER_PATH the state of Docker; at SHELL_PATH a shell on the server; otherwise the state of the server, with the update information of its packages in
|
||||
* the Status panel, its metrics, its logs, its backups or the updates of its system's packages. A page shows one tab at a time, each read only while shown. An
|
||||
* administrator switches pages with the page menu at the right end of the header; the button with the user's name,
|
||||
* left of Sign out, opens the user's own account, and an administrator's shell button, left of it, the shell; pressed
|
||||
@@ -84,6 +85,10 @@ export default function App(props: { info: Info }) {
|
||||
const [filesSite, setFilesSite] = useState<string | null>(null)
|
||||
const [session, setSession] = useState<Session | null | undefined>(undefined)
|
||||
const [role, setRole] = useState<{ name: string; admin: boolean } | null>(null)
|
||||
// The router and the VPN components as router.enabled and vpn.enabled of /config; null while not known, when every page shows.
|
||||
const [components, setComponents] = useState<{ router: boolean; vpn: boolean } | null>(null)
|
||||
const routerOff = components?.router === false
|
||||
const vpnOff = components?.vpn === false
|
||||
const page = PAGE_PATHS.find((path) => path === window.location.pathname) ?? '/'
|
||||
const userPage = page === USER_PATH
|
||||
const admin = session && role?.name === session.name ? role.admin : undefined
|
||||
@@ -129,6 +134,18 @@ export default function App(props: { info: Info }) {
|
||||
.catch(() => setRole({ name: session.name, admin: false }))
|
||||
}, [session])
|
||||
|
||||
useEffect(() => {
|
||||
if (!admin) {
|
||||
return
|
||||
}
|
||||
request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
|
||||
.then((details) => setComponents({
|
||||
router: details.configuration.router?.enabled === true,
|
||||
vpn: details.configuration.vpn?.enabled === true,
|
||||
}))
|
||||
.catch(() => setComponents(null))
|
||||
}, [admin])
|
||||
|
||||
/** Opens the page of the path, keeping the page it was opened from in sessionStorage, or returns to that page from it. */
|
||||
function toggle(path: string) {
|
||||
if (page === path) {
|
||||
@@ -159,14 +176,14 @@ export default function App(props: { info: Info }) {
|
||||
<Box>
|
||||
<Stack direction="row" sx={{ alignItems: 'baseline', gap: 1 }}>
|
||||
<Typography variant="h5" component="h1">
|
||||
VPN Router Manager
|
||||
Ubuntu Linux Manager
|
||||
</Typography>
|
||||
<Typography variant="caption" color="text.secondary" sx={{ fontFamily: 'monospace' }}>
|
||||
{props.info.version ?? 'development'}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
|
||||
Router status page:{' '}
|
||||
Server status page:{' '}
|
||||
{props.info.status_url
|
||||
? <Link href={props.info.status_url} target="_blank" rel="noreferrer">{props.info.status_url}</Link>
|
||||
: <b>not configured</b>}
|
||||
@@ -220,7 +237,7 @@ export default function App(props: { info: Info }) {
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
{session && admin && <PageMenu path={page} />}
|
||||
{session && admin && <PageMenu path={page} hidden={vpnOff ? [REMOTE_ACCESS_PATH] : []} />}
|
||||
</Stack>
|
||||
</Stack>
|
||||
{session === undefined && <CircularProgress />}
|
||||
@@ -264,7 +281,12 @@ export default function App(props: { info: Info }) {
|
||||
<ShellPanel editorShown={editorShown} onFiles={showFiles} onOpened={showEditor} />
|
||||
</>
|
||||
)}
|
||||
{session && admin && page === REMOTE_ACCESS_PATH && (
|
||||
{session && admin && page === REMOTE_ACCESS_PATH && vpnOff && (
|
||||
<Typography color="text.secondary">
|
||||
The VPN is off on this server: IKEv2, OpenVPN and WireGuard need vpn.enabled in the configuration.
|
||||
</Typography>
|
||||
)}
|
||||
{session && admin && page === REMOTE_ACCESS_PATH && !vpnOff && (
|
||||
<>
|
||||
<Tabs value={remoteAccessView} onChange={(_event, next: RemoteAccessSystem) => setRemoteAccessView(next)} sx={{ mb: 3, borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tab value="p2s" label="IKEv2" />
|
||||
@@ -276,14 +298,14 @@ export default function App(props: { info: Info }) {
|
||||
)}
|
||||
{session && admin && page === SITE_TO_SITE_PATH && (
|
||||
<>
|
||||
<Tabs value={siteToSiteView} onChange={(_event, next: SiteToSiteView) => setSiteToSiteView(next)} sx={{ mb: 3, borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tab value="status" label="Status" />
|
||||
<Tabs value={routerOff ? 'network' : siteToSiteView} onChange={(_event, next: SiteToSiteView) => setSiteToSiteView(next)} sx={{ mb: 3, borderBottom: 1, borderColor: 'divider' }}>
|
||||
{!routerOff && <Tab value="status" label="Status" />}
|
||||
<Tab value="network" label="Network" />
|
||||
<Tab value="connections" label="Connections" />
|
||||
{!routerOff && <Tab value="connections" label="Connections" />}
|
||||
</Tabs>
|
||||
{siteToSiteView === 'connections' && <SiteToSitePanel />}
|
||||
{siteToSiteView === 'status' && <SiteToSiteStatusPanel />}
|
||||
{siteToSiteView === 'network' && <NetworkPanel />}
|
||||
{!routerOff && siteToSiteView === 'connections' && <SiteToSitePanel />}
|
||||
{!routerOff && siteToSiteView === 'status' && <SiteToSiteStatusPanel />}
|
||||
{(routerOff || siteToSiteView === 'network') && <NetworkPanel />}
|
||||
</>
|
||||
)}
|
||||
{session && admin && page === USERS_PATH && (
|
||||
@@ -307,7 +329,7 @@ export default function App(props: { info: Info }) {
|
||||
<Tab value="backup" label="Backup" />
|
||||
<Tab value="system" label="System" />
|
||||
</Tabs>
|
||||
{view === 'router' && <RouterPanel />}
|
||||
{view === 'router' && <ServerPanel />}
|
||||
{view === 'metrics' && <MetricsPanel />}
|
||||
{view === 'logs' && <LogsPanel />}
|
||||
{view === 'backup' && <BackupPanel />}
|
||||
|
||||
@@ -25,11 +25,11 @@ const MODE_LABELS: Record<string, string> = {
|
||||
const FINGERPRINT = /^([0-9A-Fa-f]{2}:){31}[0-9A-Fa-f]{2}$/
|
||||
|
||||
/**
|
||||
* A dialog that edits the router's backup settings: whether backups run, the schedule and the target; for a local
|
||||
* folder, its path, the retention settings that apply to the schedule and the cloud copy with a remote of the router's
|
||||
* A dialog that edits the server's backup settings: whether backups run, the schedule and the target; for a local
|
||||
* folder, its path, the retention settings that apply to the schedule and the cloud copy with a remote of the server's
|
||||
* rclone.conf; for a Proxmox Backup Server, the repository, the token secret, the fingerprint, the namespace and the
|
||||
* key file; and whether the metrics database is included. An empty token secret keeps the current one. onSave sends
|
||||
* the settings and the secret; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* the settings and the secret; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function BackupDialog(props: {
|
||||
backup: Backup
|
||||
@@ -104,7 +104,7 @@ export default function BackupDialog(props: {
|
||||
value={settings.path}
|
||||
autoComplete="off"
|
||||
error={pathProblem !== ''}
|
||||
helperText={pathProblem || 'The folder of the archives on the router; it may be a mount.'}
|
||||
helperText={pathProblem || 'The folder of the archives on the server; it may be a mount.'}
|
||||
onChange={(event) => change({ path: event.target.value })}
|
||||
/>
|
||||
<Typography variant="subtitle2">Archives kept</Typography>
|
||||
@@ -186,7 +186,7 @@ export default function BackupDialog(props: {
|
||||
value={settings.pbs_keyfile}
|
||||
autoComplete="off"
|
||||
error={keyfileProblem !== ''}
|
||||
helperText={keyfileProblem || 'A key of proxmox-backup-client key create on the router; empty for none.'}
|
||||
helperText={keyfileProblem || 'A key of proxmox-backup-client key create on the server; empty for none.'}
|
||||
onChange={(event) => change({ pbs_keyfile: event.target.value.trim() })}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -5,19 +5,19 @@ import { Alert, Box, Button, Table, TableBody, TableCell, TableHead, TablePagina
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import BackupDialog from './BackupDialog.tsx'
|
||||
import { BackupChip, TARGET_LABELS, backupRows, when } from './BackupSummary.tsx'
|
||||
import { Pairs, Section, bytes } from './RouterPanel.tsx'
|
||||
import { Pairs, Section, bytes } from './ServerPanel.tsx'
|
||||
import SearchField, { matches } from './SearchField.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { ApiError, BACKUP_KEEPS, BACKUP_SCHEDULES, BACKUP_SETTINGS_SHAPE, BACKUP_SHAPE, STARTED_SHAPE, request, type Backup } from './api.ts'
|
||||
|
||||
/** The note shown after a change, which the router applies when vpn-router-setup has run again. */
|
||||
const APPLIED = 'The router applies the change in the background.'
|
||||
/** The note shown after a change, which the server applies when linux-manager-setup has run again. */
|
||||
const APPLIED = 'The server applies the change in the background.'
|
||||
|
||||
/** Seconds between reads while a backup runs or is starting. */
|
||||
const WATCH_SECONDS = 3
|
||||
|
||||
/**
|
||||
* The router's backups: the settings, the last run and the local archives, searched by name and time and shown a page at
|
||||
* The server's backups: the settings, the last run and the local archives, searched by name and time and shown a page at
|
||||
* a time; edit the settings and start a backup now.
|
||||
* While a backup runs, or after Run now until it has ended, the tab reads every WATCH_SECONDS.
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ export default function BackupPanel() {
|
||||
|
||||
return (
|
||||
<Box component="section">
|
||||
<Toolbar description="Backups of the router's configuration, keys, users and metrics.">
|
||||
<Toolbar description="Backups of the server's configuration, keys, users and metrics.">
|
||||
<Button variant="contained" startIcon={<Edit />} disabled={busy || backup === null} onClick={() => setEditing(true)}>
|
||||
Edit
|
||||
</Button>
|
||||
@@ -105,12 +105,12 @@ export default function BackupPanel() {
|
||||
{note && <Alert severity="info" sx={{ mb: 2 }} onClose={() => setNote(null)}>{note}</Alert>}
|
||||
{backup && settings && !local && !backup.client && (
|
||||
<Alert severity="warning" sx={{ mb: 2 }}>
|
||||
proxmox-backup-client is not installed on the router; install proxmox-backup-client-static from Proxmox's client repository.
|
||||
proxmox-backup-client is not installed on the server; install proxmox-backup-client-static from Proxmox's client repository.
|
||||
</Alert>
|
||||
)}
|
||||
{backup && settings && local && settings.rclone_remote && !(backup.rclone.installed && backup.rclone.config) && (
|
||||
<Alert severity="warning" sx={{ mb: 2 }}>
|
||||
{backup.rclone.installed ? 'The router has no /etc/vpn-router/rclone.conf.' : 'rclone is not installed on the router.'} The cloud copy fails until it has.
|
||||
{backup.rclone.installed ? 'The server has no /etc/linux-manager/rclone.conf.' : 'rclone is not installed on the server.'} The cloud copy fails until it has.
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Chip } from '@mui/material'
|
||||
import { bytes } from './RouterPanel.tsx'
|
||||
import { bytes } from './ServerPanel.tsx'
|
||||
import type { Backup, BackupState } from './api.ts'
|
||||
|
||||
/** The colour of each result of a backup run. */
|
||||
@@ -14,7 +14,7 @@ const RESULT_COLORS: Record<string, 'success' | 'warning' | 'error' | 'info'> =
|
||||
/** The labels of the backup targets. */
|
||||
export const TARGET_LABELS: Record<string, string> = { local: 'Local folder', pbs: 'Proxmox Backup Server' }
|
||||
|
||||
/** A time of the router in the browser's format, or a dash. */
|
||||
/** A time of the server in the browser's format, or a dash. */
|
||||
export function when(time: string | null | undefined) {
|
||||
return time ? new Date(time).toLocaleString() : '-'
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export function BackupChip(props: { state: BackupState | null }) {
|
||||
: <Chip size="small" label="never" variant="outlined" />
|
||||
}
|
||||
|
||||
/** The schedule, the next run (as systemd shows it) and the last run of the router's backups, as rows of Pairs. */
|
||||
/** The schedule, the next run (as systemd shows it) and the last run of the server's backups, as rows of Pairs. */
|
||||
export function backupRows(backup: Backup): [string, string][] {
|
||||
const { settings, state } = backup
|
||||
const rows: [string, string][] = [
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { ROUTER_TEMPLATES, type Pki } from './api.ts'
|
||||
|
||||
/** A request of POST /ca/certificates: a CSR to sign, or a subject and names for a key the router makes into a PFX file. */
|
||||
/** A request of POST /ca/certificates: a CSR to sign, or a subject and names for a key the server makes into a PFX file. */
|
||||
export type IssueRequest =
|
||||
| { ca: string; template: string; csr: string }
|
||||
| { ca: string; template: string; subject: string; sans: string[]; password: string }
|
||||
@@ -20,9 +20,9 @@ function listOf(text: string) {
|
||||
|
||||
/**
|
||||
* A dialog that issues a certificate from an active issuing CA with one of the templates it issues but those only the
|
||||
* router issues: from a CSR, pasted or read from a file, or with a key the router makes for a subject and subject
|
||||
* router issues: from a CSR, pasted or read from a file, or with a key the server makes for a subject and subject
|
||||
* alternative names, returned once in a PFX file protected by a password. onSave sends the request and saves what the
|
||||
* router answers; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* router answers; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function CertificateDialog(props: { pki: Pki; onSave: (request: IssueRequest) => Promise<void>; onCancel: () => void }) {
|
||||
const authorities = props.pki.status.authorities
|
||||
@@ -135,7 +135,7 @@ export default function CertificateDialog(props: { pki: Pki; onSave: (request: I
|
||||
type="password"
|
||||
value={password}
|
||||
autoComplete="new-password"
|
||||
helperText="Protects the key in the PFX file; the router keeps no copy of the key."
|
||||
helperText="Protects the key in the PFX file; the server keeps no copy of the key."
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
|
||||
@@ -21,7 +21,7 @@ import TemplateDialog from './TemplateDialog.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import EkuDialog from './EkuDialog.tsx'
|
||||
import PkiSettingsDialog, { PUBLISH_LABELS } from './PkiSettingsDialog.tsx'
|
||||
import { Pairs, Section } from './RouterPanel.tsx'
|
||||
import { Pairs, Section } from './ServerPanel.tsx'
|
||||
import {
|
||||
ApiError, BUNDLE_SHAPE, CA_IMPORTED_SHAPE, CRL_IMPORTED_SHAPE, CSR_SHAPE, ISSUED_SHAPE, PFX_SHAPE, PKI_SETTINGS_SHAPE, PKI_SHAPE, REVOKED_SHAPE,
|
||||
BUILTIN_TEMPLATES, REVOKE_REASONS, request, type Pki, type PkiCertificate, type PkiIssuingCa, type PkiTemplate,
|
||||
@@ -35,8 +35,8 @@ type View = 'root' | 'templates' | 'usages' | 'p2s' | 's2s' | 'issuing'
|
||||
/** The built-in CAs, whose certificates the Issuing CAs tab leaves out. */
|
||||
const BUILTIN_CAS = ['root', 'p2s', 's2s']
|
||||
|
||||
/** The note shown after a change, which the router applies when vpn-router-setup has run again. */
|
||||
const APPLIED = 'The router applies the change in the background.'
|
||||
/** The note shown after a change, which the server applies when linux-manager-setup has run again. */
|
||||
const APPLIED = 'The server applies the change in the background.'
|
||||
|
||||
/** The colour of each state of an issuing CA and of a certificate. */
|
||||
const STATE_COLORS: Record<string, 'success' | 'warning' | 'error' | 'default'> = {
|
||||
@@ -60,15 +60,15 @@ const REASON_LABELS: Record<string, string> = {
|
||||
|
||||
|
||||
/**
|
||||
* The router's PKI in tabs: Root, the root CA with the general settings and the certificates of the issuing CAs;
|
||||
* The server's PKI in tabs: Root, the root CA with the general settings and the certificates of the issuing CAs;
|
||||
* Templates, the certificate templates, which are added, changed, removed and reset there; Extended key usages, the
|
||||
* built-in ones and the custom ones, which are added, changed and removed there; P2S Issuing CA and S2S
|
||||
* Issuing CA, each built-in CA with the certificates it issued; Issuing CAs, the general-purpose CAs, which are added,
|
||||
* changed and removed there, with their certificates, filtered by CA. The warnings, Issue and Settings
|
||||
* are above the tabs. Settings edits the pki section, Issue issues a certificate from a CSR or into a PFX file, a
|
||||
* certificate of another system or of the router is revoked, an issuing CA waiting for the offline root gives its CSR
|
||||
* and takes its signed certificate, and the root takes a CRL signed offline. The root key is managed on the router
|
||||
* with vpn-router-ca only.
|
||||
* certificate of another system or of the server is revoked, an issuing CA waiting for the offline root gives its CSR
|
||||
* and takes its signed certificate, and the root takes a CRL signed offline. The root key is managed on the server
|
||||
* with linux-manager-ca only.
|
||||
*/
|
||||
export default function CertificatesPanel() {
|
||||
const [pki, setPki] = useState<Pki | null>(null)
|
||||
@@ -138,7 +138,7 @@ export default function CertificatesPanel() {
|
||||
}
|
||||
|
||||
/** Writes the templates of pki.templates: the current ones with name set to values, or without it when values is
|
||||
* null, which removes a template of the router's own or brings a built-in one back to its defaults. */
|
||||
* null, which removes a template of the server's own or brings a built-in one back to its defaults. */
|
||||
async function saveTemplate(name: string, values: PkiTemplate | null) {
|
||||
const { [name]: _current, ...others } = pki?.settings.templates ?? {}
|
||||
await request('PUT', '/ca', PKI_SETTINGS_SHAPE, { templates: values === null ? others : { ...others, [name]: values } })
|
||||
@@ -157,7 +157,7 @@ export default function CertificatesPanel() {
|
||||
function removeUsage(name: string) {
|
||||
setConfirm({
|
||||
title: 'Remove extended key usage',
|
||||
message: `Remove extended key usage ${name}? The router refuses while a template gives it; certificates issued with it keep it.`,
|
||||
message: `Remove extended key usage ${name}? The server refuses while a template gives it; certificates issued with it keep it.`,
|
||||
confirmLabel: 'Remove',
|
||||
destructive: true,
|
||||
onCancel: () => setConfirm(null),
|
||||
@@ -177,7 +177,7 @@ export default function CertificatesPanel() {
|
||||
title: builtin ? 'Reset template' : 'Remove template',
|
||||
message: builtin
|
||||
? `Bring template ${name} back to its built-in options? The certificates issued afterwards follow them.`
|
||||
: `Remove template ${name}? The router refuses while an issuing CA issues it; certificates issued with it stay valid.`,
|
||||
: `Remove template ${name}? The server refuses while an issuing CA issues it; certificates issued with it stay valid.`,
|
||||
confirmLabel: builtin ? 'Reset' : 'Remove',
|
||||
destructive: !builtin,
|
||||
onCancel: () => setConfirm(null),
|
||||
@@ -195,7 +195,7 @@ export default function CertificatesPanel() {
|
||||
function removeAuthority(name: string) {
|
||||
setConfirm({
|
||||
title: 'Remove issuing CA',
|
||||
message: `Remove issuing CA ${name}? The router retires it and revokes its certificate on the root CRL; with the root offline, the root CRL is signed offline. Its certificates stay valid until they expire or are revoked.`,
|
||||
message: `Remove issuing CA ${name}? The server retires it and revokes its certificate on the root CRL; with the root offline, the root CRL is signed offline. Its certificates stay valid until they expire or are revoked.`,
|
||||
confirmLabel: 'Remove',
|
||||
destructive: true,
|
||||
onCancel: () => setConfirm(null),
|
||||
@@ -214,7 +214,7 @@ export default function CertificatesPanel() {
|
||||
let reason: string = REVOKE_REASONS[0]
|
||||
setConfirm({
|
||||
title: 'Revoke certificate',
|
||||
message: `Revoke certificate ${certificate.serial} of ${certificate.subject}? The CRL of ${certificate.ca} lists it at once.${certificate.kind === 'router' ? ' The router issues itself a new one.' : ''}`,
|
||||
message: `Revoke certificate ${certificate.serial} of ${certificate.subject}? The CRL of ${certificate.ca} lists it at once.${certificate.kind === 'router' ? ' The server issues itself a new one.' : ''}`,
|
||||
confirmLabel: 'Revoke',
|
||||
destructive: true,
|
||||
children: (
|
||||
@@ -274,7 +274,7 @@ export default function CertificatesPanel() {
|
||||
? pki?.status.authorities.find((item) => item.state === 'active' && item.subject === certificate.subject && item.expires === certificate.expires)
|
||||
: undefined
|
||||
|
||||
/** A table of certificates with their state and, for one of another system or of the router, Revoke; for an active
|
||||
/** A table of certificates with their state and, for one of another system or of the server, Revoke; for an active
|
||||
* issuing CA, the download of its CA bundle. */
|
||||
const certificateTable = (list: PkiCertificate[]) => (
|
||||
<Box sx={{ overflowX: 'auto' }}>
|
||||
@@ -368,7 +368,7 @@ export default function CertificatesPanel() {
|
||||
</Stack>
|
||||
)}
|
||||
</>
|
||||
) : <Typography variant="body2" color="text.secondary">None yet; the router creates it once a platform is chosen.</Typography>}
|
||||
) : <Typography variant="body2" color="text.secondary">None yet; the server creates it once a platform is chosen.</Typography>}
|
||||
</Section>
|
||||
<Section title="Certificates issued">{certificateTable((pki?.certificates ?? []).filter((certificate) => certificate.ca === name))}</Section>
|
||||
</Box>
|
||||
@@ -415,14 +415,14 @@ export default function CertificatesPanel() {
|
||||
['Expires', when(root.expires)],
|
||||
['Key', root.key ? (
|
||||
<Box component="span" sx={{ display: 'inline-flex', alignItems: 'center', gap: 0.5 }}>
|
||||
on the router
|
||||
<Tooltip title="Keeping the root key off the router is recommended: vpn-router-ca root export-key, then vpn-router-ca root remove-key.">
|
||||
<WarningAmber fontSize="small" color="warning" aria-label="The root key is on the router" />
|
||||
on the server
|
||||
<Tooltip title="Keeping the root key off the server is recommended: linux-manager-ca root export-key, then linux-manager-ca root remove-key.">
|
||||
<WarningAmber fontSize="small" color="warning" aria-label="The root key is on the server" />
|
||||
</Tooltip>
|
||||
</Box>
|
||||
) : 'offline'],
|
||||
['CRL valid until', when(root.crl_next_update)],
|
||||
['CRL', root.crl_source === 'uploaded' ? 'uploaded' : root.crl_source === 'signed' ? 'signed by the router' : '-'],
|
||||
['CRL', root.crl_source === 'uploaded' ? 'uploaded' : root.crl_source === 'signed' ? 'signed by the server' : '-'],
|
||||
]}
|
||||
/>
|
||||
<Stack direction="row" sx={{ mt: 1, justifyContent: 'flex-end', gap: 1 }}>
|
||||
@@ -434,7 +434,7 @@ export default function CertificatesPanel() {
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
) : <Typography variant="body2" color="text.secondary">None yet; the router creates it once a platform is chosen.</Typography>}
|
||||
) : <Typography variant="body2" color="text.secondary">None yet; the server creates it once a platform is chosen.</Typography>}
|
||||
</Section>
|
||||
<Section title="General">
|
||||
<Pairs
|
||||
@@ -582,7 +582,7 @@ export default function CertificatesPanel() {
|
||||
)}
|
||||
|
||||
{pki && view === 'p2s' && builtinTab('p2s', 'P2S Issuing CA: the VPN server certificate and the users\' certificates')}
|
||||
{pki && view === 's2s' && builtinTab('s2s', 'S2S Issuing CA: the site-to-site certificates of the router and its peers')}
|
||||
{pki && view === 's2s' && builtinTab('s2s', 'S2S Issuing CA: the site-to-site certificates of the server and its peers')}
|
||||
|
||||
{pki && view === 'issuing' && (
|
||||
<Box sx={{ display: 'grid', gap: 2 }}>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ZONE_PATTERN, type DnsDomain } from './api.ts'
|
||||
|
||||
/**
|
||||
* A dialog that adds a domain of the name server, or edits one given as current: its name, fixed for an existing one,
|
||||
* and an optional TTL. onSave sends it; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* and an optional TTL. onSave sends it; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function DnsDomainDialog(props: {
|
||||
current?: DnsDomain
|
||||
@@ -48,7 +48,7 @@ export default function DnsDomainDialog(props: {
|
||||
autoComplete="off"
|
||||
disabled={Boolean(props.current)}
|
||||
error={nameProblem !== ''}
|
||||
helperText={nameProblem || 'The domain the router is the primary name server of.'}
|
||||
helperText={nameProblem || 'The domain the server is the primary name server of.'}
|
||||
onChange={(event) => setName(event.target.value.trim().toLowerCase())}
|
||||
/>
|
||||
<TextField
|
||||
|
||||
@@ -9,7 +9,7 @@ import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import DnsDomainDialog from './DnsDomainDialog.tsx'
|
||||
import DnsRecordDialog from './DnsRecordDialog.tsx'
|
||||
import DnsSettingsDialog from './DnsSettingsDialog.tsx'
|
||||
import { Pairs, Section } from './RouterPanel.tsx'
|
||||
import { Pairs, Section } from './ServerPanel.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import {
|
||||
ApiError, DNS_DOMAIN_REMOVED_SHAPE, DNS_DOMAIN_SHAPE, DNS_RECORD_SHAPE, DNS_REMOVED_SHAPE, DNS_SETTINGS_SHAPE, DNS_SHAPE,
|
||||
@@ -58,8 +58,8 @@ function Records(props: { records: DnsRecord[]; busy: boolean; onRemove?: (recor
|
||||
}
|
||||
|
||||
/**
|
||||
* The router's name server, from its /dns: the settings of the dns section with whether PowerDNS is installed and runs,
|
||||
* its primary name server, the router's FQDN, and the router's public IP, edited with Settings; the domains it is the
|
||||
* The server's name server, from its /dns: the settings of the dns section with whether PowerDNS is installed and runs,
|
||||
* its primary name server, the server's FQDN, and the server's public IP, edited with Settings; the domains it is the
|
||||
* primary of: add, edit and remove; and for the selected domain its manual records: add and remove, and the records it
|
||||
* serves. The records of the web sites follow the DNS setting of each site on the Sites page.
|
||||
*/
|
||||
@@ -133,7 +133,7 @@ export default function DnsPanel() {
|
||||
|
||||
return (
|
||||
<Box component="section">
|
||||
<Toolbar description="The primary name server of the router's domains.">
|
||||
<Toolbar description="The primary name server of the server's domains.">
|
||||
<Button variant="outlined" startIcon={<Settings />} disabled={busy || !section} onClick={() => setSettings(true)}>
|
||||
Settings
|
||||
</Button>
|
||||
|
||||
@@ -15,7 +15,7 @@ const CONTENT_HELP: Record<string, string> = {
|
||||
|
||||
/**
|
||||
* A dialog that adds a record to a domain: its name, relative to the domain, @ for the domain itself, its type, its
|
||||
* content and an optional TTL. onSave sends it; the dialog closes when it succeeds and shows the router's message when
|
||||
* content and an optional TTL. onSave sends it; the dialog closes when it succeeds and shows the server's message when
|
||||
* it fails.
|
||||
*/
|
||||
export default function DnsRecordDialog(props: {
|
||||
|
||||
@@ -3,11 +3,11 @@ import { useState, type FormEvent } from 'react'
|
||||
import { ADDRESS_PATTERN, LISTEN_CHOICES, ZONE_PATTERN, type DnsSettings, type Listen } from './api.ts'
|
||||
|
||||
/**
|
||||
* A dialog that edits the router's dns section: whether the name server runs, the secondary name server of every
|
||||
* domain, the interfaces it answers on and the TTL, and wan.public_address, the router's public IP the records of the
|
||||
* sites with Public IP take. The primary name server is the router's FQDN, nameserver, shown and not edited. An enabled
|
||||
* name server needs a secondary other than the router's FQDN. onSave sends the section and the public address; the
|
||||
* dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* A dialog that edits the server's dns section: whether the name server runs, the secondary name server of every
|
||||
* domain, the interfaces it answers on and the TTL, and wan.public_address, the server's public IP the records of the
|
||||
* sites with Public IP take. The primary name server is the server's FQDN, nameserver, shown and not edited. An enabled
|
||||
* name server needs a secondary other than the server's FQDN. onSave sends the section and the public address; the
|
||||
* dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function DnsSettingsDialog(props: {
|
||||
current: DnsSettings
|
||||
@@ -26,7 +26,7 @@ export default function DnsSettingsDialog(props: {
|
||||
|
||||
const secondaryProblem = secondary === '' ? (enabled ? 'Required while enabled.' : '')
|
||||
: !ZONE_PATTERN.test(secondary) ? 'A DNS name in lower case.'
|
||||
: secondary === props.nameserver ? 'The secondary is not the router\'s FQDN, the primary.' : ''
|
||||
: secondary === props.nameserver ? 'The secondary is not the server\'s FQDN, the primary.' : ''
|
||||
const addressProblem = publicAddress === '' || ADDRESS_PATTERN.test(publicAddress) ? '' : 'Not an IP address.'
|
||||
const ttlProblem = /^\d{2,5}$/.test(ttl) && Number(ttl) >= 60 && Number(ttl) <= 86400 ? '' : '60 to 86400 seconds.'
|
||||
const blocked = secondaryProblem !== '' || addressProblem !== '' || ttlProblem !== ''
|
||||
@@ -55,9 +55,9 @@ export default function DnsSettingsDialog(props: {
|
||||
<FormControlLabel control={<Switch checked={enabled} onChange={(event) => setEnabled(event.target.checked)} />} label="Enabled" />
|
||||
<TextField
|
||||
label="Primary name server"
|
||||
value={props.nameserver || '(the router has no FQDN)'}
|
||||
value={props.nameserver || '(the server has no FQDN)'}
|
||||
disabled
|
||||
helperText="The router's FQDN: the SOA and the first NS of every domain."
|
||||
helperText="The server's FQDN: the SOA and the first NS of every domain."
|
||||
/>
|
||||
<TextField
|
||||
label="Secondary name server"
|
||||
@@ -73,7 +73,7 @@ export default function DnsSettingsDialog(props: {
|
||||
value={publicAddress}
|
||||
autoComplete="off"
|
||||
error={addressProblem !== ''}
|
||||
helperText={addressProblem || 'The router\'s public IP, for the records of the sites with Public IP. Empty: none.'}
|
||||
helperText={addressProblem || 'The server\'s public IP, for the records of the sites with Public IP. Empty: none.'}
|
||||
onChange={(event) => setPublicAddress(event.target.value.trim().toLowerCase())}
|
||||
/>
|
||||
<Stack direction="row" sx={{ gap: 2 }}>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Refresh from '@mui/icons-material/Refresh'
|
||||
import { Alert, Box, Button, Typography } from '@mui/material'
|
||||
import { Pairs, Section, text } from './RouterPanel.tsx'
|
||||
import { Pairs, Section, text } from './ServerPanel.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { DETAILS_SHAPE, STATUS_SHAPE, request, type RouterDetails, type RouterStatus } from './api.ts'
|
||||
import { useRead } from './useRead.ts'
|
||||
|
||||
/** Reads the router's /status/full and /config. */
|
||||
/** Reads the server's /status/full and /config. */
|
||||
const readDocker = async () => {
|
||||
const [status, details] = await Promise.all([
|
||||
request<RouterStatus>('GET', '/status/full', STATUS_SHAPE),
|
||||
@@ -15,8 +15,8 @@ const readDocker = async () => {
|
||||
}
|
||||
|
||||
/**
|
||||
* The state of Docker on the router: whether it is installed, the state of docker.service and of the router's Docker
|
||||
* rules, from /status/full, and the ports exposed on the external interface and the rules of the VPN-ROUTER-DOCKER
|
||||
* The state of Docker on the server: whether it is installed, the state of docker.service and of the server's Docker
|
||||
* rules, from /status/full, and the ports exposed on the external interface and the rules of the LINUX-MANAGER-DOCKER
|
||||
* chain, from /config.
|
||||
*/
|
||||
export default function DockerPanel() {
|
||||
@@ -42,7 +42,7 @@ export default function DockerPanel() {
|
||||
]}
|
||||
/>
|
||||
</Section>
|
||||
<Section title="Rules of VPN-ROUTER-DOCKER">
|
||||
<Section title="Rules of LINUX-MANAGER-DOCKER">
|
||||
{details.docker.rules === null
|
||||
? <Typography variant="body2" color="text.secondary">Not available.</Typography>
|
||||
: (
|
||||
|
||||
+11
-11
@@ -12,25 +12,25 @@ import { ApiError, EDITOR_CONTENT_SHAPE, EDITOR_SAVED_SHAPE, request, type Edito
|
||||
const FONT = "Menlo, Monaco, Consolas, 'Droid Sans Mono', 'DejaVu Sans Mono', 'Courier New', monospace"
|
||||
|
||||
/** The localStorage key of whether the editor's minimap is hidden. */
|
||||
const MINIMAP_KEY = 'vpn-router-manager.editor-minimap'
|
||||
const MINIMAP_KEY = 'linux-manager-ui.editor-minimap'
|
||||
|
||||
/** What the page knows of an open file: its version on the router, whether it has unsaved changes, and its trouble. */
|
||||
/** What the page knows of an open file: its version on the server, whether it has unsaved changes, and its trouble. */
|
||||
type FileState = { version: string | null; dirty: boolean; saving: boolean; conflict: boolean; error: string | null }
|
||||
|
||||
/** The router's path of a file of the editor. */
|
||||
/** The server's path of a file of the editor. */
|
||||
function pathOf(file: EditorFile) {
|
||||
return `/shell/editor/${encodeURIComponent(file.session)}/${encodeURIComponent(file.id)}`
|
||||
}
|
||||
|
||||
/**
|
||||
* The editor of the Shell page: a tab for each file the shell opened with vre, its name on the tab, its path as the
|
||||
* The editor of the Shell page: a tab for each file the shell opened with lme, its name on the tab, its path as the
|
||||
* tab's tooltip, a dot while it has unsaved changes and a close icon, above a Monaco editor of the file chosen, with
|
||||
* the syntax colours of the language of its extension and the light or dark theme of the page. Monaco is loaded when
|
||||
* the panel first shows. The minimap button shows or hides the editor's minimap, kept in localStorage.
|
||||
*
|
||||
* Each file is read from the router when it opens. Save, or Ctrl+S, writes the editor's text with the version it
|
||||
* replaces; when the file changed on the router meanwhile, Reload takes the router's text and Overwrite writes over
|
||||
* it. Closing a tab with unsaved changes asks first; a closed tab is closed on the router too, and onClosed tells the
|
||||
* Each file is read from the server when it opens. Save, or Ctrl+S, writes the editor's text with the version it
|
||||
* replaces; when the file changed on the server meanwhile, Reload takes the server's text and Overwrite writes over
|
||||
* it. Closing a tab with unsaved changes asks first; a closed tab is closed on the server too, and onClosed tells the
|
||||
* shell. Files no longer in files, as when the shell ended, are dropped.
|
||||
*/
|
||||
export default function EditorPanel(props: { files: EditorFile[]; scheme: 'light' | 'dark'; onClosed: (id: string) => void }) {
|
||||
@@ -126,7 +126,7 @@ export default function EditorPanel(props: { files: EditorFile[]; scheme: 'light
|
||||
editor.current?.focus()
|
||||
}, [active, monaco])
|
||||
|
||||
/** Writes the editor's text of the file; with overwrite, over whatever the router has now. */
|
||||
/** Writes the editor's text of the file; with overwrite, over whatever the server has now. */
|
||||
const save = useCallback(async (id: string, overwrite = false) => {
|
||||
const file = files.find((item) => item.id === id)
|
||||
const entry = models.current.get(id)
|
||||
@@ -150,7 +150,7 @@ export default function EditorPanel(props: { files: EditorFile[]; scheme: 'light
|
||||
saveRef.current = (id) => void save(id)
|
||||
}, [save])
|
||||
|
||||
/** Replaces the editor's text of the file with the router's. */
|
||||
/** Replaces the editor's text of the file with the server's. */
|
||||
async function reload(file: EditorFile) {
|
||||
const entry = models.current.get(file.id)
|
||||
try {
|
||||
@@ -165,7 +165,7 @@ export default function EditorPanel(props: { files: EditorFile[]; scheme: 'light
|
||||
}
|
||||
}
|
||||
|
||||
/** Closes the file here and on the router, choosing the tab beside it. */
|
||||
/** Closes the file here and on the server, choosing the tab beside it. */
|
||||
function close(file: EditorFile) {
|
||||
setClosing(null)
|
||||
void request('DELETE', pathOf(file), () => true).catch(() => undefined)
|
||||
@@ -245,7 +245,7 @@ export default function EditorPanel(props: { files: EditorFile[]; scheme: 'light
|
||||
</>
|
||||
}
|
||||
>
|
||||
{`${current.path} changed on the router since it was read.`}
|
||||
{`${current.path} changed on the server since it was read.`}
|
||||
</Alert>
|
||||
)}
|
||||
<Box sx={{ position: 'relative', height: 'calc(100vh - 280px)', minHeight: 280, border: 1, borderColor: 'divider', borderRadius: 1, overflow: 'hidden' }}>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { EKU_NAME_PATTERN, OID_PATTERN, type Pki } from './api.ts'
|
||||
/**
|
||||
* A dialog that adds a custom extended key usage, or with name changes the OID of one: its name, fixed once it exists,
|
||||
* by which templates give it, and its OID in dotted form. onSave gets the name and the OID; the dialog closes when it
|
||||
* succeeds and shows the router's message when it fails.
|
||||
* succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function EkuDialog(props: { pki: Pki; name?: string; onSave: (name: string, oid: string) => Promise<void>; onCancel: () => void }) {
|
||||
const [name, setName] = useState(props.name ?? '')
|
||||
|
||||
@@ -2,15 +2,15 @@ import { Alert, Autocomplete, Button, Dialog, DialogActions, DialogContent, Dial
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import type { Group } from './api.ts'
|
||||
|
||||
/** The group names vpn-router-group accepts, the same as user names. */
|
||||
/** The group names linux-manager-group accepts, the same as user names. */
|
||||
const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}[a-z0-9]$|^[a-z]$/
|
||||
|
||||
/** The longest description vpn-router-group accepts. */
|
||||
/** The longest description linux-manager-group accepts. */
|
||||
const DESCRIPTION_MAX = 256
|
||||
|
||||
/**
|
||||
* A dialog that adds a group, or, given a group, edits it: its name, description and members, at least one, chosen
|
||||
* from users. onSave sends them; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* from users. onSave sends them; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function GroupDialog(props: {
|
||||
group?: Group
|
||||
|
||||
@@ -8,13 +8,13 @@ import {
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import GroupDialog from './GroupDialog.tsx'
|
||||
import { Section } from './RouterPanel.tsx'
|
||||
import { Section } from './ServerPanel.tsx'
|
||||
import SearchField, { matches } from './SearchField.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { ApiError, GROUPS_SHAPE, GROUP_SHAPE, REMOVED_SHAPE, SERVICE_ACCOUNTS_SHAPE, USERS_SHAPE, request, type Group, type User } from './api.ts'
|
||||
|
||||
/**
|
||||
* The groups of the router's directory: list with their descriptions and members, add, edit the name, the
|
||||
* The groups of the server's directory: list with their descriptions and members, add, edit the name, the
|
||||
* description and the members, and remove. A group always keeps at least one member; the members offered are the users
|
||||
* and the service accounts but the internal ones.
|
||||
*/
|
||||
|
||||
@@ -3,9 +3,9 @@ import { useState, type FormEvent } from 'react'
|
||||
import type { HttpsSettings } from './api.ts'
|
||||
|
||||
/**
|
||||
* A dialog that switches the CA of the certificates Caddy obtains on the router: Let's Encrypt's staging environment,
|
||||
* A dialog that switches the CA of the certificates Caddy obtains on the server: Let's Encrypt's staging environment,
|
||||
* https.acme_staging, or Caddy's default CAs. onSave sends acme_staging; the dialog closes when it succeeds and shows
|
||||
* the router's message when it fails.
|
||||
* the server's message when it fails.
|
||||
*/
|
||||
export default function HttpsSettingsDialog(props: {
|
||||
current: HttpsSettings
|
||||
@@ -41,7 +41,7 @@ export default function HttpsSettingsDialog(props: {
|
||||
: 'Caddy takes its certificates from Let\'s Encrypt, and from ZeroSSL when Let\'s Encrypt refuses, such as for its limit of 5 certificates a week for the same name.'}
|
||||
</Typography>
|
||||
{staging !== props.current.acme_staging && (
|
||||
<Alert severity="info">The router runs its setup again, which applies the change.</Alert>
|
||||
<Alert severity="info">The server runs its setup again, which applies the change.</Alert>
|
||||
)}
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useState, type FormEvent } from 'react'
|
||||
/**
|
||||
* A dialog that takes a PEM text, pasted or read from a file, such as the certificate of an issuing CA signed by the
|
||||
* offline root or a root CRL. begin is the PEM header the text must have. onSave sends the text; the dialog closes when
|
||||
* it succeeds and shows the router's message when it fails.
|
||||
* it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function ImportDialog(props: {
|
||||
title: string
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ROUTER_TEMPLATES, type Pki, type PkiIssuingCa } from './api.ts'
|
||||
/**
|
||||
* A dialog that adds a general-purpose issuing CA, or with name changes one: its name, fixed once it exists, its common
|
||||
* name, the templates it issues and whether Caddy runs an ACME server for it. onSave gets the name and the options; the
|
||||
* dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function IssuingCaDialog(props: {
|
||||
pki: Pki
|
||||
@@ -56,7 +56,7 @@ export default function IssuingCaDialog(props: {
|
||||
{error && <Alert severity="error" sx={{ whiteSpace: 'pre-line' }}>{error}</Alert>}
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{props.name === undefined
|
||||
? 'The root signs the new CA at once while its key is on the router; otherwise the CA waits with a CSR for the offline root.'
|
||||
? 'The root signs the new CA at once while its key is on the server; otherwise the CA waits with a CSR for the offline root.'
|
||||
: 'The common name applies when the CA is created; the templates and the ACME server apply at once.'}
|
||||
</Typography>
|
||||
<TextField
|
||||
|
||||
@@ -6,16 +6,16 @@ import LogView from './LogView.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { LOGS_SHAPE, LOG_LINES_SHAPE, request, type Logs } from './api.ts'
|
||||
|
||||
/** The numbers of lines offered, up to the router's most. */
|
||||
/** The numbers of lines offered, up to the server's most. */
|
||||
const LINE_CHOICES = [100, 200, 500, 1000]
|
||||
|
||||
/** Seconds between the reads of a followed log. */
|
||||
const FOLLOW_SECONDS = 2
|
||||
|
||||
/**
|
||||
* The router's logs, from its /logs: the Journal sub-tab shows the last lines of the journal of a unit the router names, or of
|
||||
* the whole journal, and the Files sub-tab the last lines of a log file the router's web.log_files lists. The number of lines
|
||||
* is chosen up to the router's most; a log is read when its unit, file or number of lines is chosen and with Refresh, and
|
||||
* The server's logs, from its /logs: the Journal sub-tab shows the last lines of the journal of a unit the server names, or of
|
||||
* the whole journal, and the Files sub-tab the last lines of a log file the server's web.log_files lists. The number of lines
|
||||
* is chosen up to the server's most; a log is read when its unit, file or number of lines is chosen and with Refresh, and
|
||||
* while Follow is on every FOLLOW_SECONDS, scrolled to its last line, as tail -f shows it.
|
||||
*/
|
||||
export default function LogsPanel() {
|
||||
|
||||
+10
-10
@@ -5,7 +5,7 @@ import { LineChart } from '@mui/x-charts/LineChart'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import MetricsSettingsDialog from './MetricsSettingsDialog.tsx'
|
||||
import { Board, BoardButtons, useBoard, type BoardPanel } from './PanelBoard.tsx'
|
||||
import { bytes } from './RouterPanel.tsx'
|
||||
import { bytes } from './ServerPanel.tsx'
|
||||
import {
|
||||
METRICS_RANGES, METRICS_SETTINGS_SHAPE, METRICS_SHAPE, request, type Aggregate, type MetricsHistory, type MetricsRange,
|
||||
type MetricsSettings,
|
||||
@@ -14,10 +14,10 @@ import { useBrowserSettings } from './settings.ts'
|
||||
|
||||
|
||||
/** The localStorage key of the tab's layout. */
|
||||
const LAYOUT_KEY = 'vpn-router-manager.metrics-layout'
|
||||
const LAYOUT_KEY = 'linux-manager-ui.metrics-layout'
|
||||
|
||||
/** The localStorage key of the lines hidden by their legend item: chart id -> line labels. */
|
||||
const HIDDEN_KEY = 'vpn-router-manager.metrics-hidden'
|
||||
const HIDDEN_KEY = 'linux-manager-ui.metrics-hidden'
|
||||
|
||||
/** The hidden lines kept in localStorage, or none when there are none or they cannot be read. */
|
||||
function readHidden(): Record<string, string[]> {
|
||||
@@ -33,7 +33,7 @@ function readHidden(): Record<string, string[]> {
|
||||
return {}
|
||||
}
|
||||
|
||||
/** The label of each view, how a time on its axis is written, and the start of the span it shows, which ends at end, as the router's span. */
|
||||
/** The label of each view, how a time on its axis is written, and the start of the span it shows, which ends at end, as the server's span. */
|
||||
const RANGES: Record<MetricsRange, { label: string; format: Intl.DateTimeFormatOptions; start: (end: Date) => Date }> = {
|
||||
hour: { label: 'Hour', format: { hour: '2-digit', minute: '2-digit' }, start: (end) => new Date(end.getTime() - 3600_000) },
|
||||
day: { label: 'Day', format: { hour: '2-digit', minute: '2-digit' }, start: (end) => new Date(end.getTime() - 86400_000) },
|
||||
@@ -41,7 +41,7 @@ const RANGES: Record<MetricsRange, { label: string; format: Intl.DateTimeFormatO
|
||||
year: { label: 'Year', format: { year: 'numeric', month: 'short' }, start: (end) => new Date(new Date(end).setFullYear(end.getFullYear() - 1)) },
|
||||
}
|
||||
|
||||
/** The labels of the kinds of VPN clients the router counts. */
|
||||
/** The labels of the kinds of VPN clients the server counts. */
|
||||
const CLIENT_KINDS: Record<string, string> = {
|
||||
p2s: 'IKEv2',
|
||||
openvpn: 'OpenVPN',
|
||||
@@ -55,7 +55,7 @@ type Consolidation = 'avg' | 'max'
|
||||
type Line = { label: string; data: (number | null)[] }
|
||||
|
||||
/**
|
||||
* The router's metrics as charts, for the last hour, day, month or year, as the router's /metrics/history answers them:
|
||||
* The server's metrics as charts, for the last hour, day, month or year, as the server's /metrics/history answers them:
|
||||
* CPU, memory, free disk space in bytes and in percent, the bytes per second of each interface, the VPN clients, the
|
||||
* load averages, and, per site-to-site connection, the part of the time it was up and its bytes and packets per
|
||||
* second; each bucket as its average or its maximum. The time axis spans the whole view, ending at the last read,
|
||||
@@ -64,7 +64,7 @@ type Line = { label: string; data: (number | null)[] }
|
||||
* The charts are panels of a PanelBoard, as on the Overview tab, with their layout kept in the browser: each folds by its
|
||||
* title bar and hides by its [X]; Panels shows them again, and Edit layout moves them by dragging and sets their width.
|
||||
* A click on a legend item hides or shows its line; the hidden lines of each chart are kept in the browser too.
|
||||
* Settings reads the router's metrics section from /metrics/settings and edits it in MetricsSettingsDialog.
|
||||
* Settings reads the server's metrics section from /metrics/settings and edits it in MetricsSettingsDialog.
|
||||
*/
|
||||
export default function MetricsPanel() {
|
||||
const board = useBoard(LAYOUT_KEY)
|
||||
@@ -85,7 +85,7 @@ export default function MetricsPanel() {
|
||||
setSettings((await request<{ settings: MetricsSettings & { otlp_password_set: boolean } }>('GET', '/metrics/settings', METRICS_SETTINGS_SHAPE)).settings)
|
||||
setError(null)
|
||||
} catch (caught) {
|
||||
setError(`The router did not give its metrics settings: ${(caught as Error).message}`)
|
||||
setError(`The server did not give its metrics settings: ${(caught as Error).message}`)
|
||||
}
|
||||
setOpening(false)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ export default function MetricsPanel() {
|
||||
setHistory(await request<MetricsHistory>('GET', `/metrics/history?range=${range}`, METRICS_SHAPE))
|
||||
setError(null)
|
||||
} catch (caught) {
|
||||
setError(`The router did not give its metrics: ${(caught as Error).message}`)
|
||||
setError(`The server did not give its metrics: ${(caught as Error).message}`)
|
||||
}
|
||||
setAt(new Date())
|
||||
setReading(false)
|
||||
@@ -200,7 +200,7 @@ export default function MetricsPanel() {
|
||||
], (value) => value.toFixed(2)),
|
||||
]
|
||||
// The site-to-site charts, while the view has data of a connection: the percentage of each slot of the view it was up,
|
||||
// which the router computes in slots of its own whatever Average or Maximum shows, its traffic and its packets.
|
||||
// which the server computes in slots of its own whatever Average or Maximum shows, its traffic and its packets.
|
||||
if (tunnels.length > 0) {
|
||||
const availability = history?.range === range ? history.site_to_site_up : { slot: '', points: [] }
|
||||
panels.push(
|
||||
|
||||
@@ -11,15 +11,15 @@ const KEEP_LABELS: Record<MetricsKeep, string> = {
|
||||
keep_yearly: 'Yearly summaries',
|
||||
}
|
||||
|
||||
/** A retention period as the router takes it: a count and a unit. */
|
||||
/** A retention period as the server takes it: a count and a unit. */
|
||||
const KEEP_PATTERN = /^[1-9]\d{0,4} (hour|day|month|year)s?$/
|
||||
|
||||
/**
|
||||
* A dialog that edits the router's metrics section: whether the metrics service runs, the interfaces and the ports of
|
||||
* A dialog that edits the server's metrics section: whether the metrics service runs, the interfaces and the ports of
|
||||
* /metrics, its service account, the OTLP endpoint the samples are pushed to with its user name and password, and how
|
||||
* long each level of the history is kept. An empty password keeps the current one, and an empty user name removes it.
|
||||
* onSave sends the section, with otlp_password only when one is entered; the dialog closes when it succeeds and shows
|
||||
* the router's message when it fails.
|
||||
* the server's message when it fails.
|
||||
*/
|
||||
export default function MetricsSettingsDialog(props: {
|
||||
current: MetricsSettings & { otlp_password_set: boolean }
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import Refresh from '@mui/icons-material/Refresh'
|
||||
import { Alert, Box, Button } from '@mui/material'
|
||||
import { Board, BoardButtons, useBoard, type BoardPanel } from './PanelBoard.tsx'
|
||||
import { Grid, Pairs, text } from './RouterPanel.tsx'
|
||||
import { Grid, Pairs, text } from './ServerPanel.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { DETAILS_SHAPE, request, type RouterDetails } from './api.ts'
|
||||
import { useRead } from './useRead.ts'
|
||||
|
||||
/** The localStorage key of the tab's layout. */
|
||||
const LAYOUT_KEY = 'vpn-router-manager.network-layout'
|
||||
const LAYOUT_KEY = 'linux-manager-ui.network-layout'
|
||||
|
||||
/** Reads the router's /config. */
|
||||
/** Reads the server's /config. */
|
||||
const readDetails = () => request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
|
||||
|
||||
/**
|
||||
* The router's network, from its /config: the external and the internal interface with their addresses, the internal
|
||||
* The server's network, from its /config: the external and the internal interface with their addresses, the internal
|
||||
* gateway and the local CIDRs, and the IPv4 routes. The panels are on a board whose layout is kept in the browser.
|
||||
*/
|
||||
export default function NetworkPanel() {
|
||||
|
||||
@@ -4,10 +4,10 @@ import { useEffect, useState, type FormEvent } from 'react'
|
||||
import { CODE_PATTERN, OTP_SECRET_SHAPE, request, type OtpSecret, type Proof } from './api.ts'
|
||||
|
||||
/**
|
||||
* A dialog that enrols a user for TOTP: it asks the router for a new secret at path, shows it as a QR code and as text
|
||||
* A dialog that enrols a user for TOTP: it asks the server for a new secret at path, shows it as a QR code and as text
|
||||
* for an authenticator app, and asks for a code the app shows. With proof it also asks for the user's current password
|
||||
* and, when proof.otp says the user is enrolled, a code of the current authenticator. onSave sends the secret with the
|
||||
* code and the proof; the dialog closes when it succeeds and shows the router's message when it fails. Nothing is
|
||||
* code and the proof; the dialog closes when it succeeds and shows the server's message when it fails. Nothing is
|
||||
* stored before the code is verified.
|
||||
*/
|
||||
export default function OtpDialog(props: {
|
||||
|
||||
@@ -31,12 +31,12 @@ export const DOCKER_PATH = '/docker-manager'
|
||||
/** The path of the Web Sites page: the sites Caddy serves, their files and the name server. */
|
||||
export const SITES_PATH = '/sites-manager'
|
||||
|
||||
/** The path of the shell page: a login shell on the router, opened with the shell button of the header, not the menu. */
|
||||
/** The path of the shell page: a login shell on the server, opened with the shell button of the header, not the menu. */
|
||||
export const SHELL_PATH = '/shell'
|
||||
|
||||
/** The pages of an administrator in the menu: path, label and icon. */
|
||||
const PAGES: { path: string; label: string; icon: ReactNode }[] = [
|
||||
{ path: '/', label: 'Router', icon: <Router fontSize="small" /> },
|
||||
{ path: '/', label: 'Server', icon: <Router fontSize="small" /> },
|
||||
{ path: USERS_PATH, label: 'Identities', icon: <People fontSize="small" /> },
|
||||
{ path: SITE_TO_SITE_PATH, label: 'Connectivity', icon: <Hub fontSize="small" /> },
|
||||
{ path: REMOTE_ACCESS_PATH, label: 'Remote Access', icon: <VpnKey fontSize="small" /> },
|
||||
@@ -45,8 +45,11 @@ const PAGES: { path: string; label: string; icon: ReactNode }[] = [
|
||||
{ path: DOCKER_PATH, label: 'Docker', icon: <ViewInAr fontSize="small" /> },
|
||||
]
|
||||
|
||||
/** A button naming the page shown, or Pages on the account and the shell page, whose menu opens the pages of an administrator. */
|
||||
export default function PageMenu(props: { path: string }) {
|
||||
/**
|
||||
* A button naming the page shown, or Pages on the account and the shell page, whose menu opens the pages of an
|
||||
* administrator but those of hidden, the pages of a component switched off.
|
||||
*/
|
||||
export default function PageMenu(props: { path: string; hidden: string[] }) {
|
||||
const [anchor, setAnchor] = useState<HTMLElement | null>(null)
|
||||
const current = PAGES.find((page) => page.path === props.path) ?? { path: props.path, label: 'Pages', icon: <MenuIcon fontSize="small" /> }
|
||||
return (
|
||||
@@ -63,7 +66,7 @@ export default function PageMenu(props: { path: string }) {
|
||||
{current.label}
|
||||
</Button>
|
||||
<Menu anchorEl={anchor} open={anchor !== null} onClose={() => setAnchor(null)}>
|
||||
{PAGES.map((page) => (
|
||||
{PAGES.filter((page) => !props.hidden.includes(page.path)).map((page) => (
|
||||
<MenuItem key={page.path} component="a" href={page.path} selected={page.path === current.path}>
|
||||
<ListItemIcon>{page.icon}</ListItemIcon>
|
||||
<ListItemText>{page.label}</ListItemText>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CODE_PATTERN, PASSKEY_BEGUN_SHAPE, USER_SHAPE, request, type PasskeyBeg
|
||||
|
||||
/**
|
||||
* A dialog that registers a passkey of the signed-in user: a label, the current password and, for a user enrolled for
|
||||
* one-time passwords, a code. The router begins the registration with them, the browser creates the passkey, and the
|
||||
* one-time passwords, a code. The server begins the registration with them, the browser creates the passkey, and the
|
||||
* router stores it; onSaved gets the user with the new passkey. A failure shows its message.
|
||||
*/
|
||||
export default function PasskeyDialog(props: { otp: boolean; onSaved: (user: User) => void; onCancel: () => void }) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ipsOf, ipsProblem, keyProblem } from './wireguard.ts'
|
||||
/**
|
||||
* A dialog that adds a WireGuard peer to one of the VPN users: the user, the device's public key, which no peer may have
|
||||
* already (keys), and its IPs, which start as proposed, the next free address of the WireGuard network. onSave sends
|
||||
* the user's name and the peer; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* the user's name and the peer; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function PeerDialog(props: {
|
||||
users: string[]
|
||||
|
||||
@@ -13,7 +13,7 @@ export const PUBLISH_LABELS: Record<string, string> = {
|
||||
'https-default': 'HTTPS on port 443, served by Caddy',
|
||||
}
|
||||
|
||||
/** The name of an issuing CA or a template, as the router accepts it. */
|
||||
/** The name of an issuing CA or a template, as the server accepts it. */
|
||||
export const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}$/
|
||||
|
||||
/** The names the issuing CAs of pki.issuing_cas cannot have. */
|
||||
@@ -22,7 +22,7 @@ export const RESERVED = ['root', 'p2s', 's2s']
|
||||
/** The longest common name of a CA, in characters. */
|
||||
const CA_NAME_MAX = 64
|
||||
|
||||
/** The longest lifetime the router accepts, in days. */
|
||||
/** The longest lifetime the server accepts, in days. */
|
||||
const DAYS_MAX = 36500
|
||||
|
||||
/** A new template's options. */
|
||||
@@ -41,11 +41,11 @@ export function daysProblem(value: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A dialog that edits the router's pki section but the general-purpose issuing CAs, the templates and the custom
|
||||
* A dialog that edits the server's pki section but the general-purpose issuing CAs, the templates and the custom
|
||||
* extended key usages, which IssuingCaDialog, TemplateDialog and EkuDialog edit: the names, lifetimes and key type of
|
||||
* the CAs, the validity of the CRLs and
|
||||
* where certificates and CRLs are published. The router applies the names, lifetimes and key type when it creates a
|
||||
* CA. onSave sends the settings; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* where certificates and CRLs are published. The server applies the names, lifetimes and key type when it creates a
|
||||
* CA. onSave sends the settings; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function PkiSettingsDialog(props: {
|
||||
pki: Pki
|
||||
@@ -87,7 +87,7 @@ export default function PkiSettingsDialog(props: {
|
||||
<Stack sx={{ gap: 2, pt: 1 }}>
|
||||
{error && <Alert severity="error" sx={{ whiteSpace: 'pre-line' }}>{error}</Alert>}
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
Names, lifetimes and the key type apply when the router creates a CA; URLs apply to the certificates signed afterwards.
|
||||
Names, lifetimes and the key type apply when the server creates a CA; URLs apply to the certificates signed afterwards.
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">CAs</Typography>
|
||||
{(['root', 'p2s', 's2s'] as const).map((name) => {
|
||||
@@ -144,7 +144,7 @@ export default function PkiSettingsDialog(props: {
|
||||
type="number"
|
||||
value={settings.root_crl_days}
|
||||
error={daysProblem(settings.root_crl_days) !== ''}
|
||||
helperText={daysProblem(settings.root_crl_days) || 'When the router signs it, with the root key on the router.'}
|
||||
helperText={daysProblem(settings.root_crl_days) || 'When the server signs it, with the root key on the server.'}
|
||||
onChange={(event) => change({ root_crl_days: number(event.target.value) })}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useState, type FormEvent } from 'react'
|
||||
import { CODE_PATTERN, PROFILE_SHAPE, request } from './api.ts'
|
||||
import { saveFile } from './saveFile.ts'
|
||||
|
||||
/** The length of a password the router accepts for the key in an Apple profile. */
|
||||
/** The length of a password the server accepts for the key in an Apple profile. */
|
||||
const PASSWORD_MIN = 8
|
||||
const PASSWORD_MAX = 128
|
||||
|
||||
@@ -16,8 +16,8 @@ const KINDS = {
|
||||
/**
|
||||
* A dialog that downloads a VPN profile of a user, saved as <name>.ovpn or <name>.mobileconfig: for the signed-in
|
||||
* user's own profile (own) the current password and, when enrolled (otp), a code, and for an Apple profile the
|
||||
* password that protects the user's key in it, typed twice. path is the router's call, such as
|
||||
* /users/<name>/apple-profile or /account/profile. The dialog closes when the file is saved and shows the router's
|
||||
* password that protects the user's key in it, typed twice. path is the server's call, such as
|
||||
* /users/<name>/apple-profile or /account/profile. The dialog closes when the file is saved and shows the server's
|
||||
* message when it fails.
|
||||
*/
|
||||
export default function ProfileDialog(props: {
|
||||
|
||||
@@ -3,10 +3,10 @@ import { useState, type FormEvent } from 'react'
|
||||
import { OPENVPN_PROTOCOLS, REMOTE_ACCESS_LABELS, type RemoteAccess, type RemoteAccessSystem } from './api.ts'
|
||||
import { routerAddressProblem } from './wireguard.ts'
|
||||
|
||||
/** An IPv4 network with its prefix length, as the router takes an address pool. */
|
||||
/** An IPv4 network with its prefix length, as the server takes an address pool. */
|
||||
const CIDR_PATTERN = /^(\d{1,3}\.){3}\d{1,3}\/\d{1,2}$/
|
||||
|
||||
/** A domain of IKEv2's DNS domains, as the router takes it, and the most domains. */
|
||||
/** A domain of IKEv2's DNS domains, as the server takes it, and the most domains. */
|
||||
const DOMAIN_PATTERN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/
|
||||
const DOMAINS_MAX = 16
|
||||
|
||||
@@ -17,9 +17,9 @@ function portProblem(text: string) {
|
||||
|
||||
/**
|
||||
* A dialog that edits the settings of one remote access system: whether it is enabled and its address pool, for
|
||||
* WireGuard wg0's address, for IKEv2 the DNS domains its clients resolve with the router's DNS, one per line, and the
|
||||
* WireGuard wg0's address, for IKEv2 the DNS domains its clients resolve with the server's DNS, one per line, and the
|
||||
* port, with OpenVPN's protocol. An enabled system needs its address. onSave sends
|
||||
* the section; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* the section; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function RemoteAccessDialog(props: {
|
||||
system: RemoteAccessSystem
|
||||
@@ -84,7 +84,7 @@ export default function RemoteAccessDialog(props: {
|
||||
autoComplete="off"
|
||||
error={addressProblem !== ''}
|
||||
helperText={addressProblem || (props.system === 'wireguard'
|
||||
? 'The router\'s address and prefix on the WireGuard network, such as 192.168.200.1/24.'
|
||||
? 'The server\'s address and prefix on the WireGuard network, such as 192.168.200.1/24.'
|
||||
: 'The IPv4 network the clients get their addresses from.')}
|
||||
onChange={(event) => setAddress(event.target.value)}
|
||||
/>
|
||||
@@ -96,7 +96,7 @@ export default function RemoteAccessDialog(props: {
|
||||
multiline
|
||||
minRows={2}
|
||||
error={domainsProblem !== ''}
|
||||
helperText={domainsProblem || 'The domains the clients resolve with the router\'s DNS, one per line.'}
|
||||
helperText={domainsProblem || 'The domains the clients resolve with the server\'s DNS, one per line.'}
|
||||
onChange={(event) => setDomains(event.target.value)}
|
||||
/>
|
||||
)}
|
||||
@@ -106,7 +106,7 @@ export default function RemoteAccessDialog(props: {
|
||||
value={port}
|
||||
autoComplete="off"
|
||||
error={portError !== ''}
|
||||
helperText={portError || 'A cloud firewall in front of the router must allow this port.'}
|
||||
helperText={portError || 'A cloud firewall in front of the server must allow this port.'}
|
||||
slotProps={{ htmlInput: { inputMode: 'numeric' } }}
|
||||
onChange={(event) => setPort(event.target.value.trim())}
|
||||
/>
|
||||
|
||||
@@ -7,7 +7,7 @@ import RemoteAccessDialog from './RemoteAccessDialog.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import WireGuardConfigDialog from './WireGuardConfigDialog.tsx'
|
||||
import WireGuardPeers from './WireGuardPeers.tsx'
|
||||
import { Copyable, Grid, IPSEC_HEADS, Pairs, Section, bytes, ipsecRows, text } from './RouterPanel.tsx'
|
||||
import { Copyable, Grid, IPSEC_HEADS, Pairs, Section, bytes, ipsecRows, text } from './ServerPanel.tsx'
|
||||
import {
|
||||
DETAILS_SHAPE, REMOTE_ACCESS_LABELS, REMOTE_ACCESS_SECTION_SHAPES, REMOTE_ACCESS_SHAPE, STATUS_SHAPE, USERS_SHAPE, request,
|
||||
type RemoteAccess, type RemoteAccessSystem, type RouterDetails, type RouterStatus, type Users,
|
||||
@@ -21,11 +21,11 @@ const DESCRIPTIONS: Record<RemoteAccessSystem, string> = {
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings and the state of one remote access system of the router, from its /remote-access and /status/full: the
|
||||
* The settings and the state of one remote access system of the server, from its /remote-access and /status/full: the
|
||||
* settings with Edit, whether setup runs the system, why an enabled one does not run, and its connected clients; for
|
||||
* IKEv2, from /config too, the IPsec security associations, child SAs, connections and connection children of all but
|
||||
* the site-to-site connections, that is of IKEv2 access; for WireGuard, from /users and /config too, the peers of the users, added and removed here (WireGuardPeers), and each
|
||||
* connection with its user, found by the peer's key, its IPs, endpoint, handshake and traffic. The router applies a
|
||||
* connection with its user, found by the peer's key, its IPs, endpoint, handshake and traffic. The server applies a
|
||||
* change in the background; Refresh reads the state again.
|
||||
*/
|
||||
export default function RemoteAccessPanel(props: { system: RemoteAccessSystem }) {
|
||||
@@ -35,11 +35,11 @@ export default function RemoteAccessPanel(props: { system: RemoteAccessSystem })
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [editing, setEditing] = useState(false)
|
||||
const [showConfig, setShowConfig] = useState(false)
|
||||
// WireGuard's: the users with their peers, and the router's details with each peer's key, endpoint and traffic.
|
||||
// WireGuard's: the users with their peers, and the server's details with each peer's key, endpoint and traffic.
|
||||
const [users, setUsers] = useState<Users | null>(null)
|
||||
const [details, setDetails] = useState<RouterDetails | null>(null)
|
||||
const wireguard = props.system === 'wireguard'
|
||||
// IKEv2's: the router's details with its IPsec SAs and connections, those of IKEv2 access being all but site to site.
|
||||
// IKEv2's: the server's details with its IPsec SAs and connections, those of IKEv2 access being all but site to site.
|
||||
const ikev2 = props.system === 'p2s'
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
@@ -88,7 +88,7 @@ export default function RemoteAccessPanel(props: { system: RemoteAccessSystem })
|
||||
const peers = status?.wireguard?.peers
|
||||
const siteToSite = new Set((details?.network.site_to_site ?? []).map((connection) => connection.name))
|
||||
const ipsec = ipsecRows(ikev2 ? details : null, (name) => !siteToSite.has(name))
|
||||
// An IPsec table is shown with rows, or with the note that the router could not read them.
|
||||
// An IPsec table is shown with rows, or with the note that the server could not read them.
|
||||
const shown = (rows: string[][] | undefined) => ikev2 && details !== null && (rows === undefined || rows.length > 0)
|
||||
|
||||
return (
|
||||
@@ -101,8 +101,8 @@ export default function RemoteAccessPanel(props: { system: RemoteAccessSystem })
|
||||
{access && settings && settings.enabled && !running && (
|
||||
<Alert severity="warning" sx={{ mb: 2 }}>
|
||||
{system === 'wireguard'
|
||||
? 'WireGuard is enabled but does not run yet; the router applies a change within a moment.'
|
||||
: `${REMOTE_ACCESS_LABELS[system]} is enabled but does not run yet. It needs wan.local_fqdn${access.local_fqdn ? '' : ', which is not set,'} and the router's VPN server certificate of the P2S issuing CA; the router applies a change within a moment.`}
|
||||
? 'WireGuard is enabled but does not run yet; the server applies a change within a moment.'
|
||||
: `${REMOTE_ACCESS_LABELS[system]} is enabled but does not run yet. It needs wan.local_fqdn${access.local_fqdn ? '' : ', which is not set,'} and the server's VPN server certificate of the P2S issuing CA; the server applies a change within a moment.`}
|
||||
</Alert>
|
||||
)}
|
||||
{access && (
|
||||
|
||||
@@ -15,15 +15,15 @@ import {
|
||||
import { useBrowserSettings } from './settings.ts'
|
||||
|
||||
/** The localStorage key of the tab's layout. */
|
||||
const LAYOUT_KEY = 'vpn-router-manager.router-layout'
|
||||
const LAYOUT_KEY = 'linux-manager-ui.router-layout'
|
||||
|
||||
/**
|
||||
* The router's state: its status, ok or degraded on the title bar of the Status panel, with the update information of
|
||||
* The server's state: its status, ok or degraded on the title bar of the Status panel, with the update information of
|
||||
* its packages (UpdatesNotice) at the top of that panel, its remote access clients, and from /config the status web
|
||||
* service, HTTPS, with a chip while Caddy takes Let's Encrypt's staging CA and a button that opens HttpsSettingsDialog
|
||||
* with /https/settings, and Caddy (version, source and the state of caddy.service) in it; the state of each of its systemd
|
||||
* services and of Caddy in the Services panel; the Addresses panel's links to the status page, over HTTPS for
|
||||
* wan.local_fqdn and over plain HTTP on the addresses web.listen names, and to the Router Manager over HTTPS, and the
|
||||
* wan.local_fqdn and over plain HTTP on the addresses web.listen names, and to the Manager over HTTPS, and the
|
||||
* OpenID Provider's issuer and discovery URL, each with a copy icon, or off while it is disabled; its
|
||||
* backups with Run now, and its non-public details as tables and command output, with a panel per PostgreSQL
|
||||
* cluster: its settings from /config and its databases with their sizes from /postgresql. Read at once, then as the
|
||||
@@ -33,7 +33,7 @@ const LAYOUT_KEY = 'vpn-router-manager.router-layout'
|
||||
* The panels are on a PanelBoard whose layout is kept in the browser: each folds by its title bar and, but for Status,
|
||||
* hides by its [X]; the Panels dialog shows them again, and Edit layout moves them by dragging and sets their width.
|
||||
*/
|
||||
export default function RouterPanel() {
|
||||
export default function ServerPanel() {
|
||||
const [status, setStatus] = useState<RouterStatus | null>(null)
|
||||
const [details, setDetails] = useState<RouterDetails | null>(null)
|
||||
const [databases, setDatabases] = useState<PostgresqlDatabases | null>(null)
|
||||
@@ -46,13 +46,13 @@ export default function RouterPanel() {
|
||||
const [httpsSettings, setHttpsSettings] = useState<HttpsSettings | null>(null)
|
||||
const [httpsError, setHttpsError] = useState<string | null>(null)
|
||||
|
||||
/** Reads the router's https section from /https/settings and opens HttpsSettingsDialog with it. */
|
||||
/** Reads the server's https section from /https/settings and opens HttpsSettingsDialog with it. */
|
||||
async function openHttps() {
|
||||
setHttpsError(null)
|
||||
try {
|
||||
setHttpsSettings((await request<{ settings: HttpsSettings }>('GET', '/https/settings', HTTPS_SETTINGS_SHAPE)).settings)
|
||||
} catch (caught) {
|
||||
setHttpsError(`The router did not give its HTTPS settings: ${(caught as Error).message}`)
|
||||
setHttpsError(`The server did not give its HTTPS settings: ${(caught as Error).message}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,20 +61,20 @@ export default function RouterPanel() {
|
||||
const found: { status?: string; details?: string; databases?: string; backup?: string } = {}
|
||||
const [nextStatus, nextDetails, nextDatabases, nextBackup] = await Promise.all([
|
||||
request<RouterStatus>('GET', '/status/full', STATUS_SHAPE).catch((error: Error) => {
|
||||
found.status = `The router did not give its status: ${error.message}`
|
||||
found.status = `The server did not give its status: ${error.message}`
|
||||
return null
|
||||
}),
|
||||
request<RouterDetails>('GET', '/config', DETAILS_SHAPE).catch((error: Error) => {
|
||||
found.details = `The router did not give its details: ${error.message}`
|
||||
found.details = `The server did not give its details: ${error.message}`
|
||||
return null
|
||||
}),
|
||||
request<PostgresqlDatabases>('GET', '/postgresql', POSTGRESQL_SHAPE).catch((error: Error) => {
|
||||
found.databases = `The router did not give its PostgreSQL databases: ${error.message}`
|
||||
found.databases = `The server did not give its PostgreSQL databases: ${error.message}`
|
||||
return null
|
||||
}),
|
||||
request<Backup>('GET', '/backup', BACKUP_SHAPE).catch((error: ApiError) => {
|
||||
if (error.status !== 404) {
|
||||
found.backup = `The router did not give its backups: ${error.message}`
|
||||
found.backup = `The server did not give its backups: ${error.message}`
|
||||
}
|
||||
return null
|
||||
}),
|
||||
@@ -200,7 +200,7 @@ export default function RouterPanel() {
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
) : <Typography variant="body2" color="text.secondary">The router's status is not read yet.</Typography>}
|
||||
) : <Typography variant="body2" color="text.secondary">The server's status is not read yet.</Typography>}
|
||||
</>
|
||||
),
|
||||
})
|
||||
@@ -284,7 +284,7 @@ export default function RouterPanel() {
|
||||
<Pairs
|
||||
rows={[
|
||||
['Status page', <Links key="status" urls={[...(httpsOn && fqdn ? [`https://${fqdn}:${text(https?.web_port)}`] : []), ...plain]} />],
|
||||
['Router Manager', <Links key="manager" urls={httpsOn && fqdn ? [`https://${fqdn}:${text(https?.manager_port)}`] : []} />],
|
||||
['Ubuntu Linux Manager', <Links key="manager" urls={httpsOn && fqdn ? [`https://${fqdn}:${text(https?.manager_port)}`] : []} />],
|
||||
...(details.oidc?.issuer
|
||||
? [
|
||||
['OpenID Provider', <Copyable key="issuer" value={details.oidc.issuer} label="issuer" />],
|
||||
@@ -402,12 +402,12 @@ export function text(value: unknown): string {
|
||||
return value === undefined || value === null || value === '' ? '-' : String(value)
|
||||
}
|
||||
|
||||
/** The names shown for the router's systemd units; a unit not listed is shown by its unit name. */
|
||||
/** The names shown for the server's systemd units; a unit not listed is shown by its unit name. */
|
||||
const UNIT_LABELS: Record<string, string> = {
|
||||
'vpn-router-setup': 'VPN Router Setup',
|
||||
'linux-manager-setup': 'Linux Manager Setup',
|
||||
strongswan: 'StrongSwan',
|
||||
'wg-quick@wg0': 'WireGuard interface',
|
||||
'openvpn-server@vpn-router': 'OpenVPN server',
|
||||
'openvpn-server@linux-manager': 'OpenVPN server',
|
||||
slapd: 'OpenLDAP',
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ export function Copyable(props: { value: string; label: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** A table with a header row, or a note when the router could not read it. */
|
||||
/** A table with a header row, or a note when the server could not read it. */
|
||||
export function Grid(props: { head: string[]; rows: string[][] | undefined }) {
|
||||
if (props.rows === undefined) {
|
||||
return <Typography variant="body2" color="text.secondary">Not available.</Typography>
|
||||
@@ -539,7 +539,7 @@ const SECTION_LABELS: Record<string, string> = {
|
||||
https: 'HTTPS',
|
||||
}
|
||||
|
||||
/** The names shown for where the router's Caddy comes from. */
|
||||
/** The names shown for where the server's Caddy comes from. */
|
||||
const CADDY_SOURCES: Record<string, string> = { ubuntu: 'Ubuntu', upstream: 'Upstream' }
|
||||
|
||||
/**
|
||||
@@ -584,8 +584,8 @@ export const IPSEC_HEADS = {
|
||||
}
|
||||
|
||||
/**
|
||||
* The rows of the IPsec tables of the router's /config for the connections whose names keep accepts: the IKE SAs, their
|
||||
* child SAs, the connections and their children; undefined where the router could not list them.
|
||||
* The rows of the IPsec tables of the server's /config for the connections whose names keep accepts: the IKE SAs, their
|
||||
* child SAs, the connections and their children; undefined where the server could not list them.
|
||||
*/
|
||||
export function ipsecRows(details: RouterDetails | null, keep: (name: string) => boolean) {
|
||||
const sas = details?.ipsec.sas?.filter((sa) => keep(sa.name))
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import type { Role, User } from './api.ts'
|
||||
|
||||
/** The names vpn-router-user accepts for a service account: a user name or a GUID in lowercase. */
|
||||
/** The names linux-manager-user accepts for a service account: a user name or a GUID in lowercase. */
|
||||
const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}[a-z0-9]$|^[a-z]$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
||||
|
||||
/** A random GUID (version 4) in lowercase, from crypto.getRandomValues, which pages served over plain HTTP have too. */
|
||||
@@ -19,21 +19,21 @@ function newGuid() {
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
|
||||
}
|
||||
|
||||
/** The e-mail addresses vpn-router-user accepts: one @, no spaces, and a dot in the domain. */
|
||||
/** The e-mail addresses linux-manager-user accepts: one @, no spaces, and a dot in the domain. */
|
||||
const EMAIL_PATTERN = /^[^@\s]+@[^@\s]+\.[^@\s]+$/
|
||||
|
||||
/** The longest display name and description the router accepts. */
|
||||
/** The longest display name and description the server accepts. */
|
||||
const DISPLAY_NAME_MAX = 64
|
||||
const DESCRIPTION_MAX = 256
|
||||
|
||||
/** The most URIs of each kind and allowed groups of an OpenID Provider client, and the longest URI, the router accepts. */
|
||||
/** The most URIs of each kind and allowed groups of an OpenID Provider client, and the longest URI, the server accepts. */
|
||||
const CLIENT_VALUES_MAX = 16
|
||||
const URI_MAX = 1024
|
||||
|
||||
/** The hosts a client's URI may name over plain HTTP. */
|
||||
const LOOPBACK_HOSTS = ['localhost', '127.0.0.1', '[::1]']
|
||||
|
||||
/** The names of a role and of a scope of a resource the router accepts. */
|
||||
/** The names of a role and of a scope of a resource the server accepts. */
|
||||
const ROLE_NAME = /^[A-Za-z][A-Za-z0-9._-]{0,63}$/
|
||||
const SCOPE_NAME = /^[a-z][a-z0-9._-]{0,63}$/
|
||||
|
||||
@@ -55,7 +55,7 @@ export type ServiceAccountSettings = {
|
||||
roles: Role[]
|
||||
}
|
||||
|
||||
/** Why the roles are refused by the router, or ''. */
|
||||
/** Why the roles are refused by the server, or ''. */
|
||||
function rolesProblem(roles: Role[]) {
|
||||
for (const role of roles) {
|
||||
if (!ROLE_NAME.test(role.name.trim())) {
|
||||
@@ -74,7 +74,7 @@ function lines(text: string) {
|
||||
return text.split('\n').map((line) => line.trim()).filter((line) => line !== '')
|
||||
}
|
||||
|
||||
/** Why the URIs of a text field are refused by the router, or ''. */
|
||||
/** Why the URIs of a text field are refused by the server, or ''. */
|
||||
function urisProblem(text: string) {
|
||||
const uris = lines(text)
|
||||
if (uris.length > CLIENT_VALUES_MAX) {
|
||||
@@ -102,7 +102,7 @@ function urisProblem(text: string) {
|
||||
* no secret, which client credentials need, and the client scopes, chosen from scopes, those of every resource; an account with redirect URIs or grants is
|
||||
* a client, its name the client ID and its password the secret. As a resource: its scopes, typed, and its roles, each with a name, a description and the
|
||||
* groups and accounts, chosen from accounts, it is assigned to. onSave sends them, trimmed, with the password when adding; the dialog closes when it
|
||||
* succeeds and shows the router's message when it fails.
|
||||
* succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function ServiceAccountDialog(props: {
|
||||
account?: User
|
||||
|
||||
@@ -9,7 +9,7 @@ import Refresh from '@mui/icons-material/Refresh'
|
||||
import { Alert, Box, Button, IconButton, Table, TableBody, TableCell, TableHead, TableRow, Tooltip } from '@mui/material'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import { Section } from './RouterPanel.tsx'
|
||||
import { Section } from './ServerPanel.tsx'
|
||||
import SearchField, { matches } from './SearchField.tsx'
|
||||
import ServiceAccountDialog from './ServiceAccountDialog.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
@@ -42,13 +42,13 @@ function oidcText(account: User) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The service accounts of the router's directory, from its /service-accounts: the accounts other systems sign in with
|
||||
* to use the router's services. List with their display names, descriptions, e-mail addresses, OpenID Provider
|
||||
* The service accounts of the server's directory, from its /service-accounts: the accounts other systems sign in with
|
||||
* to use the server's services. List with their display names, descriptions, e-mail addresses, OpenID Provider
|
||||
* settings and state, add, edit the display name, the description, the e-mail address and the OpenID Provider settings,
|
||||
* as a client and as a resource with its scopes and roles, set the password, disable, enable, unlock after failed
|
||||
* logins and remove. While the OpenID Provider is enabled, the list's title has the number of its clients, the service
|
||||
* accounts with redirect URIs or grants; its issuer is on the Overview's Addresses panel. The internal ones, which the router creates and manages for its own services with all their properties, are
|
||||
* listed only: the router refuses every change of them through the API.
|
||||
* accounts with redirect URIs or grants; its issuer is on the Overview's Addresses panel. The internal ones, which the server creates and manages for its own services with all their properties, are
|
||||
* listed only: the server refuses every change of them through the API.
|
||||
*/
|
||||
export default function ServiceAccountsPanel() {
|
||||
const [accounts, setAccounts] = useState<User[] | null>(null)
|
||||
@@ -127,7 +127,7 @@ export default function ServiceAccountsPanel() {
|
||||
|
||||
return (
|
||||
<Box component="section">
|
||||
<Toolbar description="Accounts of other systems that use the router's services.">
|
||||
<Toolbar description="Accounts of other systems that use the server's services.">
|
||||
<SearchField value={search} onChange={setSearch} />
|
||||
<Button variant="contained" startIcon={<Add />} disabled={busy || accounts === null} onClick={() => setAdding(true)}>
|
||||
Add
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from 'react'
|
||||
import { DEFAULT_SETTINGS, REFRESH_CHOICES, refreshLabel, saveBrowserSettings, useBrowserSettings } from './settings.ts'
|
||||
|
||||
/**
|
||||
* An icon button that opens the settings of this browser: how often the Overview and the Metrics tab read the router on
|
||||
* An icon button that opens the settings of this browser: how often the Overview and the Metrics tab read the server on
|
||||
* their own, or manual, when they read only when opened and on Refresh. A change applies at once and is kept in the
|
||||
* browser; Defaults sets every setting back.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ export default function SettingsButton() {
|
||||
select
|
||||
label="Metrics tab refresh"
|
||||
value={settings.metricsRefresh}
|
||||
helperText="The router takes a sample every minute."
|
||||
helperText="The server takes a sample every minute."
|
||||
onChange={(event) => saveBrowserSettings({ ...settings, metricsRefresh: Number(event.target.value) })}
|
||||
>
|
||||
{REFRESH_CHOICES.map((seconds) => <MenuItem key={seconds} value={seconds}>{refreshLabel(seconds)}</MenuItem>)}
|
||||
|
||||
@@ -18,15 +18,15 @@ const THEMES: Record<'light' | 'dark', ITheme> = {
|
||||
const FONT = "Menlo, Monaco, Consolas, 'Droid Sans Mono', 'DejaVu Sans Mono', 'Courier New', monospace"
|
||||
|
||||
/**
|
||||
* A login shell on the router in an xterm.js terminal, as the signed-in user's console account; a user whose console
|
||||
* login is not on is told how root switches it on. The router gives a ticket without a sign-in while the user's last
|
||||
* A login shell on the server in an xterm.js terminal, as the signed-in user's console account; a user whose console
|
||||
* login is not on is told how root switches it on. The server gives a ticket without a sign-in while the user's last
|
||||
* use of a shell is within its web.shell_auth_timeout; otherwise the user signs in again with the password and the
|
||||
* code, or with one of its passkeys, which the browser unlocks with the device's PIN or biometrics. With the ticket, a
|
||||
* WebSocket to /api/shell carries the terminal: keystrokes and output as binary
|
||||
* messages, the window size as a text message {cols, rows}. When the router or the connection ends the shell, the
|
||||
* messages, the window size as a text message {cols, rows}. When the server or the connection ends the shell, the
|
||||
* terminal stays readable with the reason above it, and New shell asks for a new ticket.
|
||||
*
|
||||
* A text message {editor: "open", session, id, path} of the router, sent when vre in the shell names a file, opens the
|
||||
* A text message {editor: "open", session, id, path} of the server, sent when lme in the shell names a file, opens the
|
||||
* file in the editor (EditorPanel) and calls onOpened. editorShown shows the editor in place of the terminal, which
|
||||
* keeps running; onFiles is called with the number of open files, 0 once the last is closed or the shell ends.
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ export default function ShellPanel(props: { editorShown: boolean; onFiles: (coun
|
||||
const codeProblem = !CODE_PATTERN.test(code) ? 'Six digits.' : ''
|
||||
const login = account?.console?.enabled && account.otp ? account.console : null
|
||||
|
||||
/** Asks the router for a ticket without signing in; the sign-in form shows when the router wants one. */
|
||||
/** Asks the server for a ticket without signing in; the sign-in form shows when the server wants one. */
|
||||
const reopen = useCallback(async () => {
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
@@ -189,7 +189,7 @@ export default function ShellPanel(props: { editorShown: boolean; onFiles: (coun
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens a shell with one of the user's passkeys, which the router asks the browser for. */
|
||||
/** Opens a shell with one of the user's passkeys, which the server asks the browser for. */
|
||||
async function openWithPasskey() {
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
@@ -218,7 +218,7 @@ export default function ShellPanel(props: { editorShown: boolean; onFiles: (coun
|
||||
<Alert severity="info">
|
||||
{account.console?.enabled
|
||||
? 'The shell needs one-time passwords. Enrol an authenticator app on the Account page.'
|
||||
: `Console login is not on for ${account.name}. Root on the router switches it on: vpn-router-user console ${account.name} --posix, or --account LOCAL to use a local account.`}
|
||||
: `Console login is not on for ${account.name}. Root on the server switches it on: linux-manager-user console ${account.name} --posix, or --account LOCAL to use a local account.`}
|
||||
</Alert>
|
||||
)}
|
||||
{ticket === null && !account && error && <Alert severity="error" sx={{ whiteSpace: 'pre-line' }}>{error}</Alert>}
|
||||
@@ -228,7 +228,7 @@ export default function ShellPanel(props: { editorShown: boolean; onFiles: (coun
|
||||
<Stack sx={{ gap: 2 }}>
|
||||
<Typography variant="h6" component="h3">Open a shell</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{`The shell runs on the router as ${login.local ? 'the local account' : 'your POSIX account'} ${login.account}. Sign in again to open it.`}
|
||||
{`The shell runs on the server as ${login.local ? 'the local account' : 'your POSIX account'} ${login.account}. Sign in again to open it.`}
|
||||
</Typography>
|
||||
{error && <Alert severity="error" sx={{ whiteSpace: 'pre-line' }}>{error}</Alert>}
|
||||
<TextField label="Password" type="password" value={password} autoFocus autoComplete="current-password" onChange={(event) => setPassword(event.target.value)} />
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ import { CODE_PATTERN, PASSKEY_BEGUN_SHAPE, SESSION_SHAPE, request, type Passkey
|
||||
|
||||
/**
|
||||
* The sign-in form: the user name, the password and, for a user enrolled for one-time passwords, the code, or a
|
||||
* passkey in a browser with WebAuthn. The router checks them; onSignedIn gets the session, and a failure shows the
|
||||
* router's message.
|
||||
* passkey in a browser with WebAuthn. The server checks them; onSignedIn gets the session, and a failure shows the
|
||||
* server's message.
|
||||
*/
|
||||
export default function SignIn(props: { onSignedIn: (session: Session) => void }) {
|
||||
const [name, setName] = useState('')
|
||||
@@ -33,7 +33,7 @@ export default function SignIn(props: { onSignedIn: (session: Session) => void }
|
||||
}
|
||||
}
|
||||
|
||||
/** Signs in with a passkey the browser offers for the router's name. */
|
||||
/** Signs in with a passkey the browser offers for the server's name. */
|
||||
async function signInWithPasskey() {
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
type SiteDnsAddress, type SiteTls,
|
||||
} from './api.ts'
|
||||
|
||||
/** The names, host names and index files the router accepts for a site. */
|
||||
/** The names, host names and index files the server accepts for a site. */
|
||||
const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}$/
|
||||
const HOST_PATTERN = /^(\*\.)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/
|
||||
const ADDRESS_PATTERN = /^(\d{1,3}\.){3}\d{1,3}$|^[0-9a-f:]+:[0-9a-f:]*$/
|
||||
@@ -40,11 +40,11 @@ function hostLines(text: string) {
|
||||
* A dialog that adds a site, with its name, or, given a site, edits it: whether it is served, its host names, one per
|
||||
* line, its port, the interfaces whose firewall opens it, its TLS with the issuing CA of cas or a certificate chain and
|
||||
* key in PEM, read from files or pasted, its index file, the single-page fallback, the editors group, chosen from
|
||||
* groups, and its DNS: User managed, its records kept by a DNS provider outside the router, or Router managed, the
|
||||
* router's name server giving its host names records of the router's Public, Internal or External interface IP. A host
|
||||
* name may be the router's FQDN, on a port of the site's own, but not with Router managed: the record of the router's
|
||||
* groups, and its DNS: User managed, its records kept by a DNS provider outside the server, or Router managed, the
|
||||
* server's name server giving its host names records of the server's Public, Internal or External interface IP. A host
|
||||
* name may be the server's FQDN, on a port of the site's own, but not with Router managed: the record of the server's
|
||||
* FQDN stays where its domain is. onSave sends them; an empty private key keeps the current one. The dialog closes when
|
||||
* it succeeds and shows the router's message when it fails.
|
||||
* it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function SiteDialog(props: {
|
||||
site?: Site
|
||||
@@ -155,7 +155,7 @@ export default function SiteDialog(props: {
|
||||
multiline
|
||||
minRows={2}
|
||||
error={hostsProblem !== ''}
|
||||
helperText={hostsProblem || 'The names the site answers on, one per line, also the router\'s FQDN; none answers any name.'}
|
||||
helperText={hostsProblem || 'The names the site answers on, one per line, also the server\'s FQDN; none answers any name.'}
|
||||
onChange={(event) => setHosts(event.target.value)}
|
||||
/>
|
||||
<Stack direction="row" sx={{ gap: 2 }}>
|
||||
@@ -165,8 +165,8 @@ export default function SiteDialog(props: {
|
||||
value={dns}
|
||||
error={dnsProblem !== ''}
|
||||
helperText={dnsProblem || (dns === 'router'
|
||||
? 'The router\'s name server gives each host name a record in its domain on the DNS page.'
|
||||
: 'The records are kept by a DNS provider outside the router.')}
|
||||
? 'The server\'s name server gives each host name a record in its domain on the DNS page.'
|
||||
: 'The records are kept by a DNS provider outside the server.')}
|
||||
onChange={(event) => setDns(event.target.value as SiteDns)}
|
||||
sx={{ flex: 1 }}
|
||||
>
|
||||
@@ -177,7 +177,7 @@ export default function SiteDialog(props: {
|
||||
label="Address"
|
||||
value={dnsAddress}
|
||||
disabled={dns !== 'router'}
|
||||
helperText="The router's address in the records."
|
||||
helperText="The server's address in the records."
|
||||
onChange={(event) => setDnsAddress(event.target.value as SiteDnsAddress)}
|
||||
sx={{ flex: 1 }}
|
||||
>
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '@mui/material'
|
||||
import { useCallback, useEffect, useState, type DragEvent, type FormEvent } from 'react'
|
||||
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import { Section, bytes } from './RouterPanel.tsx'
|
||||
import { Section, bytes } from './ServerPanel.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import {
|
||||
ApiError, SITES_SHAPE, SITE_FILES_SHAPE, SITE_FOLDER_SHAPE, SITE_PATH_SHAPE, download, encodedPath, request, upload,
|
||||
@@ -66,11 +66,11 @@ function NameDialog(props: { title: string; label: string; initial: string; onSa
|
||||
}
|
||||
|
||||
/**
|
||||
* The files of a web site, from the router's /sites/<name>/files/: the site chosen from the sites, starting with site,
|
||||
* The files of a web site, from the server's /sites/<name>/files/: the site chosen from the sites, starting with site,
|
||||
* a folder at a time with its path as links up to the site's folder. List the files and folders with their sizes and
|
||||
* times, open a folder, download a file, upload files, chosen or dropped on the list, into the folder shown, with zip
|
||||
* archives extracted there while Extract zip archives is on, create a folder, rename and remove. An upload shows its
|
||||
* progress; a file larger than the router's sites.upload_max_mb is not sent.
|
||||
* progress; a file larger than the server's sites.upload_max_mb is not sent.
|
||||
*/
|
||||
export default function SiteFiles(props: { site: string | null; onSite: (name: string) => void }) {
|
||||
const [sites, setSites] = useState<Sites | null>(null)
|
||||
|
||||
@@ -2,12 +2,12 @@ import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuI
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { CONNECTION_AUTH, LOCAL_ID_MODES, type SiteToSiteConnection, type SiteToSiteSettings } from './api.ts'
|
||||
|
||||
/** The connection names the router accepts: they name its swanctl connection, child and secret. */
|
||||
/** The connection names the server accepts: they name its swanctl connection, child and secret. */
|
||||
const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}$/
|
||||
|
||||
/** The labels of the local identity modes. */
|
||||
const MODE_LABELS: Record<string, string> = {
|
||||
fqdn: 'FQDN of the router',
|
||||
fqdn: 'FQDN of the server',
|
||||
public_ip: 'Public IP, resolved from the FQDN',
|
||||
internal_ip: 'Internal IP',
|
||||
}
|
||||
@@ -15,7 +15,7 @@ const MODE_LABELS: Record<string, string> = {
|
||||
/** The labels of the authentication methods. */
|
||||
const AUTH_LABELS: Record<string, string> = {
|
||||
psk: 'Pre-shared key',
|
||||
certificate: "Certificates: the router's site-to-site certificate",
|
||||
certificate: "Certificates: the server's site-to-site certificate",
|
||||
}
|
||||
|
||||
/** A list typed as text separated by commas. */
|
||||
@@ -26,9 +26,9 @@ function listOf(text: string) {
|
||||
/**
|
||||
* A dialog that adds a site-to-site connection, or, given a connection, edits its settings: the remote peer's
|
||||
* addresses, its identity and subnets, the local subnets, the local identity mode and the authentication: a pre-shared
|
||||
* key, or certificates with the optional PEM certificate of the CA of the peer's certificate, the router's site-to-site
|
||||
* key, or certificates with the optional PEM certificate of the CA of the peer's certificate, the server's site-to-site
|
||||
* CA without one. The key is required for a connection with a pre-shared key that has none; otherwise an empty key keeps
|
||||
* the current one. onSave sends them; the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* the current one. onSave sends them; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function SiteToSiteDialog(props: {
|
||||
connection?: SiteToSiteConnection
|
||||
@@ -152,7 +152,7 @@ export default function SiteToSiteDialog(props: {
|
||||
maxRows={12}
|
||||
autoComplete="off"
|
||||
error={remoteCaProblem !== ''}
|
||||
helperText={remoteCaProblem || "The PEM certificate of the CA of the peer's certificate; empty for the router's site-to-site CA."}
|
||||
helperText={remoteCaProblem || "The PEM certificate of the CA of the peer's certificate; empty for the server's site-to-site CA."}
|
||||
slotProps={{ htmlInput: { sx: { fontFamily: 'monospace', fontSize: 12 } } }}
|
||||
onChange={(event) => setRemoteCa(event.target.value)}
|
||||
/>
|
||||
|
||||
@@ -9,20 +9,20 @@ import {
|
||||
} from '@mui/material'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import { Section } from './RouterPanel.tsx'
|
||||
import { Section } from './ServerPanel.tsx'
|
||||
import SiteToSiteDialog from './SiteToSiteDialog.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import {
|
||||
ApiError, REMOVED_SHAPE, SITE_TO_SITE_CONNECTION_SHAPE, SITE_TO_SITE_SHAPE, request, type SiteToSiteConnection,
|
||||
} from './api.ts'
|
||||
|
||||
/** The note shown after a change, which the router applies when vpn-router-setup has run again. */
|
||||
const APPLIED = 'The router applies the change in the background; Established follows once the tunnel is up again.'
|
||||
/** The note shown after a change, which the server applies when linux-manager-setup has run again. */
|
||||
const APPLIED = 'The server applies the change in the background; Established follows once the tunnel is up again.'
|
||||
|
||||
/**
|
||||
* The router's site-to-site connections: list with their remote peers, subnets, local identity mode, authentication
|
||||
* The server's site-to-site connections: list with their remote peers, subnets, local identity mode, authentication
|
||||
* (whether a pre-shared key is set, or which CA the peer's certificate comes from) and whether the tunnel is
|
||||
* established; add, edit and remove. The router applies a change by
|
||||
* established; add, edit and remove. The server applies a change by
|
||||
* running its setup again, so the list is read again after each.
|
||||
*/
|
||||
export default function SiteToSitePanel() {
|
||||
@@ -131,7 +131,7 @@ export default function SiteToSitePanel() {
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{connection.established === null
|
||||
? <Tooltip title="The router cannot tell."><span>-</span></Tooltip>
|
||||
? <Tooltip title="The server cannot tell."><span>-</span></Tooltip>
|
||||
: connection.established
|
||||
? <CheckCircle fontSize="small" color="success" aria-label="established" />
|
||||
: <Cancel fontSize="small" color="error" aria-label="not established" />}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import Refresh from '@mui/icons-material/Refresh'
|
||||
import { Alert, Box, Button, Stack } from '@mui/material'
|
||||
import { Grid, IPSEC_HEADS, Section, duration, ipsecRows, text } from './RouterPanel.tsx'
|
||||
import { Grid, IPSEC_HEADS, Section, duration, ipsecRows, text } from './ServerPanel.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { DETAILS_SHAPE, request, type RouterDetails } from './api.ts'
|
||||
import { useRead } from './useRead.ts'
|
||||
|
||||
/** Reads the router's /config. */
|
||||
/** Reads the server's /config. */
|
||||
const readDetails = () => request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
|
||||
|
||||
/**
|
||||
* How long a site-to-site connection has been up: the age of its oldest established IKE SA; "down" without one, and
|
||||
* "unknown" when the router could not list its SAs.
|
||||
* "unknown" when the server could not list its SAs.
|
||||
*/
|
||||
function uptimeOf(sas: RouterDetails['ipsec']['sas'], name: string) {
|
||||
if (sas === null) {
|
||||
@@ -21,7 +21,7 @@ function uptimeOf(sas: RouterDetails['ipsec']['sas'], name: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The state of the router's site-to-site connections, from its /config: each with the identities and subnets the
|
||||
* The state of the server's site-to-site connections, from its /config: each with the identities and subnets the
|
||||
* router resolved for it and how long it has been up, and their IPsec security associations, child SAs, connections
|
||||
* and connection children.
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ import Settings from '@mui/icons-material/Settings'
|
||||
import { Alert, Box, Button, Checkbox, Chip, FormControlLabel, IconButton, Link, Stack, Table, TableBody, TableCell, TableHead, TableRow, Tooltip } from '@mui/material'
|
||||
import { useCallback, useEffect, useState, type ReactNode } from 'react'
|
||||
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import { Copyable, Pairs, Section } from './RouterPanel.tsx'
|
||||
import { Copyable, Pairs, Section } from './ServerPanel.tsx'
|
||||
import SearchField, { matches } from './SearchField.tsx'
|
||||
import SiteDialog, { type SiteSettings } from './SiteDialog.tsx'
|
||||
import SitesSettingsDialog from './SitesSettingsDialog.tsx'
|
||||
@@ -27,7 +27,7 @@ function siteUrls(site: Site) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The web sites of the router's /sites, which Caddy serves from folders on the router. The Settings panel shows the
|
||||
* The web sites of the server's /sites, which Caddy serves from folders on the server. The Settings panel shows the
|
||||
* sites section, whether they are served, the largest upload and WebDAV with its URL, edited with Settings. The list
|
||||
* shows each site with its URLs, port, interfaces, TLS, editors group, DNS and state: add, edit, enable, disable,
|
||||
* remove, with its folder when asked, and open its files on the Files tab with onOpenFiles.
|
||||
@@ -114,7 +114,7 @@ export default function SitesPanel(props: { onOpenFiles: (name: string) => void
|
||||
|
||||
return (
|
||||
<Box component="section">
|
||||
<Toolbar description="Static web sites Caddy serves from folders on the router.">
|
||||
<Toolbar description="Static web sites Caddy serves from folders on the server.">
|
||||
<SearchField value={search} onChange={setSearch} />
|
||||
<Button variant="outlined" startIcon={<Settings />} disabled={busy || !section} onClick={() => setSettings(true)}>
|
||||
Settings
|
||||
|
||||
@@ -2,12 +2,12 @@ import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormC
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import type { SitesSettings } from './api.ts'
|
||||
|
||||
/** The largest upload limit the router accepts, in MiB. */
|
||||
/** The largest upload limit the server accepts, in MiB. */
|
||||
const UPLOAD_MAX_MB = 10240
|
||||
|
||||
/**
|
||||
* A dialog that edits the router's sites section: whether the sites are served, the largest upload in MiB, and WebDAV
|
||||
* with its port. onSave sends the section; the dialog closes when it succeeds and shows the router's message when it
|
||||
* A dialog that edits the server's sites section: whether the sites are served, the largest upload in MiB, and WebDAV
|
||||
* with its port. onSave sends the section; the dialog closes when it succeeds and shows the server's message when it
|
||||
* fails.
|
||||
*/
|
||||
export default function SitesSettingsDialog(props: {
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Board, useBoard, type BoardPanel } from './PanelBoard.tsx'
|
||||
import UpdatesNotice from './UpdatesNotice.tsx'
|
||||
|
||||
/** The localStorage key of the tab's layout. */
|
||||
const LAYOUT_KEY = 'vpn-router-manager.system-layout'
|
||||
const LAYOUT_KEY = 'linux-manager-ui.system-layout'
|
||||
|
||||
/**
|
||||
* The router's operating system: the System updates panel lists the packages apt-get upgrade would upgrade, with Check
|
||||
* The server's operating system: the System updates panel lists the packages apt-get upgrade would upgrade, with Check
|
||||
* update and Upgrade (UpdatesNotice with system). The panel is on a PanelBoard whose layout is kept in the browser.
|
||||
*/
|
||||
export default function SystemPanel() {
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
|
||||
/**
|
||||
* A dialog that adds a certificate template, or with name changes one, a built-in template included: its name, fixed
|
||||
* once it exists, the key the router makes, the lifetime, the key usages, the extended key usages, built in or custom,
|
||||
* once it exists, the key the server makes, the lifetime, the key usages, the extended key usages, built in or custom,
|
||||
* the kind of common name, the subject alternative names allowed and the certificate policy OIDs. onSave gets the name and the options; the dialog closes when it
|
||||
* succeeds and shows the router's message when it fails.
|
||||
* succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function TemplateDialog(props: {
|
||||
pki: Pki
|
||||
|
||||
+13
-13
@@ -21,7 +21,7 @@ const STATES: Record<UpgradeState['state'], string> = {
|
||||
}
|
||||
|
||||
/**
|
||||
* The update information of the router's package, read when shown: a table of the package with its installed
|
||||
* The update information of the server's package, read when shown: a table of the package with its installed
|
||||
* version and, when the repository apt is configured with has a newer one, that version, as of apt's last update of
|
||||
* its package lists. With system, that of the system's packages instead: a table of the packages apt-get upgrade
|
||||
* would upgrade, each with its installed and its new version, from /system-updates, upgraded by /system-upgrade.
|
||||
@@ -29,11 +29,11 @@ const STATES: Record<UpgradeState['state'], string> = {
|
||||
* Check update, always in the top right corner, has the manager update apt's package lists, and the information is
|
||||
* read again every POLL_SECONDS until the update ends.
|
||||
*
|
||||
* With updates available, Upgrade is added beside it and starts the upgrade of the packages on the router after a confirmation, and a dialog
|
||||
* follows it every POLL_SECONDS with its output. The upgrade restarts the manager and the router's web service, so a
|
||||
* With updates available, Upgrade is added beside it and starts the upgrade of the packages on the server after a confirmation, and a dialog
|
||||
* follows it every POLL_SECONDS with its output. The upgrade restarts the manager and the server's web service, so a
|
||||
* failed read is shown as a restart and reading goes on. When the manager's package changed, Reload page loads its new
|
||||
* web application. A failed or interrupted upgrade is shown with its output and can be started again. When a package
|
||||
* asks for a reboot, Reboot reboots the router after a confirmation, and the page reloads once the manager answers again.
|
||||
* asks for a reboot, Reboot reboots the server after a confirmation, and the page reloads once the manager answers again.
|
||||
*
|
||||
* onBusy is called with true while a check, an upgrade or a reboot runs and with false when it ends.
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ export default function UpdatesNotice(props: { onBusy?: (busy: boolean) => void;
|
||||
}
|
||||
}
|
||||
|
||||
const managerChanged = upgrade?.state === 'succeeded' && upgrade.before?.['vpn-router'] !== upgrade.after?.['vpn-router']
|
||||
const managerChanged = upgrade?.state === 'succeeded' && upgrade.before?.['linux-manager'] !== upgrade.after?.['linux-manager']
|
||||
const newer = updates?.available ? updates.packages.filter((item) => item.update) : []
|
||||
const checkedAt = checking
|
||||
? 'checking for updates...'
|
||||
@@ -213,17 +213,17 @@ export default function UpdatesNotice(props: { onBusy?: (busy: boolean) => void;
|
||||
}
|
||||
>
|
||||
{upgrade.rebooting || rebooting
|
||||
? 'The router is rebooting; the page reloads when the Router Manager answers again.'
|
||||
: `The router needs a reboot${upgrade.reboot_packages.length > 0 ? ` for ${upgrade.reboot_packages.join(', ')}` : ''}.`}
|
||||
? 'The server is rebooting; the page reloads when the Manager answers again.'
|
||||
: `The server needs a reboot${upgrade.reboot_packages.length > 0 ? ` for ${upgrade.reboot_packages.join(', ')}` : ''}.`}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{confirming === 'upgrade' && (
|
||||
<ConfirmDialog
|
||||
title={props.system ? "Upgrade the system's packages" : "Upgrade the router's package"}
|
||||
title={props.system ? "Upgrade the system's packages" : "Upgrade the server's package"}
|
||||
message={props.system
|
||||
? `The ${newer.length} packages listed are upgraded on the router with apt-get upgrade; none is installed or removed. Services restart during the upgrade, the Router Manager among them when vpn-router is listed, and the page may not answer for a while.`
|
||||
: 'vpn-router is upgraded on the router. The Router Manager and the router\'s web service restart during the upgrade, and the page may not answer for a while.'}
|
||||
? `The ${newer.length} packages listed are upgraded on the server with apt-get upgrade; none is installed or removed. Services restart during the upgrade, the Manager among them when linux-manager is listed, and the page may not answer for a while.`
|
||||
: 'linux-manager is upgraded on the server. The Manager and the server\'s web service restart during the upgrade, and the page may not answer for a while.'}
|
||||
confirmLabel="Upgrade"
|
||||
destructive={false}
|
||||
onConfirm={() => void start('upgrade')}
|
||||
@@ -232,8 +232,8 @@ export default function UpdatesNotice(props: { onBusy?: (busy: boolean) => void;
|
||||
)}
|
||||
{confirming === 'reboot' && (
|
||||
<ConfirmDialog
|
||||
title="Reboot the router"
|
||||
message={'The router reboots in a few seconds. Its VPN connections are interrupted until it is up again.'}
|
||||
title="Reboot the server"
|
||||
message={'The server reboots in a few seconds. Its VPN connections are interrupted until it is up again.'}
|
||||
confirmLabel="Reboot"
|
||||
destructive
|
||||
onConfirm={() => void start('reboot')}
|
||||
@@ -245,7 +245,7 @@ export default function UpdatesNotice(props: { onBusy?: (busy: boolean) => void;
|
||||
<DialogTitle>{props.system ? 'System upgrade' : 'Upgrade'}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Stack sx={{ gap: 1 }}>
|
||||
{unreachable && <Alert severity="info">The Router Manager is restarting...</Alert>}
|
||||
{unreachable && <Alert severity="info">The Manager is restarting...</Alert>}
|
||||
{upgrade && (
|
||||
<Typography variant="body2">
|
||||
{STATES[upgrade.state]}
|
||||
|
||||
@@ -4,14 +4,14 @@ import PersonFields from './PersonFields.tsx'
|
||||
import type { Person } from './api.ts'
|
||||
import { personComplete, personProblems, trimmed } from './person.ts'
|
||||
|
||||
/** The user names vpn-router-user accepts. */
|
||||
/** The user names linux-manager-user accepts. */
|
||||
const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}[a-z0-9]$|^[a-z]$/
|
||||
|
||||
/**
|
||||
* A dialog that asks for a password, typed twice. Without name it adds a user and asks for the name too, and either
|
||||
* the first name, the last name and the e-mail address of a VPN user, all required, or, with Manager access only, an
|
||||
* optional e-mail address for a Manager-only account. onSave sends them, the person fields as the user gives them;
|
||||
* the dialog closes when it succeeds and shows the router's message when it fails.
|
||||
* the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
*/
|
||||
export default function UserDialog(props: {
|
||||
title: string
|
||||
|
||||
@@ -19,7 +19,7 @@ import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import OtpDialog from './OtpDialog.tsx'
|
||||
import PersonDialog from './PersonDialog.tsx'
|
||||
import ProfileDialog from './ProfileDialog.tsx'
|
||||
import { Section } from './RouterPanel.tsx'
|
||||
import { Section } from './ServerPanel.tsx'
|
||||
import SearchField, { matches } from './SearchField.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import UserDialog from './UserDialog.tsx'
|
||||
@@ -32,7 +32,7 @@ import { saveFile } from './saveFile.ts'
|
||||
type Kind = 'all' | 'vpn' | 'manager'
|
||||
|
||||
/** How console login is changed, which the Manager cannot do. */
|
||||
const CONSOLE_HELP = 'Console login is switched on the router: vpn-router-user console <name> --posix | --account LOCAL | --off'
|
||||
const CONSOLE_HELP = 'Console login is switched on the server: linux-manager-user console <name> --posix | --account LOCAL | --off'
|
||||
|
||||
/** The console login of a user as a cell: off, the user's own POSIX account with its uid, or the local account, refused without one-time passwords. */
|
||||
function consoleText(login: Console | null, otp: boolean) {
|
||||
@@ -44,10 +44,10 @@ function consoleText(login: Console | null, otp: boolean) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The users of the router's directory, which /users answers without its service accounts (ServiceAccountsPanel): list with their names and
|
||||
* The users of the server's directory, which /users answers without its service accounts (ServiceAccountsPanel): list with their names and
|
||||
* e-mail addresses, filtered by kind and by a search in the user name, the names and the e-mail address, add, edit the details, set the password, enrol for one-time passwords and remove the enrolment,
|
||||
* remove the passkeys, disable, enable, unlock after failed logins, remove, the OpenVPN profile, offered while the
|
||||
* router's status shows OpenVPN, and the Apple VPN profile of IKEv2, offered while it shows IKEv2 access; console
|
||||
* server's status shows OpenVPN, and the Apple VPN profile of IKEv2, offered while it shows IKEv2 access; console
|
||||
* login is shown, not changed.
|
||||
*/
|
||||
export default function UsersPanel() {
|
||||
@@ -68,7 +68,7 @@ export default function UsersPanel() {
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
setBusy(true)
|
||||
// The status has openvpn and p2s while the router runs OpenVPN and IKEv2, which the profiles need; null while it is
|
||||
// The status has openvpn and p2s while the server runs OpenVPN and IKEv2, which the profiles need; null while it is
|
||||
// not known.
|
||||
request<RouterStatus>('GET', '/status/full', STATUS_SHAPE)
|
||||
.then((status) => {
|
||||
@@ -119,7 +119,7 @@ export default function UsersPanel() {
|
||||
function removeOtp(name: string) {
|
||||
setConfirm({
|
||||
title: 'Remove the one-time passwords',
|
||||
message: `Remove the TOTP secret of ${name}? The user's authenticator app no longer matches the router.`,
|
||||
message: `Remove the TOTP secret of ${name}? The user's authenticator app no longer matches the server.`,
|
||||
confirmLabel: 'Remove',
|
||||
destructive: true,
|
||||
onCancel: () => setConfirm(null),
|
||||
@@ -268,12 +268,12 @@ export default function UsersPanel() {
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip title={openvpn === false ? 'OpenVPN is not enabled on the router' : 'Download the OpenVPN profile'}>
|
||||
<Tooltip title={openvpn === false ? 'OpenVPN is not enabled on the server' : 'Download the OpenVPN profile'}>
|
||||
<span>
|
||||
<IconButton size="small" disabled={busy || !user.certificate || openvpn === false} onClick={() => void download(user.name)}><Download fontSize="small" /></IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip title={p2s === false ? 'IKEv2 is not enabled on the router' : 'Download the Apple VPN profile (IKEv2)'}>
|
||||
<Tooltip title={p2s === false ? 'IKEv2 is not enabled on the server' : 'Download the Apple VPN profile (IKEv2)'}>
|
||||
<span>
|
||||
<IconButton size="small" disabled={busy || !user.certificate || p2s === false} onClick={() => setAppleProfile(user.name)}><Apple fontSize="small" /></IconButton>
|
||||
</span>
|
||||
|
||||
@@ -10,9 +10,9 @@ import { clientConfig } from './wireguard.ts'
|
||||
const PREFILLED_LINES = 2
|
||||
|
||||
/**
|
||||
* A dialog that shows a device's WireGuard configuration, ready to copy: the router as its peer (server) and the
|
||||
* A dialog that shows a device's WireGuard configuration, ready to copy: the server as its peer (server) and the
|
||||
* device's address, its peer's IPs, or a placeholder without them (ips null). The device's private key is a
|
||||
* placeholder, which the router never has; a switch leaves out the [Interface] and PrivateKey lines, which a client such
|
||||
* placeholder, which the server never has; a switch leaves out the [Interface] and PrivateKey lines, which a client such
|
||||
* as WireGuard for Windows fills in for a new empty tunnel, and keeps its position in the browser's settings. Copy
|
||||
* puts the configuration as shown on the clipboard.
|
||||
*/
|
||||
|
||||
@@ -7,19 +7,19 @@ import { useState } from 'react'
|
||||
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
|
||||
import PeerDialog from './PeerDialog.tsx'
|
||||
import WireGuardConfigDialog from './WireGuardConfigDialog.tsx'
|
||||
import { Section } from './RouterPanel.tsx'
|
||||
import { Section } from './ServerPanel.tsx'
|
||||
import { USER_SHAPE, request, type User, type Users, type WireGuardPeer, type WireGuardServer } from './api.ts'
|
||||
import { saveFile } from './saveFile.ts'
|
||||
import { clientConfig, nextFreeAddress } from './wireguard.ts'
|
||||
|
||||
/**
|
||||
* The WireGuard peers of the router's VPN users, each a device with its public key and IPs, of the users the page read
|
||||
* The WireGuard peers of the server's VPN users, each a device with its public key and IPs, of the users the page read
|
||||
* with GET /users (users, null while unread): a table of the peers with their user, removed by their button after a
|
||||
* confirmation, and Add peer, whose dialog adds a peer to a user, with IPs that start as the next free address of the
|
||||
* network of the router's WireGuard address. A change replaces the user's peers with PUT /users/<name>; the router
|
||||
* network of the server's WireGuard address. A change replaces the user's peers with PUT /users/<name>; the server
|
||||
* writes them into wg0.conf in the background, and onChanged has the page read again. Each peer's configuration for its
|
||||
* device, with its IPs, the router's public key, endpoint and allowed IPs (server), and a placeholder where the device's
|
||||
* private key goes, which the router never has, shows in a dialog ready to copy (the eye) and downloads.
|
||||
* device, with its IPs, the server's public key, endpoint and allowed IPs (server), and a placeholder where the device's
|
||||
* private key goes, which the server never has, shows in a dialog ready to copy (the eye) and downloads.
|
||||
*/
|
||||
export default function WireGuardPeers(props: { server: WireGuardServer; users: Users | null; onChanged: () => void }) {
|
||||
const answer = props.users
|
||||
@@ -92,7 +92,7 @@ export default function WireGuardPeers(props: { server: WireGuardServer; users:
|
||||
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
|
||||
<Tooltip title={props.server.public_key && props.server.endpoint
|
||||
? 'Show the configuration of the device'
|
||||
: "The router's public key or endpoint is not known yet"}>
|
||||
: "The server's public key or endpoint is not known yet"}>
|
||||
<span>
|
||||
<IconButton size="small" disabled={!props.server.public_key || !props.server.endpoint} onClick={() => setShown({ owner: peerOwner, peer })}>
|
||||
<Visibility fontSize="small" />
|
||||
@@ -101,7 +101,7 @@ export default function WireGuardPeers(props: { server: WireGuardServer; users:
|
||||
</Tooltip>
|
||||
<Tooltip title={props.server.public_key && props.server.endpoint
|
||||
? 'Download the configuration of the device'
|
||||
: "The router's public key or endpoint is not known yet"}>
|
||||
: "The server's public key or endpoint is not known yet"}>
|
||||
<span>
|
||||
<IconButton size="small" disabled={!props.server.public_key || !props.server.endpoint} onClick={() => download(peerOwner, peer)}>
|
||||
<Download fontSize="small" />
|
||||
|
||||
+49
-49
@@ -1,4 +1,4 @@
|
||||
/** GET /api/info: the version of the manager package and the URL of the status page of the router it manages. */
|
||||
/** GET /api/info: the version of the manager package and the URL of the status page of the server it manages. */
|
||||
export type Info = {
|
||||
version: string | null
|
||||
status_url: string | null
|
||||
@@ -16,7 +16,7 @@ export type Updates = {
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/upgrade: the state of the upgrade of the router's package, idle before the first one, interrupted when it
|
||||
* GET /api/upgrade: the state of the upgrade of the server's package, idle before the first one, interrupted when it
|
||||
* ended without recording its result; the user who started it, when, its exit status, the installed versions before
|
||||
* and after, the last lines of its output, and whether a package asks for a reboot and one is about to happen.
|
||||
*/
|
||||
@@ -39,13 +39,13 @@ export type Session = {
|
||||
name: string
|
||||
}
|
||||
|
||||
/** The status of the router, as its web service answers /status/full, the whole status. Keys are the router's own. */
|
||||
/** The status of the server, as its web service answers /status/full, the whole status. Keys are the server's own. */
|
||||
export type RouterStatus = {
|
||||
status: 'ok' | 'degraded'
|
||||
/** How much the router shows, its web.status_content: basic, standard or full; the fields below say which come with each. */
|
||||
/** How much the server shows, its web.status_content: basic, standard or full; the fields below say which come with each. */
|
||||
content: 'basic' | 'standard' | 'full'
|
||||
time: string
|
||||
/** The client's address as the router saw it, through the manager the browser's. */
|
||||
/** The client's address as the server saw it, through the manager the browser's. */
|
||||
client_ip: string
|
||||
/** Standard and full. */
|
||||
version?: string | null
|
||||
@@ -54,14 +54,14 @@ export type RouterStatus = {
|
||||
/** Full, as the rest. */
|
||||
units?: Record<string, string>
|
||||
docker?: { installed: boolean; service?: string; rules?: string }
|
||||
/** The number of site-to-site connections set up, and of those established, null when the router cannot tell. */
|
||||
/** The number of site-to-site connections set up, and of those established, null when the server cannot tell. */
|
||||
site_to_site?: { connections: number; established: number | null }
|
||||
p2s?: { clients: number | null }
|
||||
openvpn?: { clients: number | null }
|
||||
wireguard?: { peers: { handshake_seconds_ago: number | null; received_bytes: number; sent_bytes: number }[] | null }
|
||||
}
|
||||
|
||||
/** The non-public information of the router, as its web service answers /config. Keys are the router's own. */
|
||||
/** The non-public information of the server, as its web service answers /config. Keys are the server's own. */
|
||||
export type RouterDetails = {
|
||||
configuration: Record<string, Record<string, unknown>>
|
||||
network: {
|
||||
@@ -71,7 +71,7 @@ export type RouterDetails = {
|
||||
internal_address?: string
|
||||
internal_gateway?: string
|
||||
local_cidrs?: string[]
|
||||
/** Each site-to-site connection with the identities and subnets the router resolved for it. */
|
||||
/** Each site-to-site connection with the identities and subnets the server resolved for it. */
|
||||
site_to_site?: { name: string; local_identity: string; remote_identity: string; local_cidrs: string[]; remote_cidrs: string[] }[]
|
||||
routes: { dst: string; gateway?: string; dev: string; protocol?: string; scope?: string; prefsrc?: string; metric?: number; flags: string[] }[] | null
|
||||
}
|
||||
@@ -110,7 +110,7 @@ export type RouterDetails = {
|
||||
}
|
||||
|
||||
/**
|
||||
* The databases of the router's PostgreSQL clusters, as its web service answers /postgresql; databases and size, the
|
||||
* The databases of the server's PostgreSQL clusters, as its web service answers /postgresql; databases and size, the
|
||||
* total in bytes, are null for a cluster that is not online, and clusters when pg_lsclusters fails.
|
||||
*/
|
||||
export type PostgresqlDatabases = {
|
||||
@@ -130,16 +130,16 @@ export type PostgresqlDatabases = {
|
||||
*/
|
||||
export type Console = { enabled: boolean; account: string; local: boolean; uid: number | null }
|
||||
|
||||
/** A code of the authenticator, as the router accepts it. */
|
||||
/** A code of the authenticator, as the server accepts it. */
|
||||
export const CODE_PATTERN = /^\d{6}$/
|
||||
|
||||
/** A WireGuard peer of a user: the public key of the device and its IPs, IPv4 addresses and networks. */
|
||||
export type WireGuardPeer = { public_key: string; ips: string[] }
|
||||
|
||||
/** GET /users: the users, and the router's WireGuard endpoint, whose network the peers take their addresses from. */
|
||||
/** GET /users: the users, and the server's WireGuard endpoint, whose network the peers take their addresses from. */
|
||||
export type Users = { users: User[]; wireguard: { enabled: boolean; address: string } }
|
||||
|
||||
/** A user of the router's directory, as /users lists it; a person attribute the user was added without is null. */
|
||||
/** A user of the server's directory, as /users lists it; a person attribute the user was added without is null. */
|
||||
export type User = {
|
||||
name: string
|
||||
enabled: boolean
|
||||
@@ -149,10 +149,10 @@ export type User = {
|
||||
manager_only: boolean
|
||||
/** A service account, a Manager-only account that cannot sign in to the Manager, which another system signs in with to use a router service. */
|
||||
service: boolean
|
||||
/** An internal service account, one the router creates and manages for its own services. */
|
||||
/** An internal service account, one the server creates and manages for its own services. */
|
||||
internal: boolean
|
||||
otp: boolean
|
||||
/** The console login of a member of admins, null when it was never set; only root on the router changes it. */
|
||||
/** The console login of a member of admins, null when it was never set; only root on the server changes it. */
|
||||
console: Console | null
|
||||
/** The WireGuard peers of a VPN user, each a device with its public key and its IPs; empty for any other user. */
|
||||
wireguard_peers: WireGuardPeer[]
|
||||
@@ -188,7 +188,7 @@ export type Role = {
|
||||
accounts: string[]
|
||||
}
|
||||
|
||||
/** GET /logs: the units whose journal and the files whose last lines the router shows, and the most lines of one read. */
|
||||
/** GET /logs: the units whose journal and the files whose last lines the server shows, and the most lines of one read. */
|
||||
export type Logs = { units: string[]; files: string[]; max_lines: number }
|
||||
|
||||
/** GET /service-accounts: the service accounts and the OpenID Provider, whose issuer is null while it is disabled. */
|
||||
@@ -220,7 +220,7 @@ export type Person = {
|
||||
email: string
|
||||
}
|
||||
|
||||
/** A group of the router's directory, as /groups lists it; description is '' when it has none. */
|
||||
/** A group of the server's directory, as /groups lists it; description is '' when it has none. */
|
||||
export type Group = {
|
||||
name: string
|
||||
description: string
|
||||
@@ -235,7 +235,7 @@ export const CONNECTION_AUTH = ['psk', 'certificate'] as const
|
||||
|
||||
/**
|
||||
* The settings of a site-to-site connection that POST and PUT /site-to-site take, but the key; remote_ca is the PEM
|
||||
* certificate of the CA of the peer's certificate, '' for the router's site-to-site CA.
|
||||
* certificate of the CA of the peer's certificate, '' for the server's site-to-site CA.
|
||||
*/
|
||||
export type SiteToSiteSettings = {
|
||||
addrs: string[]
|
||||
@@ -259,10 +259,10 @@ export type SiteToSiteConnection = SiteToSiteSettings & {
|
||||
established: boolean | null
|
||||
}
|
||||
|
||||
/** How often the router makes backups, from the most to the least often. */
|
||||
/** How often the server makes backups, from the most to the least often. */
|
||||
export const BACKUP_SCHEDULES = ['hourly', 'daily', 'weekly'] as const
|
||||
|
||||
/** Where backups go: an archive in a folder of the router, or a Proxmox Backup Server. */
|
||||
/** Where backups go: an archive in a folder of the server, or a Proxmox Backup Server. */
|
||||
export const BACKUP_TARGETS = ['local', 'pbs'] as const
|
||||
|
||||
/** How rclone follows the folder in the cloud: sync mirrors it, copy deletes nothing. */
|
||||
@@ -272,7 +272,7 @@ export const RCLONE_MODES = ['sync', 'copy'] as const
|
||||
export const BACKUP_KEEPS = ['keep_hourly', 'keep_daily', 'keep_weekly', 'keep_monthly', 'keep_yearly'] as const
|
||||
export type BackupKeep = (typeof BACKUP_KEEPS)[number]
|
||||
|
||||
/** The settings of the router's backup section that PUT /backup takes, but the token secret. */
|
||||
/** The settings of the server's backup section that PUT /backup takes, but the token secret. */
|
||||
export type BackupSettings = {
|
||||
enabled: boolean
|
||||
schedule: string
|
||||
@@ -288,7 +288,7 @@ export type BackupSettings = {
|
||||
} & Record<BackupKeep, number>
|
||||
|
||||
/**
|
||||
* The last backup of the router: result is running, ok, warning (made, but the cloud copy failed), failed or
|
||||
* The last backup of the server: result is running, ok, warning (made, but the cloud copy failed), failed or
|
||||
* interrupted; archive is the local archive and snapshot the PBS snapshot, size in bytes, removed the archives retention
|
||||
* deleted, and cloud the copy with rclone, null without one.
|
||||
*/
|
||||
@@ -328,7 +328,7 @@ export const PKI_PUBLISH = ['http', 'http-80', 'https', 'https-default'] as cons
|
||||
/** The key usages a template may give. */
|
||||
export const KEY_USAGES = ['digital_signature', 'content_commitment', 'key_encipherment', 'data_encipherment', 'key_agreement'] as const
|
||||
|
||||
/** The name of a custom extended key usage, and an OID in dotted form, as the router accepts them. */
|
||||
/** The name of a custom extended key usage, and an OID in dotted form, as the server accepts them. */
|
||||
export const EKU_NAME_PATTERN = /^[a-z][a-z0-9_-]{0,30}$/
|
||||
export const OID_PATTERN = /^[0-2](\.(0|[1-9][0-9]*)){1,63}$/
|
||||
|
||||
@@ -341,7 +341,7 @@ export const SAN_TYPES = ['dns', 'ip', 'email'] as const
|
||||
/** The reasons a certificate is revoked for. */
|
||||
export const REVOKE_REASONS = ['unspecified', 'key_compromise', 'affiliation_changed', 'superseded', 'cessation_of_operation', 'privilege_withdrawn'] as const
|
||||
|
||||
/** The built-in templates, which cannot be removed, and those only the router issues. */
|
||||
/** The built-in templates, which cannot be removed, and those only the server issues. */
|
||||
export const BUILTIN_TEMPLATES = ['vpn-server', 'vpn-user', 'site-to-site', 'server', 'client'] as const
|
||||
export const ROUTER_TEMPLATES = ['vpn-server', 'vpn-user'] as const
|
||||
|
||||
@@ -359,7 +359,7 @@ export type PkiTemplate = {
|
||||
/** A general-purpose issuing CA of pki.issuing_cas: its common name, the templates it issues, and its ACME server. */
|
||||
export type PkiIssuingCa = { name: string; templates: string[]; acme: boolean }
|
||||
|
||||
/** The router's pki section, as PUT /ca takes it; issuing_cas and templates hold the options as the configuration gives them. */
|
||||
/** The server's pki section, as PUT /ca takes it; issuing_cas and templates hold the options as the configuration gives them. */
|
||||
export type PkiSettings = {
|
||||
root_name: string
|
||||
root_days: number
|
||||
@@ -375,7 +375,7 @@ export type PkiSettings = {
|
||||
extended_key_usages: Record<string, string>
|
||||
}
|
||||
|
||||
/** The root CA: whether its key is on the router, and where its CRL came from, signed by the router or uploaded. */
|
||||
/** The root CA: whether its key is on the server, and where its CRL came from, signed by the server or uploaded. */
|
||||
export type PkiRoot = {
|
||||
subject: string
|
||||
expires: string
|
||||
@@ -399,7 +399,7 @@ export type PkiAuthority = {
|
||||
acme_url: string | null
|
||||
}
|
||||
|
||||
/** A certificate the router issued: kind is ca, router, user or external, state valid, expired or revoked. */
|
||||
/** A certificate the server issued: kind is ca, router, user or external, state valid, expired or revoked. */
|
||||
export type PkiCertificate = {
|
||||
serial: string
|
||||
ca: string
|
||||
@@ -432,7 +432,7 @@ export type Pki = {
|
||||
certificates: PkiCertificate[]
|
||||
}
|
||||
|
||||
/** The views of the Metrics tab, as /metrics/history of the router takes them in range. */
|
||||
/** The views of the Metrics tab, as /metrics/history of the server takes them in range. */
|
||||
export const METRICS_RANGES = ['hour', 'day', 'month', 'year'] as const
|
||||
export type MetricsRange = (typeof METRICS_RANGES)[number]
|
||||
|
||||
@@ -440,7 +440,7 @@ export type MetricsRange = (typeof METRICS_RANGES)[number]
|
||||
export const METRICS_KEEPS = ['keep_details', 'keep_hourly', 'keep_daily', 'keep_monthly', 'keep_yearly'] as const
|
||||
export type MetricsKeep = (typeof METRICS_KEEPS)[number]
|
||||
|
||||
/** The settings of the router's metrics section that PUT /metrics/settings takes, but the OTLP password. */
|
||||
/** The settings of the server's metrics section that PUT /metrics/settings takes, but the OTLP password. */
|
||||
export type MetricsSettings = {
|
||||
enabled: boolean
|
||||
listen: Listen
|
||||
@@ -451,7 +451,7 @@ export type MetricsSettings = {
|
||||
otlp_username: string
|
||||
} & Record<MetricsKeep, string>
|
||||
|
||||
/** The router's https section as GET /https/settings answers it; PUT /https/settings takes acme_staging. */
|
||||
/** The server's https section as GET /https/settings answers it; PUT /https/settings takes acme_staging. */
|
||||
export type HttpsSettings = {
|
||||
enabled: boolean
|
||||
email: string
|
||||
@@ -464,12 +464,12 @@ export type HttpsSettings = {
|
||||
/** The average and the maximum of a value over a bucket; null without data. */
|
||||
export type Aggregate = { avg: number | null; max: number | null }
|
||||
|
||||
/** The values of the router's metrics_system table: CPU in percent, memory and disk in bytes, and the load averages. */
|
||||
/** The values of the server's metrics_system table: CPU in percent, memory and disk in bytes, and the load averages. */
|
||||
export const SYSTEM_VALUES = ['cpu', 'memory_used', 'memory_total', 'disk_free', 'disk_total', 'load1', 'load5', 'load15'] as const
|
||||
export type SystemValue = (typeof SYSTEM_VALUES)[number]
|
||||
|
||||
/**
|
||||
* The values of the router's metrics_site_to_site table: up, 1 or 0, so its average is the part of the bucket the
|
||||
* The values of the server's metrics_site_to_site table: up, 1 or 0, so its average is the part of the bucket the
|
||||
* connection was up; bytes (rx, tx) and packets (packets_rx, packets_tx) per second received and sent; and the seconds
|
||||
* its IKE SA has been up.
|
||||
*/
|
||||
@@ -508,7 +508,7 @@ export const SITE_TLS_LABELS: Record<SiteTls, string> = {
|
||||
export type Listen = 'internal' | 'external' | 'both'
|
||||
export const LISTEN_CHOICES: Listen[] = ['internal', 'external', 'both']
|
||||
|
||||
/** A web site of the router's /sites, without its private key. */
|
||||
/** A web site of the server's /sites, without its private key. */
|
||||
export type Site = {
|
||||
name: string
|
||||
enabled: boolean
|
||||
@@ -529,8 +529,8 @@ export type Site = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Who serves the records of a site's host names: user, a DNS provider outside the router, or router, the router's name
|
||||
* server, with the router's address of dns_address.
|
||||
* Who serves the records of a site's host names: user, a DNS provider outside the server, or router, the server's name
|
||||
* server, with the server's address of dns_address.
|
||||
*/
|
||||
export type SiteDns = 'user' | 'router'
|
||||
export const SITE_DNS_LABELS: Record<SiteDns, string> = { user: 'User managed', router: 'Router managed' }
|
||||
@@ -541,7 +541,7 @@ export const SITE_DNS_ADDRESS_LABELS: Record<SiteDnsAddress, string> = {
|
||||
external: 'External interface IP',
|
||||
}
|
||||
|
||||
/** The router's sites section: whether sites are served, the largest upload in MiB, and WebDAV and its port. */
|
||||
/** The server's sites section: whether sites are served, the largest upload in MiB, and WebDAV and its port. */
|
||||
export type SitesSettings = { enabled: boolean; upload_max_mb: number; webdav: boolean; webdav_port: number }
|
||||
|
||||
/** GET /sites. */
|
||||
@@ -551,16 +551,16 @@ export type Sites = { settings: SitesSettings; sites: Site[] }
|
||||
export type SiteEntry = { name: string; folder: boolean; size: number; modified: string }
|
||||
export type SiteFolder = { path: string; entries: SiteEntry[] }
|
||||
|
||||
/** A DNS name without a wildcard, in lowercase, as the router takes dns.secondary and a domain. */
|
||||
/** A DNS name without a wildcard, in lowercase, as the server takes dns.secondary and a domain. */
|
||||
export const ZONE_PATTERN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+$/
|
||||
|
||||
/** An IPv4 or IPv6 address, roughly; the router checks it. */
|
||||
/** An IPv4 or IPv6 address, roughly; the server checks it. */
|
||||
export const ADDRESS_PATTERN = /^(\d{1,3}\.){3}\d{1,3}$|^[0-9a-f:]+:[0-9a-f:]*$/
|
||||
|
||||
/** The types of the records an administrator adds to a domain. */
|
||||
export const DNS_TYPES = ['A', 'AAAA', 'CNAME', 'TXT', 'MX', 'SRV', 'CAA']
|
||||
|
||||
/** The router's dns section: secondary is the secondary name server of every domain, which may transfer them. */
|
||||
/** The server's dns section: secondary is the secondary name server of every domain, which may transfer them. */
|
||||
export type DnsSettings = { enabled: boolean; secondary: string; listen: Listen; ttl: number }
|
||||
|
||||
/** A record of a domain. */
|
||||
@@ -575,8 +575,8 @@ export type DnsDomain = {
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /dns: the settings, nameserver, the router's FQDN, the primary name server of every domain, public_address, the
|
||||
* router's public IP of the records of sites with dns_address public, whether PowerDNS is installed and runs, the
|
||||
* GET /dns: the settings, nameserver, the server's FQDN, the primary name server of every domain, public_address, the
|
||||
* server's public IP of the records of sites with dns_address public, whether PowerDNS is installed and runs, the
|
||||
* domains, and why they cannot be read.
|
||||
*/
|
||||
export type Dns = {
|
||||
@@ -589,7 +589,7 @@ export type Dns = {
|
||||
problem: string | null
|
||||
}
|
||||
|
||||
/** A check of a value read from the router. */
|
||||
/** A check of a value read from the server. */
|
||||
export type Check = (value: unknown) => boolean
|
||||
|
||||
const string: Check = (value) => typeof value === 'string'
|
||||
@@ -755,7 +755,7 @@ export const GROUP_SHAPE = GROUP
|
||||
|
||||
export const USERS_SHAPE = object({ users: list(USER), wireguard: object({ enabled: boolean, address: string }) })
|
||||
|
||||
/** The shapes of GET /logs, the units and files whose logs the router shows and the most lines of one read, and of a read. */
|
||||
/** The shapes of GET /logs, the units and files whose logs the server shows and the most lines of one read, and of a read. */
|
||||
export const LOGS_SHAPE = object({ units: list(string), files: list(string), max_lines: number })
|
||||
export const LOG_LINES_SHAPE = object({ lines: list(string) })
|
||||
|
||||
@@ -945,13 +945,13 @@ export const REVOKED_SHAPE: Check = (value) => PKI_CERTIFICATE(value) && object(
|
||||
export const CA_IMPORTED_SHAPE = object({ name: string, subject: string, expires: string })
|
||||
export const CRL_IMPORTED_SHAPE = object({ next_update: nullable(string) })
|
||||
|
||||
/** The remote access systems of the router: IKEv2 (p2s), OpenVPN and WireGuard. */
|
||||
/** The remote access systems of the server: IKEv2 (p2s), OpenVPN and WireGuard. */
|
||||
export const REMOTE_ACCESS_SYSTEMS = ['p2s', 'openvpn', 'wireguard'] as const
|
||||
export type RemoteAccessSystem = (typeof REMOTE_ACCESS_SYSTEMS)[number]
|
||||
export const REMOTE_ACCESS_LABELS: Record<RemoteAccessSystem, string> = { p2s: 'IKEv2', openvpn: 'OpenVPN', wireguard: 'WireGuard' }
|
||||
export const OPENVPN_PROTOCOLS = ['udp', 'tcp'] as const
|
||||
|
||||
/** The settings of each remote access system, as the router's sections hold them. */
|
||||
/** The settings of each remote access system, as the server's sections hold them. */
|
||||
export type P2sSettings = { enabled: boolean; address_pool: string; dns_domains: string[] }
|
||||
export type OpenvpnSettings = { enabled: boolean; address_pool: string; port: number; protocol: string }
|
||||
export type WireguardSettings = { enabled: boolean; address: string; listen_port: number }
|
||||
@@ -967,7 +967,7 @@ export type RemoteAccess = {
|
||||
}
|
||||
|
||||
/**
|
||||
* What a WireGuard peer's configuration needs of the router: its public key, null before setup made it, its endpoint,
|
||||
* What a WireGuard peer's configuration needs of the server: its public key, null before setup made it, its endpoint,
|
||||
* null without wan.local_fqdn, and the networks reached through the tunnel.
|
||||
*/
|
||||
export type WireGuardServer = { public_key: string | null; endpoint: string | null; allowed_ips: string[]; dns: string[] }
|
||||
@@ -988,11 +988,11 @@ export const REMOTE_ACCESS_SECTION_SHAPES: Record<RemoteAccessSystem, Check> = {
|
||||
wireguard: WIREGUARD_SETTINGS,
|
||||
}
|
||||
|
||||
/** A ticket of the router's POST /shell, which opens one shell within expires_in seconds. */
|
||||
/** A ticket of the server's POST /shell, which opens one shell within expires_in seconds. */
|
||||
export type ShellTicket = { ticket: string | null; expires_in: number }
|
||||
export const SHELL_TICKET_SHAPE = object({ ticket: nullable(string), expires_in: number })
|
||||
|
||||
/** A file a shell opened in its editor with vre, as the router names it in a text message of the shell's WebSocket. */
|
||||
/** A file a shell opened in its editor with lme, as the server names it in a text message of the shell's WebSocket. */
|
||||
export type EditorFile = { session: string; id: string; path: string }
|
||||
|
||||
/** GET /shell/editor/<session>/<id>: the file's content and version, the SHA-256 of the content. */
|
||||
@@ -1070,7 +1070,7 @@ export const METRICS_SHAPE = object({
|
||||
/** The event raised on window when a call is answered 401: the session has ended. */
|
||||
export const SESSION_EXPIRED = 'session-expired'
|
||||
|
||||
/** A failed call, with the message of the manager or the router and the HTTP status. */
|
||||
/** A failed call, with the message of the manager or the server and the HTTP status. */
|
||||
export class ApiError extends Error {
|
||||
status: number
|
||||
|
||||
@@ -1082,7 +1082,7 @@ export class ApiError extends Error {
|
||||
|
||||
/**
|
||||
* Calls the manager's API and returns the decoded JSON when it is of the shape; a failed call or an answer of another
|
||||
* shape throws ApiError with the message of the manager or the router. A 401 to any path but /session raises
|
||||
* shape throws ApiError with the message of the manager or the server. A 401 to any path but /session raises
|
||||
* SESSION_EXPIRED.
|
||||
*/
|
||||
export async function request<T>(method: string, path: string, shape: Check, body?: unknown): Promise<T> {
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import type { Person } from './api.ts'
|
||||
|
||||
/** The e-mail addresses vpn-router-user accepts: one @, no spaces, and a dot in the domain. */
|
||||
/** The e-mail addresses linux-manager-user accepts: one @, no spaces, and a dot in the domain. */
|
||||
const EMAIL_PATTERN = /^[^@\s]+@[^@\s]+\.[^@\s]+$/
|
||||
|
||||
/** The longest first or last name vpn-router-user accepts. */
|
||||
/** The longest first or last name linux-manager-user accepts. */
|
||||
const PERSON_NAME_MAX = 64
|
||||
|
||||
/** The problem of each person field, or '' while it is empty or good. */
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@ import { useSyncExternalStore } from 'react'
|
||||
export type BrowserSettings = { routerRefresh: number; metricsRefresh: number; wireguardPrefilled: boolean }
|
||||
|
||||
/** The localStorage key of the settings. */
|
||||
const KEY = 'vpn-router-manager.settings'
|
||||
const KEY = 'linux-manager-ui.settings'
|
||||
|
||||
/** The event raised on window when the settings change in this tab. */
|
||||
const CHANGED = 'vpn-router-manager-settings'
|
||||
const CHANGED = 'linux-manager-ui-settings'
|
||||
|
||||
export const DEFAULT_SETTINGS: BrowserSettings = { routerRefresh: 10, metricsRefresh: 60, wireguardPrefilled: false }
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { WireGuardServer } from './api.ts'
|
||||
|
||||
/**
|
||||
* The WireGuard configuration of a device: its address, a placeholder for its private key, which the router never has,
|
||||
* the router's resolver as its DNS server while it runs, and the router as its peer, with the router's public key,
|
||||
* The WireGuard configuration of a device: its address, a placeholder for its private key, which the server never has,
|
||||
* the server's resolver as its DNS server while it runs, and the server as its peer, with the server's public key,
|
||||
* endpoint and allowed IPs.
|
||||
*/
|
||||
export function clientConfig(server: WireGuardServer, address: string): string {
|
||||
@@ -49,8 +49,8 @@ function networkOf(text: string, strict: boolean): { first: number; size: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Why the router's own WireGuard address with its prefix, wireguard.address, is refused, or '' when it is an address of
|
||||
* its network other than the network's and the broadcast address, as the router requires.
|
||||
* Why the server's own WireGuard address with its prefix, wireguard.address, is refused, or '' when it is an address of
|
||||
* its network other than the network's and the broadcast address, as the server requires.
|
||||
*/
|
||||
export function routerAddressProblem(text: string): string {
|
||||
const network = networkOf(text, false)
|
||||
@@ -59,7 +59,7 @@ export function routerAddressProblem(text: string): string {
|
||||
return 'An IPv4 address with a prefix length, such as 192.168.200.1/24.'
|
||||
}
|
||||
if (network.size > 2 && (own === network.first || own === network.first + network.size - 1)) {
|
||||
return `The network or broadcast address of its network; give the router's own address in it, such as ${textOf(network.first + 1)}/${32 - Math.log2(network.size)}.`
|
||||
return `The network or broadcast address of its network; give the server's own address in it, such as ${textOf(network.first + 1)}/${32 - Math.log2(network.size)}.`
|
||||
}
|
||||
return ''
|
||||
}
|
||||
@@ -85,8 +85,8 @@ export function ipsOf(text: string): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* The first address of the network of the router's address (wireguard.address, such as 192.168.200.1/24) that is
|
||||
* neither the router's own nor covered by one of the taken IPs, as a.b.c.d/32; '' when there is none.
|
||||
* The first address of the network of the server's address (wireguard.address, such as 192.168.200.1/24) that is
|
||||
* neither the server's own nor covered by one of the taken IPs, as a.b.c.d/32; '' when there is none.
|
||||
*/
|
||||
export function nextFreeAddress(routerAddress: string, taken: string[]): string {
|
||||
const router = networkOf(routerAddress, false)
|
||||
|
||||
Reference in new issue
Block a user