feature: the VPN, the router, the name server and WebDAV are components switched on the System tab and installed on demand, Caddy from the Ubuntu archive is a dependency and serves every HTTP and HTTPS port, HTTPS is chosen at install, its certificate is of the Servers Issuing CA or self-signed by default, of ACME or of another CA, the issuing CAs are in one tab, a locked account is unlocked again, the name of a CA is fixed once the CA exists, and a run of setup is no longer cut short by a change.
Release / release (push) Failing after 8s

This commit is contained in:
slawek committed 2026-11-24 05:51:27 +01:00
1 parent a649331aa2
commit a7bfabcb89
97 files changed
+4498 -1834

No files matched your search

+92 -64
View File
@@ -3,16 +3,24 @@ import Edit from '@mui/icons-material/Edit'
import Refresh from '@mui/icons-material/Refresh'
import { Alert, Box, Button, Chip, Stack } from '@mui/material'
import { useCallback, useEffect, useState } from 'react'
import { Board, BoardButtons, useBoard, type BoardPanel } from './PanelBoard.tsx'
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 './ServerPanel.tsx'
import { Copyable, Grid, IPSEC_HEADS, Pairs, 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,
} from './api.ts'
/** The localStorage key of each system's layout. */
const LAYOUT_KEYS: Record<RemoteAccessSystem, string> = {
p2s: 'linux-manager-ui.remote-access-p2s-layout',
openvpn: 'linux-manager-ui.remote-access-openvpn-layout',
wireguard: 'linux-manager-ui.remote-access-wireguard-layout',
}
/** What each system describes, above its panels. */
const DESCRIPTIONS: Record<RemoteAccessSystem, string> = {
p2s: 'IKEv2 remote access.',
@@ -26,7 +34,8 @@ const DESCRIPTIONS: Record<RemoteAccessSystem, string> = {
* 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 server applies a
* change in the background; Refresh reads the state again.
* change in the background; Refresh reads the state again. The panels are on a PanelBoard whose layout
* is kept in the browser.
*/
export default function RemoteAccessPanel(props: { system: RemoteAccessSystem }) {
const [access, setAccess] = useState<RemoteAccess | null>(null)
@@ -35,6 +44,7 @@ export default function RemoteAccessPanel(props: { system: RemoteAccessSystem })
const [busy, setBusy] = useState(false)
const [editing, setEditing] = useState(false)
const [showConfig, setShowConfig] = useState(false)
const board = useBoard(LAYOUT_KEYS[props.system])
// 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)
@@ -91,10 +101,89 @@ export default function RemoteAccessPanel(props: { system: RemoteAccessSystem })
// 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)
const panels: BoardPanel[] = access ? [
{ id: 'settings', title: 'Settings', content: <Pairs rows={rows} /> },
{
id: 'state',
title: 'State',
content: (
<Pairs
rows={[
['Running', <Chip key="running" size="small" label={running ? 'running' : 'not running'} color={running ? 'success' : 'default'} />],
...(system === 'wireguard'
? [['Peers', peers === undefined || peers === null ? '-' : String(peers.length)] as [string, string]]
: [['Connected clients', clients === undefined || clients === null ? '-' : String(clients)] as [string, string]]),
]}
/>
),
},
...(shown(ipsec.sas) ? [{ id: 'ipsec-sas', title: 'IPsec security associations', wide: true, content: <Grid head={IPSEC_HEADS.sas} rows={ipsec.sas} /> }] : []),
...(shown(ipsec.childSas) ? [{ id: 'ipsec-child-sas', title: 'IPsec child SAs', wide: true, content: <Grid head={IPSEC_HEADS.childSas} rows={ipsec.childSas} /> }] : []),
...(shown(ipsec.connections) ? [{ id: 'ipsec-connections', title: 'IPsec connections', wide: true, content: <Grid head={IPSEC_HEADS.connections} rows={ipsec.connections} /> }] : []),
...(shown(ipsec.children) ? [{ id: 'ipsec-children', title: 'IPsec connection children', wide: true, content: <Grid head={IPSEC_HEADS.children} rows={ipsec.children} /> }] : []),
...(system === 'wireguard' ? [{
id: 'server',
title: 'Server',
wide: true,
content: (
<>
<Pairs
rows={[
['Public key', access.wireguard_server.public_key === null ? 'not made yet; setup makes it once WireGuard is enabled'
: <Copyable key="key" value={access.wireguard_server.public_key} label="public key" />],
['Endpoint', access.wireguard_server.endpoint ?? 'unknown: wan.local_fqdn is not set'],
['Allowed IPs', text(access.wireguard_server.allowed_ips)],
]}
/>
<Stack direction="row" sx={{ mt: 1, justifyContent: 'flex-end' }}>
<Button
size="small"
variant="outlined"
startIcon={<Description />}
disabled={!access.wireguard_server.public_key || !access.wireguard_server.endpoint}
onClick={() => setShowConfig(true)}
>
Show config
</Button>
</Stack>
</>
),
}] : []),
...(system === 'wireguard' ? [{
id: 'peers',
title: 'Peers',
wide: true,
content: <WireGuardPeers server={access.wireguard_server} users={users} onChanged={() => void refresh()} />,
}] : []),
...(system === 'wireguard' && running ? [{
id: 'connections',
title: 'Connections',
wide: true,
content: (
<Grid
head={['User', 'IPs', 'Endpoint', 'Handshake', 'Received', 'Sent']}
rows={details?.wireguard?.peers.map((peer) => {
// A peer is a user's by its key; one added to wg0.conf by hand has no user.
const owner = users?.users.find((user) => user.wireguard_peers.some((own) => own.public_key === peer.public_key))
return [
owner?.name ?? `- (${peer.public_key.slice(0, 8)}...)`,
peer.allowed_ips.join(', '),
peer.endpoint ?? '-',
peer.handshake_seconds_ago === null ? 'none' : `${peer.handshake_seconds_ago} s ago`,
bytes(peer.received_bytes),
bytes(peer.sent_bytes),
]
}) ?? undefined}
/>
),
}] : []),
] : []
return (
<Box component="section">
<Toolbar description={DESCRIPTIONS[system]}>
<Button variant="outlined" startIcon={<Edit />} disabled={!access || busy} onClick={() => setEditing(true)}>Edit</Button>
<BoardButtons board={board} />
<Button variant="outlined" startIcon={<Refresh />} disabled={busy} onClick={() => void refresh()}>Refresh</Button>
</Toolbar>
{error && <Alert severity="error" sx={{ mb: 2, whiteSpace: 'pre-line' }}>{error}</Alert>}
@@ -105,68 +194,7 @@ export default function RemoteAccessPanel(props: { system: RemoteAccessSystem })
: `${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 && (
<Box sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', md: '1fr 1fr' } }}>
<Section title="Settings"><Pairs rows={rows} /></Section>
<Section title="State">
<Pairs
rows={[
['Running', <Chip key="running" size="small" label={running ? 'running' : 'not running'} color={running ? 'success' : 'default'} />],
...(system === 'wireguard'
? [['Peers', peers === undefined || peers === null ? '-' : String(peers.length)] as [string, string]]
: [['Connected clients', clients === undefined || clients === null ? '-' : String(clients)] as [string, string]]),
]}
/>
</Section>
{shown(ipsec.sas) && <Section title="IPsec security associations" wide><Grid head={IPSEC_HEADS.sas} rows={ipsec.sas} /></Section>}
{shown(ipsec.childSas) && <Section title="IPsec child SAs" wide><Grid head={IPSEC_HEADS.childSas} rows={ipsec.childSas} /></Section>}
{shown(ipsec.connections) && <Section title="IPsec connections" wide><Grid head={IPSEC_HEADS.connections} rows={ipsec.connections} /></Section>}
{shown(ipsec.children) && <Section title="IPsec connection children" wide><Grid head={IPSEC_HEADS.children} rows={ipsec.children} /></Section>}
{system === 'wireguard' && (
<Section title="Server" wide>
<Pairs
rows={[
['Public key', access.wireguard_server.public_key === null ? 'not made yet; setup makes it once WireGuard is enabled'
: <Copyable key="key" value={access.wireguard_server.public_key} label="public key" />],
['Endpoint', access.wireguard_server.endpoint ?? 'unknown: wan.local_fqdn is not set'],
['Allowed IPs', text(access.wireguard_server.allowed_ips)],
]}
/>
<Stack direction="row" sx={{ mt: 1, justifyContent: 'flex-end' }}>
<Button
size="small"
variant="outlined"
startIcon={<Description />}
disabled={!access.wireguard_server.public_key || !access.wireguard_server.endpoint}
onClick={() => setShowConfig(true)}
>
Show config
</Button>
</Stack>
</Section>
)}
{system === 'wireguard' && <WireGuardPeers server={access.wireguard_server} users={users} onChanged={() => void refresh()} />}
{system === 'wireguard' && running && (
<Section title="Connections" wide>
<Grid
head={['User', 'IPs', 'Endpoint', 'Handshake', 'Received', 'Sent']}
rows={details?.wireguard?.peers.map((peer) => {
// A peer is a user's by its key; one added to wg0.conf by hand has no user.
const owner = users?.users.find((user) => user.wireguard_peers.some((own) => own.public_key === peer.public_key))
return [
owner?.name ?? `- (${peer.public_key.slice(0, 8)}...)`,
peer.allowed_ips.join(', '),
peer.endpoint ?? '-',
peer.handshake_seconds_ago === null ? 'none' : `${peer.handshake_seconds_ago} s ago`,
bytes(peer.received_bytes),
bytes(peer.sent_bytes),
]
}) ?? undefined}
/>
</Section>
)}
</Box>
)}
{access && <Board board={board} panels={panels} />}
{showConfig && access && (
<WireGuardConfigDialog title="WireGuard configuration of a device" server={access.wireguard_server} ips={null} onClose={() => setShowConfig(false)} />
)}