#32: file composed mail, and verify DNS records for real
Three things the console and the mail client were getting wrong. **Sent stayed empty and drafts would not save.** Both write through the same persistence path, and both failed on the same constraint: spf_result, dkim_result and dmarc_result are restricted to the RFC verdict vocabulary and are nullable, so "not evaluated" has to be NULL. The compose path left them at Go's zero value, which sends an empty string - satisfying neither the CHECK nor the meaning - and the insert was rejected. Filing the Sent copy is deliberately non-fatal, so it failed silently; saving a draft reported the error. Inbound mail was unaffected because it always supplies a real verdict, which is also why the existing test never caught it. **DNS reconciliation could not verify anything.** The console posted to the auth service, which has no resolver, so the endpoint recorded the request and re-read the status already in the database. The machinery to do it properly already existed - the background reconciler resolves every expected record through public resolvers - it just was not reachable from the console. Adds GET /api/v1/admin/dns/verify to the protocols service, which owns both the resolver and the record spec, and wires the domains screen to it: every expected record, its expected value, and whether it actually resolves. A proxied record is reported as present rather than matching, because behind a proxy the published answer is the provider's address and comparing values would always disagree. Reconciliation still runs afterwards so the stored status and the audit trail stay in step. The spec is read, never provisioned: opening a screen must not create DKIM keys as a side effect. Verified: the persistence test fails without the fix with the exact constraint violation (email_messages_dkim_result_check), 22 Go packages and 36 webmail tests green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8cfe339d13
commit
e5edee096c
10 files changed
+354
-25
No files matched your search
@@ -46,10 +46,12 @@
|
||||
"noCertificate": "No certificate is loaded for this host.",
|
||||
"noChecks": "No checks reported.",
|
||||
"noDomains": "No domains have been onboarded yet.",
|
||||
"notPublished": "Not published",
|
||||
"onboardIntro": "Creates the domain and its standard RFC 2142 aliases, pointed at your address.",
|
||||
"onboardTitle": "Add a domain",
|
||||
"openAdmin": "Admin console",
|
||||
"preflightTitle": "Readiness checks",
|
||||
"presentProxied": "Present (proxied)",
|
||||
"queueEmpty": "The outbound queue is empty.",
|
||||
"queueSubtitle": "Inspect the outbound queue, retry a job, or cancel one.",
|
||||
"queueTitle": "Outbound queue",
|
||||
@@ -73,6 +75,7 @@
|
||||
"tracePlaceholder": "Queue ID",
|
||||
"traceTitle": "Trace a message",
|
||||
"unknownSni": "Unknown SNI requests",
|
||||
"verifyIntro": "Resolves every expected record against public resolvers and reports each one.",
|
||||
"watcherHealthy": "Certificate watcher"
|
||||
},
|
||||
"auth": {
|
||||
|
||||
@@ -46,10 +46,12 @@
|
||||
"noCertificate": "No hay certificado cargado para este host.",
|
||||
"noChecks": "No se informaron verificaciones.",
|
||||
"noDomains": "Aún no se ha dado de alta ningún dominio.",
|
||||
"notPublished": "No publicado",
|
||||
"onboardIntro": "Crea el dominio y sus alias estándar RFC 2142, apuntados a su dirección.",
|
||||
"onboardTitle": "Añadir un dominio",
|
||||
"openAdmin": "Consola de administración",
|
||||
"preflightTitle": "Verificaciones de preparación",
|
||||
"presentProxied": "Presente (con proxy)",
|
||||
"queueEmpty": "La cola de salida está vacía.",
|
||||
"queueSubtitle": "Inspeccione la cola de salida, reintente un trabajo o cancele uno.",
|
||||
"queueTitle": "Cola de salida",
|
||||
@@ -73,6 +75,7 @@
|
||||
"tracePlaceholder": "ID de la cola",
|
||||
"traceTitle": "Rastrear un mensaje",
|
||||
"unknownSni": "Solicitudes SNI desconocidas",
|
||||
"verifyIntro": "Resuelve cada registro esperado en resolutores públicos e informa uno por uno.",
|
||||
"watcherHealthy": "Monitor de certificado"
|
||||
},
|
||||
"auth": {
|
||||
|
||||
@@ -46,10 +46,12 @@
|
||||
"noCertificate": "Nenhum certificado carregado para este host.",
|
||||
"noChecks": "Nenhuma verificação relatada.",
|
||||
"noDomains": "Nenhum domínio foi cadastrado ainda.",
|
||||
"notPublished": "Não publicado",
|
||||
"onboardIntro": "Cria o domínio e os apelidos padrão da RFC 2142, apontados para o seu endereço.",
|
||||
"onboardTitle": "Adicionar um domínio",
|
||||
"openAdmin": "Console de administração",
|
||||
"preflightTitle": "Verificações de prontidão",
|
||||
"presentProxied": "Presente (com proxy)",
|
||||
"queueEmpty": "A fila de saída está vazia.",
|
||||
"queueSubtitle": "Inspecione a fila de saída, tente reenviar um trabalho ou cancele um.",
|
||||
"queueTitle": "Fila de saída",
|
||||
@@ -73,6 +75,7 @@
|
||||
"tracePlaceholder": "ID da fila",
|
||||
"traceTitle": "Rastrear uma mensagem",
|
||||
"unknownSni": "Requisições SNI desconhecidas",
|
||||
"verifyIntro": "Resolve cada registro esperado em servidores DNS públicos e relata um a um.",
|
||||
"watcherHealthy": "Monitor de certificado"
|
||||
},
|
||||
"auth": {
|
||||
|
||||
@@ -24,6 +24,23 @@ import { Button } from "../../../../components/ui/Button";
|
||||
* instead of drawing a table of green ticks.
|
||||
*/
|
||||
|
||||
interface DnsRecordCheck {
|
||||
type: string;
|
||||
name: string;
|
||||
expected: string;
|
||||
verified: boolean;
|
||||
detail: string;
|
||||
proxied: boolean;
|
||||
}
|
||||
|
||||
interface DnsVerification {
|
||||
domain: string;
|
||||
status: string;
|
||||
verified: number;
|
||||
total: number;
|
||||
records: DnsRecordCheck[];
|
||||
}
|
||||
|
||||
interface Domain {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -53,6 +70,7 @@ export default function AdminDomainsPage() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const [reconciling, setReconciling] = useState(false);
|
||||
const [verification, setVerification] = useState<DnsVerification | null>(null);
|
||||
const [onboardDomain, setOnboardDomain] = useState("");
|
||||
const [onboarding, setOnboarding] = useState(false);
|
||||
|
||||
@@ -86,22 +104,27 @@ export default function AdminDomainsPage() {
|
||||
|
||||
const selected = domains.find((d) => d.id === selectedId) ?? null;
|
||||
|
||||
// Asks the protocols service to resolve every expected record and report
|
||||
// each one. It used to post to the auth service, which has no resolver and
|
||||
// could only re-read the status already in the database.
|
||||
const handleReconcile = async () => {
|
||||
if (!selected) return;
|
||||
setReconciling(true);
|
||||
setNotice(null);
|
||||
setError(null);
|
||||
setVerification(null);
|
||||
try {
|
||||
// The real domain id, not the literal string "default-domain" that used
|
||||
// to be sent here for every domain on the server.
|
||||
const res = await fetch("/api/v1/admin/domains/reconcile", {
|
||||
const res = await fetch(`/api/v1/admin/dns/verify?domain=${encodeURIComponent(selected.name)}`);
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.message);
|
||||
setVerification(data);
|
||||
// Reconciliation still runs, so the stored status and the audit trail
|
||||
// stay in step with what was just observed.
|
||||
await fetch("/api/v1/admin/domains/reconcile", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ domain_id: selected.id }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.message);
|
||||
setNotice(data.message ?? t("settings.settingsSaved"));
|
||||
}).catch(() => undefined);
|
||||
await load();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error && err.message ? err.message : t("errors.serverError"));
|
||||
@@ -262,19 +285,67 @@ export default function AdminDomainsPage() {
|
||||
))
|
||||
)}
|
||||
|
||||
{/* Says what reconciliation currently does. The old copy announced
|
||||
"Cloudflare sync finished: all 13 DNS records verified" on every
|
||||
press - including when the request failed - while the endpoint
|
||||
behind it only writes an audit entry. */}
|
||||
<Card className="space-y-3">
|
||||
<div className="flex items-start gap-2 text-xs text-amber-300">
|
||||
<AlertTriangle className="w-4 h-4 flex-shrink-0 mt-0.5" />
|
||||
<p>{t("admin.reconcileNotImplemented")}</p>
|
||||
<Card className="space-y-4">
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<p className="text-xs text-slate-400">{t("admin.verifyIntro")}</p>
|
||||
<Button variant="outline" size="sm" onClick={handleReconcile} disabled={reconciling || !selected}>
|
||||
<RefreshCw className={`w-3.5 h-3.5 ${reconciling ? "animate-spin" : ""}`} />
|
||||
<span>{t("admin.reconcileDns")}</span>
|
||||
</Button>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={handleReconcile} disabled={reconciling || !selected}>
|
||||
<RefreshCw className={`w-3.5 h-3.5 ${reconciling ? "animate-spin" : ""}`} />
|
||||
<span>{t("admin.reconcileDns")}</span>
|
||||
</Button>
|
||||
|
||||
{verification && (
|
||||
<>
|
||||
<div className="flex items-center gap-3">
|
||||
<span
|
||||
className={`text-2xl font-black font-mono ${
|
||||
verification.verified === verification.total ? "text-emerald-400" : "text-amber-400"
|
||||
}`}
|
||||
>
|
||||
{verification.verified} / {verification.total}
|
||||
</span>
|
||||
<Badge variant={statusVariant(verification.status)}>{verification.status}</Badge>
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left border-collapse text-xs">
|
||||
<thead>
|
||||
<tr className="border-b border-slate-800 bg-slate-900/40 text-slate-400">
|
||||
<th className="p-2.5">{t("ui.recordName")}</th>
|
||||
<th className="p-2.5">{t("ui.expectedValue")}</th>
|
||||
<th className="p-2.5">{t("common.status")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-slate-800/60 font-mono">
|
||||
{verification.records.map((rec, i) => (
|
||||
<tr key={i} className="hover:bg-slate-900/30 align-top">
|
||||
<td className="p-2.5 text-slate-200 whitespace-nowrap">
|
||||
<span className="text-emerald-400 font-bold">{rec.type}</span> {rec.name}
|
||||
</td>
|
||||
<td className="p-2.5 text-slate-400 break-all max-w-md">{rec.expected}</td>
|
||||
<td className="p-2.5 whitespace-nowrap">
|
||||
{rec.verified ? (
|
||||
<span className="flex items-center gap-1 text-emerald-400">
|
||||
<CheckCircle2 className="w-3.5 h-3.5" />
|
||||
{rec.proxied ? t("admin.presentProxied") : t("admin.dnsStatusVerified")}
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
className="flex items-center gap-1 text-amber-400"
|
||||
title={rec.detail}
|
||||
>
|
||||
<AlertTriangle className="w-3.5 h-3.5" />
|
||||
{t("admin.notPublished")}
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user