Make Technitium zones from the DNS page
A New zone form on a Technitium DNS provider makes a Primary zone (a domain name, or an address or network for a reverse zone), a Secondary zone (from the servers that hold it) or a Forwarder zone (where to pass questions, the protocol, DNSSEC). Names are written lower case, ASCII, without the trailing dot and refused before Technitium is asked if they are not zone names; Technitium's own refusal (a zone that exists) is shown as it was said. Administrators only, audited, and only for providers that can (the adapter gets an optional createZone). The new zone opens when it is made. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f73704e6ca
commit
0244f5a8ab
12 files changed
+533
-10
No files matched your search
@@ -4,8 +4,11 @@
|
||||
*
|
||||
* API docs: https://github.com/TechnitiumSoftware/DnsServer/blob/master/APIDOCS.md
|
||||
* Record ID format: "type||name||content||priority"
|
||||
*
|
||||
* Making a zone is `/api/zones/create` (permission "Zones: Modify"): the name and the type, and for a Secondary zone its primary servers, for a Forwarder zone the address to pass questions to, the
|
||||
* protocol to use and whether to validate DNSSEC. It answers with the name of the zone it made (`response.domain` — for a reverse zone the …arpa name). Not checked against a live server.
|
||||
*/
|
||||
import type { DnsAdapter, DnsRecord, DnsRecordInput, DnsZone } from "../types.js";
|
||||
import type { DnsAdapter, DnsRecord, DnsRecordInput, DnsZone, NewDnsZone } from "../types.js";
|
||||
import { withDiagLogging } from "../../services/diagLog.js";
|
||||
|
||||
export interface TechnitiumConfig {
|
||||
@@ -96,6 +99,20 @@ export function createTechnitiumAdapter(config: TechnitiumConfig): DnsAdapter {
|
||||
return { type, name, content, priority: priorityStr ? parseInt(priorityStr, 10) : undefined };
|
||||
}
|
||||
|
||||
async function createZone(zone: NewDnsZone): Promise<DnsZone> {
|
||||
const params: Record<string, string> = { zone: zone.name, type: zone.type };
|
||||
if (zone.type === "Secondary") params.primaryNameServerAddresses = zone.primaryNameServers.join(",");
|
||||
if (zone.type === "Forwarder") {
|
||||
params.initializeForwarder = "true";
|
||||
params.forwarder = zone.forwarder;
|
||||
params.protocol = zone.protocol;
|
||||
params.dnssecValidation = String(zone.dnssecValidation);
|
||||
}
|
||||
const resp = await apiPost("/api/zones/create", params);
|
||||
const made = typeof resp?.domain === "string" && resp.domain.trim() !== "" ? resp.domain.trim() : zone.name;
|
||||
return { id: made, name: made };
|
||||
}
|
||||
|
||||
async function listZones(): Promise<DnsZone[]> {
|
||||
const resp = await apiGet("/api/zones/list");
|
||||
const zones = resp?.zones ?? [];
|
||||
@@ -149,5 +166,5 @@ export function createTechnitiumAdapter(config: TechnitiumConfig): DnsAdapter {
|
||||
await apiPost("/api/zones/records/delete", { domain: name, zone, type, ...typeParams });
|
||||
}
|
||||
|
||||
return withDiagLogging("technitium", { listZones, listRecords, addRecord, updateRecord, deleteRecord });
|
||||
return withDiagLogging("technitium", { listZones, createZone, listRecords, addRecord, updateRecord, deleteRecord });
|
||||
}
|
||||
Reference in new issue
Block a user