25 lines
1.3 KiB
TypeScript
25 lines
1.3 KiB
TypeScript
import type { RecordValue } from './api';
|
||
|
||
export function OPNsenseDetails({ device }: { device: RecordValue }) {
|
||
if (device.source_id !== 'opnsense.base') return null;
|
||
const inventory = device.inventory as RecordValue | null;
|
||
function list(key: string, title: string) {
|
||
const report = inventory?.[key] as RecordValue | undefined;
|
||
const available = report?.status === 'ok' || report?.status === 'partial';
|
||
const rows = Array.isArray(report?.entries) ? report.entries.filter((x): x is string => typeof x === 'string') : [];
|
||
return <div key={key}><h3>{title}</h3>{!available ? <p>Nicht ermittelbar</p> : <>
|
||
{report?.status === 'partial' && <p>Auszug – unvollständige Liste</p>}
|
||
{rows.length ? <ol>{rows.map((line, i) => <li key={i}><code>{line}</code></li>)}</ol> : <p>Keine Einträge gemeldet.</p>}
|
||
</>}</div>;
|
||
}
|
||
return <>
|
||
<section><h2>VPN-Verbindungen</h2>
|
||
{list('vpn_configured', 'Konfigurierte VPNs')}
|
||
{list('wireguard', 'WireGuard · letzter Handshake je Peer')}
|
||
{list('openvpn', 'OpenVPN · Laufzeitstatus')}
|
||
{list('ipsec', 'IPsec · aktive Sicherheitsassoziationen')}
|
||
</section>
|
||
<section><h2>Firewallregeln</h2>{list('firewall', 'Aktive PF-Filterregeln · Hauptregelsatz in Auswertungsreihenfolge')}</section>
|
||
</>;
|
||
}
|