chore(plugins): sync pre-bundled builtin frontends (crowdsec, dns-server, wordpress)

Regenerated via scripts/sync-builtin-frontends.mjs; fixes the Extensions CI
drift check that failed after plan 15 added these extensions without
re-running the sync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Juan DenisandClaude Fable 5 committed 2026-07-03 22:18:50 -04:00
1 parent 5e22aa8510
commit b35a41bfcc
12 files changed
+1859 -1

No files matched your search

@@ -0,0 +1,566 @@
import { useCallback, useEffect, useState } from 'react';
import { ShieldCheck, RefreshCw, Ban, ListChecks, Activity, Plus } from 'lucide-react';
import api from '@/services/api';
import { PageTopbar, Pill, MetricCard } from '@/components/ds';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';
import Modal from '@/components/Modal';
import ConfirmDialog from '@/components/ConfirmDialog';
import EmptyState from '@/components/EmptyState';
import { useToast } from '@/contexts/ToastContext';
const DURATIONS = ['1h', '4h', '12h', '24h', '7d'];
const formatDate = (d) => (d ? new Date(d).toLocaleString() : '—');
// Best-effort: pull a headline number out of `cscli metrics -o json`, whose
// shape varies across CrowdSec versions. Null when nothing recognizable.
function parsedEventsTotal(metrics) {
try {
const acq = metrics?.acquisition;
if (!acq || typeof acq !== 'object') return null;
let total = 0;
for (const source of Object.values(acq)) {
const n = source?.parsed ?? source?.lines_parsed;
if (typeof n === 'number') total += n;
}
return total > 0 ? total : null;
} catch {
return null;
}
}
const CrowdSecPage = () => {
const toast = useToast();
const [status, setStatus] = useState(null);
const [decisions, setDecisions] = useState([]);
const [alerts, setAlerts] = useState([]);
const [allowlists, setAllowlists] = useState({ supported: false, allowlists: [], message: null });
const [metrics, setMetrics] = useState(null);
const [loading, setLoading] = useState(true);
const [actionLoading, setActionLoading] = useState(false);
const [confirmDialog, setConfirmDialog] = useState(null);
// Ban modal
const [showBanModal, setShowBanModal] = useState(false);
const [banForm, setBanForm] = useState({ ip: '', duration: '4h', reason: '' });
// Allowlist manager
const [showListModal, setShowListModal] = useState(false);
const [listForm, setListForm] = useState({ name: '', description: '' });
const [selectedList, setSelectedList] = useState(null);
const [listItems, setListItems] = useState([]);
const [entryForm, setEntryForm] = useState({ value: '', comment: '' });
const loadData = useCallback(async () => {
setLoading(true);
try {
const statusData = await api.request('/crowdsec/status');
setStatus(statusData);
if (statusData?.installed) {
const [d, a, al, m] = await Promise.all([
api.request('/crowdsec/decisions').catch(() => ({ decisions: [] })),
api.request('/crowdsec/alerts').catch(() => ({ alerts: [] })),
api.request('/crowdsec/allowlists').catch(() => ({ supported: false, allowlists: [] })),
api.request('/crowdsec/metrics').catch(() => null),
]);
setDecisions(d.decisions || []);
setAlerts(a.alerts || []);
setAllowlists(al || { supported: false, allowlists: [] });
setMetrics(m?.metrics ?? null);
}
} catch (error) {
toast.error(`Failed to load CrowdSec data: ${error.message}`);
} finally {
setLoading(false);
}
}, [toast]);
useEffect(() => {
loadData();
}, [loadData]);
const handleBan = async () => {
if (!banForm.ip.trim()) return;
setActionLoading(true);
try {
await api.request('/crowdsec/decisions', {
method: 'POST',
body: {
ip: banForm.ip.trim(),
duration: banForm.duration,
reason: banForm.reason.trim() || undefined,
},
});
toast.success(`Decision added for ${banForm.ip}`);
setShowBanModal(false);
setBanForm({ ip: '', duration: '4h', reason: '' });
await loadData();
} catch (error) {
toast.error(`Failed to ban IP: ${error.message}`);
} finally {
setActionLoading(false);
}
};
const handleDeleteDecision = (value) => {
setConfirmDialog({
title: 'Remove decision',
message: `Remove all active decisions for ${value}?`,
confirmText: 'Remove',
variant: 'warning',
onConfirm: async () => {
try {
await api.request(`/crowdsec/decisions/${encodeURIComponent(value)}`, { method: 'DELETE' });
toast.success(`Decisions removed for ${value}`);
await loadData();
} catch (error) {
toast.error(`Failed to remove decision: ${error.message}`);
}
setConfirmDialog(null);
},
onCancel: () => setConfirmDialog(null),
});
};
const handleCreateList = async () => {
if (!listForm.name.trim()) return;
setActionLoading(true);
try {
await api.request('/crowdsec/allowlists', {
method: 'POST',
body: { name: listForm.name.trim(), description: listForm.description.trim() },
});
toast.success(`Allowlist ${listForm.name} created`);
setShowListModal(false);
setListForm({ name: '', description: '' });
await loadData();
} catch (error) {
toast.error(`Failed to create allowlist: ${error.message}`);
} finally {
setActionLoading(false);
}
};
const openList = async (name) => {
setSelectedList(name);
setListItems([]);
try {
const res = await api.request(`/crowdsec/allowlists/${encodeURIComponent(name)}`);
setListItems(res?.allowlist?.items || []);
} catch (error) {
toast.error(`Failed to load allowlist: ${error.message}`);
}
};
const handleAddEntry = async () => {
if (!selectedList || !entryForm.value.trim()) return;
setActionLoading(true);
try {
await api.request(`/crowdsec/allowlists/${encodeURIComponent(selectedList)}/items`, {
method: 'POST',
body: { value: entryForm.value.trim(), comment: entryForm.comment.trim() || undefined },
});
toast.success(`Added ${entryForm.value} to ${selectedList}`);
setEntryForm({ value: '', comment: '' });
await openList(selectedList);
} catch (error) {
toast.error(`Failed to add entry: ${error.message}`);
} finally {
setActionLoading(false);
}
};
const handleRemoveEntry = async (value) => {
try {
await api.request(
`/crowdsec/allowlists/${encodeURIComponent(selectedList)}/items?value=${encodeURIComponent(value)}`,
{ method: 'DELETE' }
);
toast.success(`Removed ${value} from ${selectedList}`);
await openList(selectedList);
} catch (error) {
toast.error(`Failed to remove entry: ${error.message}`);
}
};
if (loading) {
return (
<div className="page-container crowdsec-page">
<PageTopbar icon={<ShieldCheck size={18} />} title="CrowdSec" />
<EmptyState loading title="Loading CrowdSec status..." />
</div>
);
}
// ── Not installed: guidance, never auto-install ──
if (!status?.installed) {
return (
<div className="page-container crowdsec-page">
<PageTopbar icon={<ShieldCheck size={18} />} title="CrowdSec" />
<div className="empty-state">
<ShieldCheck size={48} strokeWidth={1} />
<h3>CrowdSec Is Not Installed</h3>
<p>
CrowdSec is a collaborative security engine that detects attacks in your
logs and shares blocklists across its community. Install it on this host
and this page will surface its decisions, alerts, and allowlists.
</p>
<p>
ServerKit does not install it for you — follow the official guide, then
refresh this page.
</p>
<div className="cs-empty-actions">
<Button asChild variant="default">
<a href={status?.docs_url || 'https://docs.crowdsec.net/'} target="_blank" rel="noreferrer">
Installation Guide
</a>
</Button>
<Button variant="outline" onClick={loadData}>
<RefreshCw size={14} /> Re-check
</Button>
</div>
</div>
</div>
);
}
const parsedEvents = parsedEventsTotal(metrics);
return (
<div className="page-container crowdsec-page">
<PageTopbar
icon={<ShieldCheck size={18} />}
title="CrowdSec"
actions={
<>
<Button variant="default" size="sm" onClick={() => setShowBanModal(true)}>
<Ban size={14} /> Ban an IP
</Button>
<Button variant="outline" size="sm" onClick={loadData}>
<RefreshCw size={14} /> Refresh
</Button>
</>
}
/>
{/* ── Status ── */}
<div className="card">
<div className="card-header">
<h3>Engine Status</h3>
</div>
<div className="card-body">
<div className="sec-rows">
<div className="sk-info-row">
<span className="k">Service</span>
<Pill kind={status.running ? 'green' : 'red'}>
{status.running ? 'Running' : 'Stopped'}
</Pill>
</div>
<div className="sk-info-row">
<span className="k">Local API</span>
<Pill kind={status.lapi_ok ? 'green' : 'amber'}>
{status.lapi_ok ? 'Reachable' : 'Unreachable'}
</Pill>
</div>
<div className="sk-info-row">
<span className="k">Version</span>
<span className="v">{status.version || 'Unknown'}</span>
</div>
<div className="sk-info-row">
<span className="k">Allowlists</span>
<span className="v">
{status.allowlists_supported
? 'Supported'
: 'Not supported by this CrowdSec version'}
</span>
</div>
<div className="sk-info-row">
<span className="k">AppSec / WAF</span>
<span className="v">
In-line request filtering needs the CrowdSec AppSec component and a
bouncer on your reverse proxy — configured outside the panel.
</span>
</div>
</div>
</div>
</div>
{/* ── Metric cards (best-effort) ── */}
<div className="cs-kpis">
<MetricCard icon={<Ban size={15} />} tone="red" value={decisions.length} label="Active decisions" />
<MetricCard icon={<Activity size={15} />} tone="amber" value={alerts.length} label="Recent alerts" />
<MetricCard
icon={<ListChecks size={15} />}
tone="green"
value={allowlists.supported ? (allowlists.allowlists || []).length : '—'}
label="Allowlists"
/>
{parsedEvents != null && (
<MetricCard icon={<Activity size={15} />} tone="cyan" value={parsedEvents} label="Parsed log lines" />
)}
</div>
{/* ── Decisions ── */}
<div className="card sec-flush">
<div className="card-header">
<h3>Decisions {decisions.length > 0 && <span className="sec-count">· {decisions.length}</span>}</h3>
</div>
{decisions.length === 0 ? (
<div className="card-body">
<p className="text-muted">No active decisions — nothing is currently banned.</p>
</div>
) : (
<table className="sk-dtable">
<thead>
<tr>
<th>Value</th>
<th>Scope</th>
<th>Type</th>
<th>Origin</th>
<th>Reason</th>
<th>Expires</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{decisions.map((d, i) => (
<tr key={d.id ?? i}>
<td className="sk-cell-mono">{d.value}</td>
<td><span className="sk-tag">{d.scope || '—'}</span></td>
<td>{d.type || '—'}</td>
<td>{d.origin || '—'}</td>
<td>{d.reason || '—'}</td>
<td>{d.until ? formatDate(d.until) : (d.duration || '—')}</td>
<td>
<Button variant="secondary" size="sm" onClick={() => handleDeleteDecision(d.value)}>
Delete
</Button>
</td>
</tr>
))}
</tbody>
</table>
)}
</div>
{/* ── Alerts ── */}
<div className="card sec-flush">
<div className="card-header">
<h3>Alerts {alerts.length > 0 && <span className="sec-count">· {alerts.length}</span>}</h3>
</div>
{alerts.length === 0 ? (
<div className="card-body">
<p className="text-muted">No recent alerts.</p>
</div>
) : (
<table className="sk-dtable">
<thead>
<tr>
<th>Scenario</th>
<th>Source</th>
<th>Country</th>
<th>Events</th>
<th>Decisions</th>
<th>Created</th>
</tr>
</thead>
<tbody>
{alerts.map((a, i) => (
<tr key={a.id ?? i}>
<td>{a.scenario || '—'}</td>
<td className="sk-cell-mono">{a.source || '—'}</td>
<td>{a.country || '—'}</td>
<td>{a.events_count ?? '—'}</td>
<td>{a.decisions ?? '—'}</td>
<td>{formatDate(a.created_at)}</td>
</tr>
))}
</tbody>
</table>
)}
</div>
{/* ── Allowlists ── */}
<div className="card">
<div className="card-header">
<h3>Allowlists</h3>
{allowlists.supported && (
<div className="card-actions">
<Button variant="default" size="sm" onClick={() => setShowListModal(true)}>
<Plus size={14} /> New Allowlist
</Button>
</div>
)}
</div>
<div className="card-body">
{!allowlists.supported ? (
<p className="text-muted">
{allowlists.message
|| 'The installed CrowdSec version does not support centralized allowlists. Upgrade CrowdSec to manage allowlists from the panel.'}
</p>
) : (allowlists.allowlists || []).length === 0 ? (
<p className="text-muted">No allowlists yet. Create one to exempt trusted IPs from remediation.</p>
) : (
<div className="cs-allowlists">
<div className="cs-allowlists__names">
{(allowlists.allowlists || []).map((l, i) => (
<button
key={l.name ?? i}
type="button"
className={`cs-allowlists__name${selectedList === l.name ? ' is-active' : ''}`}
onClick={() => openList(l.name)}
>
<span className="sk-tag">{l.name}</span>
{l.description && <span className="text-muted"> {l.description}</span>}
</button>
))}
</div>
{selectedList && (
<div className="cs-allowlists__detail">
<h4>{selectedList}</h4>
{listItems.length === 0 ? (
<p className="text-muted">No entries in this allowlist.</p>
) : (
<table className="sk-dtable">
<thead>
<tr>
<th>Value</th>
<th>Comment</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{listItems.map((it, i) => {
const value = typeof it === 'string' ? it : it.value;
return (
<tr key={value ?? i}>
<td className="sk-cell-mono">{value}</td>
<td>{(typeof it === 'object' && (it.description || it.comment)) || '—'}</td>
<td>
<Button variant="secondary" size="sm" onClick={() => handleRemoveEntry(value)}>
Remove
</Button>
</td>
</tr>
);
})}
</tbody>
</table>
)}
<div className="cs-entry-form">
<Input
type="text"
value={entryForm.value}
onChange={(e) => setEntryForm((f) => ({ ...f, value: e.target.value }))}
placeholder="IP or CIDR, e.g. 203.0.113.7 or 10.0.0.0/8"
/>
<Input
type="text"
value={entryForm.comment}
onChange={(e) => setEntryForm((f) => ({ ...f, comment: e.target.value }))}
placeholder="Comment (optional)"
/>
<Button
variant="default"
size="sm"
onClick={handleAddEntry}
disabled={actionLoading || !entryForm.value.trim()}
>
Add Entry
</Button>
</div>
</div>
)}
</div>
)}
</div>
</div>
{/* ── Ban modal ── */}
<Modal open={showBanModal} onClose={() => setShowBanModal(false)} title="Ban an IP">
<div className="form-group">
<Label>IP address or CIDR range</Label>
<Input
type="text"
value={banForm.ip}
onChange={(e) => setBanForm((f) => ({ ...f, ip: e.target.value }))}
placeholder="203.0.113.7 or 203.0.113.0/24"
/>
</div>
<div className="form-group">
<Label>Duration</Label>
<Select value={banForm.duration} onValueChange={(v) => setBanForm((f) => ({ ...f, duration: v }))}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
{DURATIONS.map((d) => (
<SelectItem key={d} value={d}>{d}</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="form-group">
<Label>Reason</Label>
<Input
type="text"
value={banForm.reason}
onChange={(e) => setBanForm((f) => ({ ...f, reason: e.target.value }))}
placeholder="Manual ban from ServerKit"
/>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowBanModal(false)}>Cancel</Button>
<Button variant="destructive" onClick={handleBan} disabled={actionLoading || !banForm.ip.trim()}>
{actionLoading ? 'Banning...' : 'Ban IP'}
</Button>
</div>
</Modal>
{/* ── New allowlist modal ── */}
<Modal open={showListModal} onClose={() => setShowListModal(false)} title="New Allowlist">
<div className="form-group">
<Label>Name</Label>
<Input
type="text"
value={listForm.name}
onChange={(e) => setListForm((f) => ({ ...f, name: e.target.value }))}
placeholder="trusted-ips"
/>
</div>
<div className="form-group">
<Label>Description</Label>
<Input
type="text"
value={listForm.description}
onChange={(e) => setListForm((f) => ({ ...f, description: e.target.value }))}
placeholder="Office and monitoring IPs"
/>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowListModal(false)}>Cancel</Button>
<Button variant="default" onClick={handleCreateList} disabled={actionLoading || !listForm.name.trim()}>
{actionLoading ? 'Creating...' : 'Create'}
</Button>
</div>
</Modal>
{confirmDialog && (
<ConfirmDialog
title={confirmDialog.title}
message={confirmDialog.message}
confirmText={confirmDialog.confirmText}
variant={confirmDialog.variant}
onConfirm={confirmDialog.onConfirm}
onCancel={confirmDialog.onCancel}
/>
)}
</div>
);
};
export default CrowdSecPage;
@@ -0,0 +1,8 @@
// CrowdSec integration UI, contributed through the extension system. Unlike the
// re-export builtins (ftp/status/email…), this page is fully self-contained in
// the extension — no core page to wrap. After sync this folder lives at
// frontend/src/plugins/serverkit-crowdsec/, so '@/…' host aliases resolve.
export { default as CrowdSecPage } from './components/CrowdSecPage.jsx';
// No default export on purpose: PluginLoader legacy-auto-renders any plugin
// default export globally. The route contribution resolves the NAMED export.
@@ -0,0 +1,45 @@
{
"name": "serverkit-crowdsec",
"display_name": "CrowdSec",
"version": "1.0.0",
"description": "CrowdSec security engine integration — surface active decisions and alerts, ban/unban IPs, and manage allowlists straight from the panel. Read/write via cscli on the host; shows install guidance when CrowdSec is absent (never auto-installs).",
"author": "ServerKit",
"license": "MIT",
"category": "security",
"homepage": "https://github.com/jhd3197/ServerKit",
"permissions": [
"shell"
],
"min_panel_version": "1.7.0",
"entry_point": "crowdsec:crowdsec_bp",
"url_prefix": "/api/v1/crowdsec",
"icon": "<path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"/><path d=\"m9 12 2 2 4-4\"/>",
"contributions": {
"nav": [
{
"id": "crowdsec",
"label": "CrowdSec",
"route": "/crowdsec",
"category": "operations",
"icon": "<path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"/><path d=\"m9 12 2 2 4-4\"/>"
}
],
"routes": [
{
"path": "crowdsec",
"component": "CrowdSecPage"
}
],
"page_titles": {
"/crowdsec": "CrowdSec"
},
"command_palette": [
{
"label": "CrowdSec",
"path": "/crowdsec",
"category": "Pages",
"keywords": "crowdsec decisions alerts bans ips allowlist security waf appsec"
}
]
}
}
@@ -0,0 +1,53 @@
/* CrowdSec extension — layout-only styles; colors/typography inherit from the
host design system (card, sk-dtable, sk-info-row, sk-kpi, empty-state…). */
.crowdsec-page .cs-kpis {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 12px;
margin: 12px 0;
}
.crowdsec-page .cs-empty-actions {
display: flex;
gap: 8px;
justify-content: center;
margin-top: 12px;
}
.crowdsec-page .cs-allowlists {
display: flex;
flex-direction: column;
gap: 12px;
}
.crowdsec-page .cs-allowlists__names {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.crowdsec-page .cs-allowlists__name {
background: none;
border: none;
padding: 2px 4px;
cursor: pointer;
text-align: left;
border-radius: 6px;
}
.crowdsec-page .cs-allowlists__name.is-active {
outline: 1px solid currentColor;
outline-offset: 2px;
}
.crowdsec-page .cs-entry-form {
display: flex;
gap: 8px;
margin-top: 12px;
align-items: center;
}
.crowdsec-page .cs-entry-form input {
max-width: 320px;
}
@@ -0,0 +1,381 @@
import { useCallback, useEffect, useState } from 'react';
import { Globe, RefreshCw, Plus, Trash2, Server } from 'lucide-react';
import api from '@/services/api';
import { PageTopbar, Pill } from '@/components/ds';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import Modal from '@/components/Modal';
import ConfirmDialog from '@/components/ConfirmDialog';
import EmptyState from '@/components/EmptyState';
import { useToast } from '@/contexts/ToastContext';
import ZoneDetail from './ZoneDetail.jsx';
const DnsServerPage = () => {
const toast = useToast();
const [status, setStatus] = useState(null);
const [zones, setZones] = useState([]);
const [loading, setLoading] = useState(true);
const [actionLoading, setActionLoading] = useState(false);
const [confirmDialog, setConfirmDialog] = useState(null);
const [selectedZone, setSelectedZone] = useState(null);
// Install form
const [installForm, setInstallForm] = useState({ ns_hostname: '', admin_email: '' });
// New zone modal
const [showZoneModal, setShowZoneModal] = useState(false);
const [zoneName, setZoneName] = useState('');
const loadData = useCallback(async () => {
setLoading(true);
try {
const statusData = await api.request('/dns-server/status');
setStatus(statusData);
if (statusData?.installed) {
const z = await api.request('/dns-server/zones').catch(() => ({ zones: [] }));
setZones(z.zones || []);
}
} catch (error) {
toast.error(`Failed to load DNS server status: ${error.message}`);
} finally {
setLoading(false);
}
}, [toast]);
useEffect(() => {
loadData();
}, [loadData]);
const handleInstall = async () => {
if (!installForm.ns_hostname.trim() || !installForm.admin_email.trim()) return;
setActionLoading(true);
try {
await api.request('/dns-server/install', {
method: 'POST',
body: {
ns_hostname: installForm.ns_hostname.trim(),
admin_email: installForm.admin_email.trim(),
},
});
toast.success('PowerDNS authoritative server installed');
await loadData();
} catch (error) {
toast.error(`Install failed: ${error.message}`);
} finally {
setActionLoading(false);
}
};
const handleUninstall = (keepData) => {
setConfirmDialog({
title: 'Remove DNS server',
message: keepData
? 'Remove the PowerDNS container? Zone data stays on disk and a reinstall picks it back up.'
: 'Remove the PowerDNS container AND delete all zone data? This cannot be undone.',
confirmText: 'Remove',
variant: 'danger',
onConfirm: async () => {
try {
await api.request(`/dns-server/install?keep_data=${keepData}`, { method: 'DELETE' });
toast.success('DNS server removed');
setSelectedZone(null);
await loadData();
} catch (error) {
toast.error(`Uninstall failed: ${error.message}`);
}
setConfirmDialog(null);
},
onCancel: () => setConfirmDialog(null),
});
};
const handleCreateZone = async () => {
if (!zoneName.trim()) return;
setActionLoading(true);
try {
await api.request('/dns-server/zones', {
method: 'POST',
body: { name: zoneName.trim() },
});
toast.success(`Zone ${zoneName} created`);
setShowZoneModal(false);
setZoneName('');
await loadData();
} catch (error) {
toast.error(`Failed to create zone: ${error.message}`);
} finally {
setActionLoading(false);
}
};
const handleDeleteZone = (name) => {
setConfirmDialog({
title: 'Delete zone',
message: `Delete zone ${name} and all of its records?`,
confirmText: 'Delete',
variant: 'danger',
onConfirm: async () => {
try {
await api.request(`/dns-server/zones/${encodeURIComponent(name)}`, { method: 'DELETE' });
toast.success(`Zone ${name} deleted`);
if (selectedZone === name) setSelectedZone(null);
await loadData();
} catch (error) {
toast.error(`Failed to delete zone: ${error.message}`);
}
setConfirmDialog(null);
},
onCancel: () => setConfirmDialog(null),
});
};
if (loading) {
return (
<div className="page-container dns-server-page">
<PageTopbar icon={<Globe size={18} />} title="DNS Server" />
<EmptyState loading title="Loading DNS server status..." />
</div>
);
}
// ── Not installed: explainer + install form ──
if (!status?.installed) {
return (
<div className="page-container dns-server-page">
<PageTopbar icon={<Globe size={18} />} title="DNS Server" />
<div className="card">
<div className="card-header">
<h3>Host Your Own Nameserver</h3>
</div>
<div className="card-body">
<p>
Run PowerDNS (authoritative, SQLite backend) in a managed Docker
container so this box answers DNS for your domains directly —
handy for homelabs and air-gapped networks where a hosted DNS
provider is not an option.
</p>
<ul className="dns-explainer">
<li>
<strong>Authoritative only.</strong> This serves the zones you
create; it never resolves other names for clients. Keep using
your normal resolver.
</li>
<li>
<strong>Port 53 must be free</strong> on this host (tcp + udp).
systemd-resolved or another DNS service will conflict.
</li>
<li>
<strong>Delegation happens at your registrar.</strong> Point the
domain&apos;s NS (and glue) records at this box&apos;s nameserver
hostname so the world finds it.
</li>
<li>
This complements provider integrations (Cloudflare etc.) — it
does not replace them.
</li>
</ul>
<div className="dns-install-form">
<div className="form-group">
<Label>Nameserver hostname</Label>
<Input
type="text"
value={installForm.ns_hostname}
onChange={(e) => setInstallForm((f) => ({ ...f, ns_hostname: e.target.value }))}
placeholder="ns1.example.com"
/>
<p className="text-muted">
The hostname other resolvers will use to reach this server.
It should resolve (via glue records) to this box&apos;s public IP.
</p>
</div>
<div className="form-group">
<Label>Hostmaster email</Label>
<Input
type="email"
value={installForm.admin_email}
onChange={(e) => setInstallForm((f) => ({ ...f, admin_email: e.target.value }))}
placeholder="hostmaster@example.com"
/>
<p className="text-muted">Used in each zone&apos;s SOA record.</p>
</div>
<div className="dns-install-actions">
<Button
variant="default"
onClick={handleInstall}
disabled={actionLoading || !installForm.ns_hostname.trim() || !installForm.admin_email.trim()}
>
{actionLoading ? 'Installing...' : 'Install DNS Server'}
</Button>
<Button variant="outline" onClick={loadData}>
<RefreshCw size={14} /> Re-check
</Button>
</div>
</div>
</div>
</div>
</div>
);
}
return (
<div className="page-container dns-server-page">
<PageTopbar
icon={<Globe size={18} />}
title="DNS Server"
actions={
<>
<Button variant="default" size="sm" onClick={() => setShowZoneModal(true)}>
<Plus size={14} /> New Zone
</Button>
<Button variant="outline" size="sm" onClick={loadData}>
<RefreshCw size={14} /> Refresh
</Button>
</>
}
/>
{/* ── Status ── */}
<div className="card">
<div className="card-header">
<h3>Server Status</h3>
<div className="card-actions">
<Button variant="secondary" size="sm" onClick={() => handleUninstall(true)}>
Remove (keep data)
</Button>
<Button variant="destructive" size="sm" onClick={() => handleUninstall(false)}>
<Trash2 size={14} /> Remove + data
</Button>
</div>
</div>
<div className="card-body">
<div className="sec-rows">
<div className="sk-info-row">
<span className="k">Container</span>
<Pill kind={status.running ? 'green' : 'red'}>
{status.running ? 'Running' : 'Stopped'}
</Pill>
</div>
<div className="sk-info-row">
<span className="k">Engine</span>
<span className="v">
PowerDNS Authoritative {status.version ? `v${status.version}` : '(version unavailable)'}
</span>
</div>
<div className="sk-info-row">
<span className="k">Nameserver</span>
<span className="v sk-cell-mono">{status.ns_hostname || '—'}</span>
</div>
<div className="sk-info-row">
<span className="k">Mode</span>
<span className="v">Authoritative only — no recursion, by design.</span>
</div>
</div>
</div>
</div>
{/* ── Zones ── */}
<div className="card sec-flush">
<div className="card-header">
<h3>Zones {zones.length > 0 && <span className="sec-count">· {zones.length}</span>}</h3>
</div>
{zones.length === 0 ? (
<div className="card-body">
<p className="text-muted">
No zones yet. Create one, then point the domain&apos;s nameservers here
at your registrar.
</p>
</div>
) : (
<table className="sk-dtable">
<thead>
<tr>
<th>Zone</th>
<th>Kind</th>
<th>Serial</th>
<th>DNSSEC</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{zones.map((z) => (
<tr key={z.name}>
<td className="sk-cell-mono">
<button
type="button"
className="dns-zone-link"
onClick={() => setSelectedZone(z.name)}
>
{z.name}
</button>
</td>
<td>{z.kind || '—'}</td>
<td>{z.serial ?? '—'}</td>
<td>
<Pill kind={z.dnssec ? 'green' : 'gray'}>
{z.dnssec ? 'Signed' : 'Off'}
</Pill>
</td>
<td>
<Button variant="secondary" size="sm" onClick={() => setSelectedZone(z.name)}>
<Server size={14} /> Manage
</Button>{' '}
<Button variant="secondary" size="sm" onClick={() => handleDeleteZone(z.name)}>
Delete
</Button>
</td>
</tr>
))}
</tbody>
</table>
)}
</div>
{/* ── Zone detail ── */}
{selectedZone && (
<ZoneDetail
zoneName={selectedZone}
onClose={() => setSelectedZone(null)}
onChanged={loadData}
/>
)}
{/* ── New zone modal ── */}
<Modal open={showZoneModal} onClose={() => setShowZoneModal(false)} title="New Zone">
<div className="form-group">
<Label>Zone name</Label>
<Input
type="text"
value={zoneName}
onChange={(e) => setZoneName(e.target.value)}
placeholder="example.com"
/>
<p className="text-muted">
SOA and NS records are bootstrapped from the nameserver hostname and
hostmaster email you provided at install.
</p>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowZoneModal(false)}>Cancel</Button>
<Button variant="default" onClick={handleCreateZone} disabled={actionLoading || !zoneName.trim()}>
{actionLoading ? 'Creating...' : 'Create Zone'}
</Button>
</div>
</Modal>
{confirmDialog && (
<ConfirmDialog
title={confirmDialog.title}
message={confirmDialog.message}
confirmText={confirmDialog.confirmText}
variant={confirmDialog.variant}
onConfirm={confirmDialog.onConfirm}
onCancel={confirmDialog.onCancel}
/>
)}
</div>
);
};
export default DnsServerPage;
@@ -0,0 +1,333 @@
import { useCallback, useEffect, useState } from 'react';
import { RefreshCw, Plus, ShieldCheck, X } from 'lucide-react';
import api from '@/services/api';
import { Pill } from '@/components/ds';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';
import Modal from '@/components/Modal';
import ConfirmDialog from '@/components/ConfirmDialog';
import { useToast } from '@/contexts/ToastContext';
const RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SRV', 'CAA', 'PTR'];
const EMPTY_FORM = { name: '', type: 'A', ttl: 3600, records: '' };
const ZoneDetail = ({ zoneName, onClose, onChanged }) => {
const toast = useToast();
const [zone, setZone] = useState(null);
const [dsRecords, setDsRecords] = useState([]);
const [delegation, setDelegation] = useState(null);
const [loading, setLoading] = useState(true);
const [actionLoading, setActionLoading] = useState(false);
const [confirmDialog, setConfirmDialog] = useState(null);
// Record editor modal (add or edit — edit pre-fills, save is an upsert)
const [showRecordModal, setShowRecordModal] = useState(false);
const [recordForm, setRecordForm] = useState(EMPTY_FORM);
const loadZone = useCallback(async () => {
setLoading(true);
try {
const data = await api.request(`/dns-server/zones/${encodeURIComponent(zoneName)}`);
setZone(data.zone || null);
setDsRecords(data.ds_records || []);
setDelegation(data.delegation || null);
} catch (error) {
toast.error(`Failed to load zone: ${error.message}`);
} finally {
setLoading(false);
}
}, [zoneName, toast]);
useEffect(() => {
loadZone();
}, [loadZone]);
const openAdd = () => {
setRecordForm(EMPTY_FORM);
setShowRecordModal(true);
};
const openEdit = (rrset) => {
setRecordForm({
name: rrset.name,
type: rrset.type,
ttl: rrset.ttl ?? 3600,
records: (rrset.records || []).join('\n'),
});
setShowRecordModal(true);
};
const handleSaveRecord = async () => {
const values = recordForm.records.split('\n').map((v) => v.trim()).filter(Boolean);
if (!values.length) return;
setActionLoading(true);
try {
await api.request(`/dns-server/zones/${encodeURIComponent(zoneName)}/rrsets`, {
method: 'POST',
body: {
name: recordForm.name.trim(),
type: recordForm.type,
ttl: Number(recordForm.ttl) || 3600,
records: values,
},
});
toast.success(`${recordForm.type} record set saved`);
setShowRecordModal(false);
await loadZone();
onChanged?.();
} catch (error) {
toast.error(`Failed to save record set: ${error.message}`);
} finally {
setActionLoading(false);
}
};
const handleDeleteRecord = (rrset) => {
setConfirmDialog({
title: 'Delete record set',
message: `Delete the ${rrset.type} record set for ${rrset.name}?`,
confirmText: 'Delete',
variant: 'danger',
onConfirm: async () => {
try {
const qs = `name=${encodeURIComponent(rrset.name)}&type=${encodeURIComponent(rrset.type)}`;
await api.request(
`/dns-server/zones/${encodeURIComponent(zoneName)}/rrsets?${qs}`,
{ method: 'DELETE' }
);
toast.success(`${rrset.type} record set deleted`);
await loadZone();
onChanged?.();
} catch (error) {
toast.error(`Failed to delete record set: ${error.message}`);
}
setConfirmDialog(null);
},
onCancel: () => setConfirmDialog(null),
});
};
const handleDnssec = async (enable) => {
setActionLoading(true);
try {
const res = await api.request(`/dns-server/zones/${encodeURIComponent(zoneName)}/dnssec`, {
method: 'POST',
body: { action: enable ? 'enable' : 'disable' },
});
toast.success(res.message || `DNSSEC ${enable ? 'enabled' : 'disabled'}`);
await loadZone();
onChanged?.();
} catch (error) {
toast.error(`DNSSEC update failed: ${error.message}`);
} finally {
setActionLoading(false);
}
};
return (
<div className="card dns-zone-detail">
<div className="card-header">
<h3 className="sk-cell-mono">{zoneName}</h3>
<div className="card-actions">
<Button variant="default" size="sm" onClick={openAdd}>
<Plus size={14} /> Add Record
</Button>
<Button variant="outline" size="sm" onClick={loadZone}>
<RefreshCw size={14} /> Refresh
</Button>
<Button variant="secondary" size="sm" onClick={onClose}>
<X size={14} /> Close
</Button>
</div>
</div>
<div className="card-body">
{loading ? (
<p className="text-muted">Loading zone...</p>
) : !zone ? (
<p className="text-muted">Zone could not be loaded.</p>
) : (
<>
{/* ── Delegation banner ── */}
{delegation && (
<div
className={`dns-delegation dns-delegation--${
delegation.checked === false ? 'unknown' : delegation.delegated ? 'ok' : 'warn'
}`}
>
{delegation.checked === false ? (
<span>Delegation check unavailable: {delegation.note}</span>
) : delegation.delegated ? (
<span>
Delegation looks correct — the public NS set matches this
zone ({(delegation.public_ns || []).join(', ')}).
</span>
) : (
<span>
{delegation.note}{' '}
{delegation.public_ns?.length > 0 && (
<>Public: {delegation.public_ns.join(', ')} · Zone:{' '}
{(delegation.zone_ns || []).join(', ') || 'none'}</>
)}
</span>
)}
</div>
)}
{/* ── Records ── */}
<table className="sk-dtable">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>TTL</th>
<th>Values</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{(zone.rrsets || []).map((r) => (
<tr key={`${r.name}|${r.type}`}>
<td className="sk-cell-mono">{r.name}</td>
<td><span className="sk-tag">{r.type}</span></td>
<td>{r.ttl ?? '—'}</td>
<td className="sk-cell-mono dns-values">
{(r.records || []).map((v) => <div key={v}>{v}</div>)}
</td>
<td>
<Button variant="secondary" size="sm" onClick={() => openEdit(r)}>
Edit
</Button>{' '}
{r.type !== 'SOA' && (
<Button variant="secondary" size="sm" onClick={() => handleDeleteRecord(r)}>
Delete
</Button>
)}
</td>
</tr>
))}
</tbody>
</table>
{/* ── DNSSEC ── */}
<div className="dns-dnssec">
<div className="dns-dnssec__head">
<h4><ShieldCheck size={16} /> DNSSEC</h4>
<Pill kind={zone.dnssec ? 'green' : 'gray'}>
{zone.dnssec ? 'Enabled' : 'Disabled'}
</Pill>
<Button
variant={zone.dnssec ? 'secondary' : 'default'}
size="sm"
disabled={actionLoading}
onClick={() => handleDnssec(!zone.dnssec)}
>
{zone.dnssec ? 'Disable' : 'Enable'}
</Button>
</div>
{zone.dnssec && (
dsRecords.length > 0 ? (
<div className="dns-ds">
<p className="text-muted">
Publish these DS records at your registrar (the parent
zone) to complete the chain of trust:
</p>
{dsRecords.map((ds) => (
<code key={ds} className="dns-ds__record">{ds}</code>
))}
</div>
) : (
<p className="text-muted">
DNSSEC is enabled but no DS records were returned yet —
refresh in a moment.
</p>
)
)}
</div>
</>
)}
</div>
{/* ── Record editor ── */}
<Modal
open={showRecordModal}
onClose={() => setShowRecordModal(false)}
title={`${recordForm.name ? 'Edit' : 'Add'} Record Set`}
>
<div className="form-group">
<Label>Name</Label>
<Input
type="text"
value={recordForm.name}
onChange={(e) => setRecordForm((f) => ({ ...f, name: e.target.value }))}
placeholder={`@ or www (relative to ${zoneName})`}
/>
</div>
<div className="form-group">
<Label>Type</Label>
<Select
value={recordForm.type}
onValueChange={(v) => setRecordForm((f) => ({ ...f, type: v }))}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
{RECORD_TYPES.map((t) => (
<SelectItem key={t} value={t}>{t}</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="form-group">
<Label>TTL (seconds)</Label>
<Input
type="number"
min={1}
max={604800}
value={recordForm.ttl}
onChange={(e) => setRecordForm((f) => ({ ...f, ttl: e.target.value }))}
/>
</div>
<div className="form-group">
<Label>Values (one per line)</Label>
<textarea
className="dns-record-values"
rows={4}
value={recordForm.records}
onChange={(e) => setRecordForm((f) => ({ ...f, records: e.target.value }))}
placeholder={'203.0.113.7\n203.0.113.8'}
/>
<p className="text-muted">
Saving replaces the whole record set for this name + type.
</p>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowRecordModal(false)}>Cancel</Button>
<Button
variant="default"
onClick={handleSaveRecord}
disabled={actionLoading || !recordForm.records.trim()}
>
{actionLoading ? 'Saving...' : 'Save Record Set'}
</Button>
</div>
</Modal>
{confirmDialog && (
<ConfirmDialog
title={confirmDialog.title}
message={confirmDialog.message}
confirmText={confirmDialog.confirmText}
variant={confirmDialog.variant}
onConfirm={confirmDialog.onConfirm}
onCancel={confirmDialog.onCancel}
/>
)}
</div>
);
};
export default ZoneDetail;
@@ -0,0 +1,8 @@
// Authoritative DNS hosting UI, contributed through the extension system.
// Fully self-contained in the extension — no core page to wrap. After sync
// this folder lives at frontend/src/plugins/serverkit-dns-server/, so '@/…'
// host aliases resolve.
export { default as DnsServerPage } from './components/DnsServerPage.jsx';
// No default export on purpose: PluginLoader legacy-auto-renders any plugin
// default export globally. The route contribution resolves the NAMED export.
@@ -0,0 +1,46 @@
{
"name": "serverkit-dns-server",
"display_name": "DNS Server",
"version": "1.0.0",
"description": "Host authoritative DNS on this box with PowerDNS (SQLite backend) in a managed Docker container — zones, records, DNSSEC, and delegation checks from the panel. Authoritative only (no recursion); complements provider integrations like Cloudflare, never replaces them. Built for homelab and air-gapped setups.",
"author": "ServerKit",
"license": "MIT",
"category": "networking",
"homepage": "https://github.com/jhd3197/ServerKit",
"permissions": [
"shell",
"docker"
],
"min_panel_version": "1.7.0",
"entry_point": "dns_server:dns_server_bp",
"url_prefix": "/api/v1/dns-server",
"icon": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20\"/><path d=\"M2 12h20\"/>",
"contributions": {
"nav": [
{
"id": "dns-server",
"label": "DNS Server",
"route": "/dns-server",
"category": "operations",
"icon": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20\"/><path d=\"M2 12h20\"/>"
}
],
"routes": [
{
"path": "dns-server",
"component": "DnsServerPage"
}
],
"page_titles": {
"/dns-server": "DNS Server"
},
"command_palette": [
{
"label": "DNS Server",
"path": "/dns-server",
"category": "Pages",
"keywords": "dns server powerdns authoritative nameserver zones records dnssec delegation hosting"
}
]
}
}
@@ -0,0 +1,92 @@
/* DNS Server extension — layout-only styles; colors/typography inherit from
the host design system (card, sk-dtable, sk-info-row, empty-state…). */
.dns-server-page .dns-explainer {
margin: 12px 0;
padding-left: 20px;
display: flex;
flex-direction: column;
gap: 6px;
}
.dns-server-page .dns-install-form {
max-width: 480px;
margin-top: 16px;
}
.dns-server-page .dns-install-actions {
display: flex;
gap: 8px;
margin-top: 12px;
}
.dns-server-page .dns-zone-link {
background: none;
border: none;
padding: 0;
cursor: pointer;
font: inherit;
color: inherit;
text-decoration: underline;
}
.dns-server-page .dns-delegation {
border-radius: 8px;
padding: 10px 12px;
margin-bottom: 12px;
border: 1px solid currentColor;
}
.dns-server-page .dns-delegation--ok { opacity: 0.9; }
.dns-server-page .dns-delegation--warn { font-weight: 500; }
.dns-server-page .dns-delegation--unknown { opacity: 0.7; }
.dns-server-page .dns-values div {
line-height: 1.5;
word-break: break-all;
}
.dns-server-page .dns-dnssec {
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid rgba(128, 128, 128, 0.25);
}
.dns-server-page .dns-dnssec__head {
display: flex;
align-items: center;
gap: 10px;
}
.dns-server-page .dns-dnssec__head h4 {
display: flex;
align-items: center;
gap: 6px;
margin: 0;
}
.dns-server-page .dns-ds {
margin-top: 10px;
display: flex;
flex-direction: column;
gap: 6px;
}
.dns-server-page .dns-ds__record {
display: block;
padding: 6px 8px;
border-radius: 6px;
word-break: break-all;
background: rgba(128, 128, 128, 0.12);
}
.dns-server-page .dns-record-values {
width: 100%;
font-family: inherit;
border-radius: 6px;
padding: 8px;
resize: vertical;
background: transparent;
color: inherit;
border: 1px solid rgba(128, 128, 128, 0.35);
}
@@ -0,0 +1,304 @@
// Import a live WordPress site over SSH (Panel Improvements #3).
//
// Three-step surface rendered inside the WordPress tab group:
// 1. Connection — host/port/user + password-or-key + remote WP path.
// 2. Probe — the backend captures the SSH host-key fingerprint and reads
// site facts (wp-config, version, size). The operator explicitly trusts
// the fingerprint before anything else touches the box.
// 3. Import — enqueues the pull-import job and polls its step log.
//
// After sync this file lives at frontend/src/plugins/serverkit-wordpress/, so
// shared pieces are imported through the host's `@/` alias like core pages do.
import { useEffect, useRef, useState } from 'react';
import { Link } from 'react-router-dom';
import api from '@/services/api';
import Spinner from '@/components/Spinner';
import { useToast } from '@/contexts/ToastContext';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
const POLL_MS = 2500;
export default function WordPressSshImport() {
const toast = useToast();
const [conn, setConn] = useState({
host: '', port: '22', username: 'root',
authMethod: 'key', password: '', privateKey: '',
wpPath: '/var/www/html',
});
const [probing, setProbing] = useState(false);
const [probe, setProbe] = useState(null); // probe result (incl. fingerprint)
const [trusted, setTrusted] = useState(false); // operator confirmed the host key
const [target, setTarget] = useState({ siteName: '', adminEmail: '', oldUrl: '' });
const [starting, setStarting] = useState(false);
const [job, setJob] = useState(null); // { id, status, steps, result, error }
const pollRef = useRef(null);
useEffect(() => () => clearInterval(pollRef.current), []);
const authPayload = () => (conn.authMethod === 'password'
? { password: conn.password }
: { private_key: conn.privateKey });
const handleProbe = async () => {
setProbing(true);
setProbe(null);
setTrusted(false);
try {
const result = await api.request('/wordpress/ssh-import/probe', {
method: 'POST',
body: {
host: conn.host.trim(),
port: parseInt(conn.port, 10) || 22,
username: conn.username.trim(),
auth: authPayload(),
wp_path: conn.wpPath.trim(),
},
});
setProbe(result);
setTarget(t => ({ ...t, oldUrl: t.oldUrl || result.site_url || '' }));
} catch (error) {
toast.error(error.message || 'Probe failed');
} finally {
setProbing(false);
}
};
const pollJob = async (jobId) => {
try {
const status = await api.request(`/wordpress/ssh-import/${jobId}`);
setJob(status);
if (['completed', 'failed', 'dead'].includes(status.status)) {
clearInterval(pollRef.current);
pollRef.current = null;
if (status.status === 'completed') {
toast.success('WordPress site imported successfully');
} else {
toast.error(status.error || 'Import failed — see the step log');
}
}
} catch {
/* transient poll error — keep polling */
}
};
const handleStart = async () => {
if (!trusted) { toast.error('Confirm the host-key fingerprint first'); return; }
if (!target.siteName.trim()) { toast.error('New site name is required'); return; }
setStarting(true);
try {
const res = await api.request('/wordpress/ssh-import', {
method: 'POST',
body: {
connection: {
host: conn.host.trim(),
port: parseInt(conn.port, 10) || 22,
username: conn.username.trim(),
auth: authPayload(),
},
fingerprint: probe.host_key_fingerprint,
target: {
site_name: target.siteName.trim(),
admin_email: target.adminEmail.trim(),
},
options: {
wp_path: conn.wpPath.trim(),
old_url: target.oldUrl.trim() || undefined,
},
},
});
setJob({ id: res.job_id, status: 'pending', steps: [] });
pollRef.current = setInterval(() => pollJob(res.job_id), POLL_MS);
pollJob(res.job_id);
} catch (error) {
toast.error(error.message || 'Failed to start the import');
} finally {
setStarting(false);
}
};
const running = job && !['completed', 'failed', 'dead'].includes(job.status);
const canProbe = conn.host.trim() && conn.username.trim() && conn.wpPath.trim()
&& (conn.authMethod === 'password' ? conn.password : conn.privateKey);
const facts = probe && [
['WordPress version', probe.wp_version || 'unknown'],
['Site URL', probe.site_url || 'unknown'],
['Database', probe.db_name],
['Table prefix', probe.table_prefix],
['Docroot size', probe.docroot_size_kb != null
? `${(probe.docroot_size_kb / 1024).toFixed(1)} MB` : 'unknown'],
['WP-CLI on source', probe.has_wp_cli ? 'yes' : 'no (fallbacks used)'],
];
return (
<div className="sk-tabgroup__inner wp-ssh-import">
<div className="page-section">
<h2 className="text-lg font-semibold">Import a live site over SSH</h2>
<p className="text-sm text-muted-foreground">
Point at any WordPress install you can reach over SSH. The panel pulls the
files and database through the tunnel and rebuilds it as a managed site —
nothing is installed on the source server.
</p>
</div>
{/* Step 1 — connection */}
<div className="card p-4 mb-4">
<h3 className="font-medium mb-3">1. Source server</h3>
<div className="grid grid-cols-2 gap-4">
<div className="form-group">
<Label>Host <span className="required">*</span></Label>
<Input value={conn.host} disabled={running}
onChange={e => setConn({ ...conn, host: e.target.value })}
placeholder="203.0.113.10 or wp.example.com" />
</div>
<div className="form-group">
<Label>Port</Label>
<Input value={conn.port} disabled={running}
onChange={e => setConn({ ...conn, port: e.target.value })}
placeholder="22" />
</div>
<div className="form-group">
<Label>Username <span className="required">*</span></Label>
<Input value={conn.username} disabled={running}
onChange={e => setConn({ ...conn, username: e.target.value })}
placeholder="root" />
</div>
<div className="form-group">
<Label>WordPress path <span className="required">*</span></Label>
<Input value={conn.wpPath} disabled={running}
onChange={e => setConn({ ...conn, wpPath: e.target.value })}
placeholder="/var/www/html" />
<span className="form-hint">Absolute path of the directory containing wp-config.php.</span>
</div>
</div>
<div className="form-group">
<Label>Authentication</Label>
<div className="flex gap-4 mb-2">
<label className="flex items-center gap-2 text-sm">
<input type="radio" checked={conn.authMethod === 'key'} disabled={running}
onChange={() => setConn({ ...conn, authMethod: 'key' })} />
Private key
</label>
<label className="flex items-center gap-2 text-sm">
<input type="radio" checked={conn.authMethod === 'password'} disabled={running}
onChange={() => setConn({ ...conn, authMethod: 'password' })} />
Password
</label>
</div>
{conn.authMethod === 'key' ? (
<>
<textarea
className="w-full font-mono text-xs"
rows={5}
value={conn.privateKey}
disabled={running}
onChange={e => setConn({ ...conn, privateKey: e.target.value })}
placeholder={'-----BEGIN OPENSSH PRIVATE KEY-----\n…'}
/>
<span className="form-hint">Used for this import only — never stored.</span>
</>
) : (
<>
<Input type="password" value={conn.password} disabled={running}
onChange={e => setConn({ ...conn, password: e.target.value })}
placeholder="SSH password" />
<span className="form-hint">Used for this import only — never stored. Password auth requires the sshpass package on the panel host.</span>
</>
)}
</div>
<Button onClick={handleProbe} disabled={!canProbe || probing || running}>
{probing ? <><Spinner size="sm" /> Probing…</> : 'Probe server'}
</Button>
</div>
{/* Step 2 — facts + host-key trust */}
{probe && (
<div className="card p-4 mb-4">
<h3 className="font-medium mb-3">2. Confirm the host</h3>
<div className="form-group">
<Label>SSH host-key fingerprint ({probe.host_key_type})</Label>
<code className="block font-mono text-xs break-all">{probe.host_key_fingerprint}</code>
<span className="form-hint">
Compare against the server you expect (ssh-keygen -lf on the source).
Every step of the import is pinned to this exact key.
</span>
</div>
<table className="text-sm">
<tbody>
{facts.map(([k, v]) => (
<tr key={k}>
<td className="pr-4 text-muted-foreground">{k}</td>
<td className="font-mono">{String(v)}</td>
</tr>
))}
</tbody>
</table>
<label className="flex items-center gap-2 text-sm mt-3">
<input type="checkbox" checked={trusted} disabled={running}
onChange={e => setTrusted(e.target.checked)} />
I recognize this fingerprint — trust this host for the import
</label>
</div>
)}
{/* Step 3 — target + run */}
{probe && (
<div className="card p-4 mb-4">
<h3 className="font-medium mb-3">3. New managed site</h3>
<div className="grid grid-cols-2 gap-4">
<div className="form-group">
<Label>Site name <span className="required">*</span></Label>
<Input value={target.siteName} disabled={running}
onChange={e => setTarget({ ...target, siteName: e.target.value })}
placeholder="my-migrated-site" />
<span className="form-hint">Letters, numbers, and hyphens only.</span>
</div>
<div className="form-group">
<Label>Admin email</Label>
<Input type="email" value={target.adminEmail} disabled={running}
onChange={e => setTarget({ ...target, adminEmail: e.target.value })}
placeholder="admin@example.com" />
</div>
<div className="form-group">
<Label>Original site URL</Label>
<Input value={target.oldUrl} disabled={running}
onChange={e => setTarget({ ...target, oldUrl: e.target.value })}
placeholder="https://old-site.com" />
<span className="form-hint">Rewritten to the new local address after import (detected automatically when possible).</span>
</div>
</div>
<Button onClick={handleStart} disabled={!trusted || starting || running}>
{starting ? <><Spinner size="sm" /> Starting…</> : 'Pull and import'}
</Button>
</div>
)}
{/* Job progress */}
{job && (
<div className="card p-4 mb-4">
<h3 className="font-medium mb-3">
Import job #{job.id} — {job.status}
{running && <Spinner size="sm" />}
</h3>
<ul className="text-sm font-mono space-y-1">
{(job.steps || []).map((s, i) => (
<li key={i}>
<span className="text-muted-foreground">[{s.step}]</span> {s.message}
</li>
))}
</ul>
{job.status === 'failed' && job.error && (
<p className="text-sm text-destructive mt-2">{job.error}</p>
)}
{job.status === 'completed' && (
<p className="text-sm mt-2">
Done. <Link to="/wordpress" className="underline">Open the WordPress sites list</Link>
{job.result?.new_url && <> — new address: <code>{job.result.new_url}</code></>}
</p>
)}
</div>
)}
</div>
);
}
@@ -23,6 +23,7 @@ import WordPressPluginLibrary from '../../pages/WordPressPluginLibrary';
import WordPressProjects from '../../pages/WordPressProjects';
import WordPressProject from '../../pages/WordPressProject';
import WordPressDetail from '../../pages/WordPressDetail';
import WordPressSshImport from './WordPressSshImport';
// "WordPress Projects" was renamed to "Pipelines" (§2 unification). Forward old
// deep links to the new space.
@@ -40,6 +41,9 @@ export function WordPressExtension() {
<Route index element={<WordPress />} />
<Route path="plugins/library" element={<WordPressPluginLibrary />} />
<Route path="pipelines" element={<WordPressProjects />} />
{/* SSH pull-import (Panel Improvements #3) — shares the group
chrome; reached via the command palette / direct link. */}
<Route path="ssh-import" element={<WordPressSshImport />} />
</Route>
{/* Full-bleed pipeline detail (own chrome, outside the tab group). */}
<Route path="pipelines/:id" element={<WordPressProject />} />
@@ -33,6 +33,17 @@
"attr": "environment_pipeline_bp",
"url_prefix": "/api/v1/wordpress/pipelines",
"name": "environment_pipeline_pipelines"
},
{
"module": "wp_ssh_import",
"attr": "wp_ssh_import_bp",
"url_prefix": "/api/v1/wordpress"
}
],
"jobs": [
{
"kind": "wordpress.ssh_import.run",
"handler": "wp_ssh_import_service:run_wp_ssh_import_job"
}
],
"icon": "<path d=\"M12 2a10 10 0 100 20 10 10 0 000-20zm-8 10a8 8 0 011.4-4.5l4.7 12.9A8 8 0 014 12zm8 8c-.8 0-1.6-.1-2.3-.3l2.4-7 2.5 6.8.1.1A8 8 0 0112 20zm1.1-11.8c.5 0 .9-.1.9-.1.4 0 .4-.6-.1-.6 0 0-1.4.1-2.3.1-.8 0-2.2-.1-2.2-.1-.5 0-.6.6-.1.6 0 0 .4.1.9.1l1.3 3.6-1.9 5.6L6.6 8.2c.5 0 .9-.1.9-.1.4 0 .4-.6-.1-.6 0 0-1.4.1-2.3.1h-.4A8 8 0 0112 4a8 8 0 016.5 3.3h-.3c-.8 0-1.4.7-1.4 1.5 0 .7.4 1.3.8 2 .3.6.7 1.3.7 2.3 0 .7-.3 1.6-.6 2.7l-.8 2.7-2.9-8.8z\"/>",
@@ -55,7 +66,8 @@
"page_titles": {
"/wordpress": "WordPress Sites",
"/wordpress/plugins/library": "WordPress Plugin Library",
"/wordpress/pipelines": "WordPress Pipelines"
"/wordpress/pipelines": "WordPress Pipelines",
"/wordpress/ssh-import": "Import WordPress over SSH"
},
"command_palette": [
{
@@ -64,6 +76,12 @@
"category": "Pages",
"keywords": "wp sites"
},
{
"label": "Import WordPress over SSH",
"path": "/wordpress/ssh-import",
"category": "Pages",
"keywords": "wp migrate pull import ssh"
},
{
"label": "WordPress Pipelines",
"path": "/wordpress/pipelines",