feat: manage TLSA records
Test / test (push) Successful in 28m4s
Build and publish image / image (push) Successful in 28m43s

This commit is contained in:
bryanpedini committed 2026-11-22 11:31:59 +01:00
1 parent 9c2fb9d15b
commit a67183b646
14 files changed
+141 -15

No files matched your search

+9 -1
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2026 Bryan Joshua Pedini
export const EDITABLE_TYPES = ["A", "AAAA", "CNAME", "NS", "MX", "TXT", "SRV", "CAA"];
export const EDITABLE_TYPES = ["A", "AAAA", "CNAME", "NS", "MX", "TXT", "SRV", "CAA", "TLSA"];
export const KNOWN_TYPES = [...EDITABLE_TYPES, "SOA"];
export const FIELD_SPECS = {
@@ -35,6 +35,12 @@ export const FIELD_SPECS = {
{ key: "tag", label: "Tag", placeholder: "issue" },
{ key: "value", label: "Value", placeholder: "ca.example.net" },
],
TLSA: [
{ key: "usage", label: "Certificate usage", options: [["0", "0 (PKIX-TA)"], ["1", "1 (PKIX-EE)"], ["2", "2 (DANE-TA)"], ["3", "3 (DANE-EE)"]] },
{ key: "selector", label: "Selector", options: [["0", "0 (full certificate)"], ["1", "1 (SubjectPublicKeyInfo)"]] },
{ key: "matching_type", label: "Matching type", options: [["0", "0 (exact match)"], ["1", "1 (SHA-256)"], ["2", "2 (SHA-512)"]] },
{ key: "certificate", label: "Certificate association data (hex)", multiline: true, hex: true, placeholder: "0123456789abcdef..." },
],
};
export function presentValue(record) {
@@ -55,6 +61,8 @@ export function presentValue(record) {
return data.priority + " " + data.weight + " " + data.port + " " + data.target;
case "CAA":
return data.flag + " " + data.tag + ' "' + data.value + '"';
case "TLSA":
return data.usage + " " + data.selector + " " + data.matching_type + " " + data.certificate;
case "SOA":
return [data.ns, data.MBox !== undefined ? data.MBox : data.mbox, data.serial == null || data.serial === 0 ? "dynamic (Unix time)" : data.serial, data.refresh, data.retry, data.expire, data.minttl].join(" ");
default:
+3 -2
View File
@@ -309,7 +309,8 @@ function buildTypeFields(type, values) {
let control;
const current = values[spec.key] === undefined || values[spec.key] === null ? "" : String(values[spec.key]);
if (spec.options) {
control = h("select", { id, name: spec.key }, spec.options.map(([value, label]) => option(value, label, value === current)));
const choices = current !== "" && !spec.options.some(([value]) => value === current) ? [...spec.options, [current, current]] : spec.options;
control = h("select", { id, name: spec.key }, choices.map(([value, label]) => option(value, label, value === current)));
} else if (spec.multiline) {
control = h("textarea", { id, name: spec.key, rows: 3, autocomplete: "off", spellcheck: "false", placeholder: spec.placeholder, value: current });
} else {
@@ -376,7 +377,7 @@ function recordBody(form) {
const data = {};
for (const spec of FIELD_SPECS[type] || []) {
const value = form.elements[spec.key].value;
data[spec.key] = spec.numeric || spec.options ? parseNumber(value) : spec.multiline || (type === "CAA" && spec.key === "value") ? value : value.trim();
data[spec.key] = spec.numeric || spec.options ? parseNumber(value) : spec.hex ? value.replace(/[\s:]/g, "").toLowerCase() : spec.multiline || (type === "CAA" && spec.key === "value") ? value : value.trim();
}
return { name: form.elements.name.value.trim(), type, ttl: parseNumber(form.elements.ttl.value), data };
}