@astrofoundry/pi-astro 0.40.14 → 0.40.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/dns.md +2 -2
- package/extensions/specialist-gate/approvals.test.ts +4 -0
- package/extensions/specialist-gate/index.ts +6 -1
- package/package.json +1 -1
- package/skills/dns/SKILL.md +18 -5
- package/specialists/AGENTS.md +1 -1
- package/specialists/README.md +4 -4
- package/specialists/dns/run.ts +142 -34
- package/specialists/wrappers.test.ts +36 -7
package/agents/dns.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dns
|
|
3
|
-
description: Operates internal DNS (Technitium
|
|
3
|
+
description: Operates internal DNS (the Technitium cluster at 37 and Mira) and public DNS (Cloudflare zones 37pla.net and monadeo.com) through the dns tool. Use for zone and record questions, record changes, split-DNS checks, cluster state, and resolver health.
|
|
4
4
|
tools: read, dns, subagent
|
|
5
5
|
skills: dns
|
|
6
6
|
systemPromptMode: replace
|
|
@@ -15,7 +15,7 @@ You are the DNS specialist. The `dns` tool is your only way to reach Technitium
|
|
|
15
15
|
Rules:
|
|
16
16
|
|
|
17
17
|
- Read before you write: list the zone's records, then add, update, or delete exactly the record the task names. Never create duplicates.
|
|
18
|
-
- Internal changes go to the Technitium primary only; the
|
|
18
|
+
- Internal changes go to the Technitium primary only; the other nodes follow through the catalog zone and the cluster. After a write, read the same zone from every node with `node <fqdn>` and report whether each has caught up.
|
|
19
19
|
- New internal zones are Primary zones in the configured catalog; confirm with `zone-options` afterwards.
|
|
20
20
|
- Public records for the front door point at the VPS address with TTL 300 and `proxied: false`. Add the hostname to the VPS nginx allowlist (edge specialist) before the public record exists.
|
|
21
21
|
- Deleting a zone or a record is only for tasks that name it explicitly; state what would disappear before you do it.
|
|
@@ -9,6 +9,10 @@ describe("approvals", () => {
|
|
|
9
9
|
expect(isRisky("dns", ["technitium", "primary", "zones"])).toBe(false);
|
|
10
10
|
expect(isRisky("dns", ["technitium", "primary", "record-delete", "z", "d", "A", "ipAddress=1.1.1.1"])).toBe(true);
|
|
11
11
|
expect(isRisky("dns", ["cloudflare", "record-add", "37pla.net", "{}"])).toBe(true);
|
|
12
|
+
expect(isRisky("dns", ["technitium", "primary", "cluster-init", "dns.home.arpa", "10.0.40.53"])).toBe(true);
|
|
13
|
+
expect(isRisky("dns", ["technitium", "node", "technitium2.dns.home.arpa", "server-domain", "technitium2"])).toBe(true);
|
|
14
|
+
expect(isRisky("dns", ["technitium", "node", "technitium2.dns.home.arpa", "cluster-state"])).toBe(false);
|
|
15
|
+
expect(isRisky("dns", ["technitium", "join", "http://10.1.40.53:5380", "10.1.40.53"])).toBe(true);
|
|
12
16
|
expect(isRisky("identity", ["zitadel", "GET", "/v2/users"])).toBe(false);
|
|
13
17
|
expect(isRisky("identity", ["zitadel", "DELETE", "/v2/users/1"])).toBe(true);
|
|
14
18
|
expect(isRisky("identity", ["dmz", "deploy-config"])).toBe(true);
|
|
@@ -34,7 +34,12 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
|
|
|
34
34
|
identity: [/^zitadel\s+(DELETE|POST|PUT|PATCH)\b/, /^dmz\s+(deploy-config|pomerium-restart|render|lego-renew)\b/],
|
|
35
35
|
// Every UniFi write, on either console.
|
|
36
36
|
network: [/^unifi\s+\S+\s+write\b/],
|
|
37
|
-
dns: [
|
|
37
|
+
dns: [
|
|
38
|
+
/^technitium\s+primary\s+(zone-create|zone-delete|record-add|record-update|record-delete|cluster-init|cluster-delete|cluster-remove|server-domain)\b/,
|
|
39
|
+
/^technitium\s+node\s+\S+\s+server-domain\b/,
|
|
40
|
+
/^technitium\s+join\b/,
|
|
41
|
+
/^cloudflare\s+record-(add|update|delete)\b/,
|
|
42
|
+
],
|
|
38
43
|
edge: [/^vps\s+deploy-nginx\b/],
|
|
39
44
|
backup: [/^(vzdump-run|host-backup-run|arcane-backup-run|gcs-run|restic-check-run|restic-restore|restore-clean)\b/],
|
|
40
45
|
proxmox: [/^(set|snapshot-create|start)\b/],
|
package/package.json
CHANGED
package/skills/dns/SKILL.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dns
|
|
3
|
-
description: How the dns specialist operates Technitium (internal resolvers) and Cloudflare (public zones) through the dns tool.
|
|
3
|
+
description: How the dns specialist operates the Technitium cluster (internal resolvers at 37 and Mira) and Cloudflare (public zones) through the dns tool.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# DNS specialist
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The internal resolvers form one Technitium cluster, `dns.home.arpa`: the Primary node `technitium1` on Synapse (`10.0.40.53`), and the Secondary nodes `technitium2` (LXC 107 on Pulsar, `10.0.40.54`) and `technitium3` (LXC 100 on SPACE-X at Mira, `10.1.40.53`). The primary owns every zone; the configured catalog zone replicates them, and the cluster syncs settings, blocklists, allowed and blocked zones, apps, and users to the other nodes. Every call goes to the primary; `node <fqdn>` makes the primary run it on another node. Public names live in Cloudflare zones `37pla.net` and `monadeo.com`. The `dns` tool has two families; `["--help"]` lists everything.
|
|
9
9
|
|
|
10
|
-
## `technitium <
|
|
10
|
+
## `technitium primary <command>` and `technitium node <fqdn> <command>`
|
|
11
11
|
|
|
12
12
|
| Command | Effect |
|
|
13
13
|
|---|---|
|
|
@@ -16,23 +16,36 @@ Two resolvers serve the homelab: Technitium primary on Synapse (`10.0.40.53`) an
|
|
|
16
16
|
| `zone-options <zone>` | zone settings, including its catalog membership |
|
|
17
17
|
| `resolve <domain> [type]` | ask that resolver (default type `A`) |
|
|
18
18
|
| `stats [LastHour\|LastDay\|LastWeek\|LastMonth\|LastYear]` | dashboard counters |
|
|
19
|
+
| `cluster-state` | cluster domain, nodes with id, type, state, and last seen, and the server's addresses |
|
|
20
|
+
| `settings` | all server settings; secrets are redacted |
|
|
19
21
|
| `zone-create <zone>` (primary) | Primary zone in the catalog |
|
|
20
22
|
| `zone-delete <zone>` (primary) | deletes the zone and every record |
|
|
21
23
|
| `record-add <zone> <domain> <type> key=value...` (primary) | `/api/zones/records/add` |
|
|
22
24
|
| `record-update <zone> <domain> <type> key=value...` (primary) | `/api/zones/records/update` |
|
|
23
25
|
| `record-delete <zone> <domain> <type> key=value...` (primary) | `/api/zones/records/delete` |
|
|
26
|
+
| `cluster-init <clusterDomain> <ip[,ip]>` (primary) | make the primary the Primary node of a new cluster |
|
|
27
|
+
| `cluster-delete` (primary) | remove the cluster from the primary; refused while Secondary nodes exist |
|
|
28
|
+
| `cluster-remove <secondaryNodeId>` (primary) | ask a Secondary node (id from `cluster-state`) to leave |
|
|
29
|
+
| `server-domain <name>` (primary or node) | set that node's DNS Server Domain |
|
|
24
30
|
|
|
25
31
|
Record parameters by type (the API's names): `A`/`AAAA` `ipAddress` (update: `newIpAddress`); `CNAME` `cname`; `TXT` `text`; `MX` `exchange`, `preference`; `SRV` `priority`, `weight`, `port`, `target`; `NS` `nameServer`; `PTR` `ptrName`. `ttl=<seconds>` and `comments=<text>` apply to all; `overwrite=true` replaces the record set on add.
|
|
26
32
|
|
|
27
33
|
```json
|
|
28
34
|
{ "args": ["technitium", "primary", "records", "auth.37pla.net"] }
|
|
29
35
|
{ "args": ["technitium", "primary", "record-add", "kuma.37pla.net", "kuma.37pla.net", "A", "ipAddress=10.0.40.30", "ttl=300"] }
|
|
30
|
-
{ "args": ["technitium", "
|
|
36
|
+
{ "args": ["technitium", "node", "technitium3.dns.home.arpa", "resolve", "kuma.37pla.net"] }
|
|
37
|
+
{ "args": ["technitium", "primary", "cluster-state"] }
|
|
31
38
|
```
|
|
32
39
|
|
|
33
40
|
Every internal service name is its own Primary zone (`auth.37pla.net`, `kuma.37pla.net`, ...; 33 zones including `catalog.invalid` and the `orange.es` forwarder). There is no internal `37pla.net` zone: run `zones` first, then use the exact zone name, and create a new zone with `zone-create <fqdn>` before adding its records.
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
Zone, record, and cluster writes are refused with `node`. Replication is near-immediate; if a node still answers the old value after a minute, report it as a replication problem.
|
|
43
|
+
|
|
44
|
+
`technitium join <nodeUrl> <nodeIp>` adds a fresh node as a Secondary node: it refuses a node whose default `admin`/`admin` login was already changed, creates a one-time admin with a random password on the primary for the join, and deletes it afterwards. The join replaces the node's settings, blocklists, apps, and users with the primary's. Check `cluster-state` afterwards.
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{ "args": ["technitium", "join", "http://10.1.40.53:5380", "10.1.40.53"] }
|
|
48
|
+
```
|
|
36
49
|
|
|
37
50
|
Internal split DNS: public hostnames such as `auth.37pla.net` resolve to the DMZ (`10.0.20.10`) inside the homelab and to the VPS (`35.237.66.101`) outside.
|
|
38
51
|
|
package/specialists/AGENTS.md
CHANGED
|
@@ -43,7 +43,7 @@ Wrappers ship as TypeScript and run under Node 24 type stripping: erasable synta
|
|
|
43
43
|
- `network` reaches two consoles, `37` and `mira` (`SITES`), each with `unifi<Site>HostId`, `unifi<Site>LocalUrl`, and `unifi<Site>CertSha256` in `network.json`. `siteRequest` goes through the Site Manager cloud connector (`api.ui.com/v1/connector/consoles/<hostId>/network/integration/...`, account key `UNIFI_API_KEY`); a read the cloud cannot serve (no connection, 408, 429, 5xx) retries on the console itself with its local key (`UNIFI_LOCAL_37_API_KEY`, `UNIFI_LOCAL_MIRA_API_KEY`) through the pinned request, a write never retries because the cloud may have applied it before failing; `--local` skips the cloud. Writes are `unifiWrite`: any `POST`, `PUT`, `PATCH`, or `DELETE` under `/v1/sites/<siteId>/` with a JSON body (none for `DELETE`); UniFi validates the rest, and the gate asks the owner for every one. `unifi cloud <path>` reads the Site Manager API (`/v1/`, `/ea/`, never the connector). Each command reads only the config keys it needs, so `pulsar` works without the UniFi keys.
|
|
44
44
|
- Pi executes sibling tool calls in parallel, so two wrapper processes of the same specialist can run at once. `lib/lock.ts` (`withLock`, a directory lock under `~/.specialists/work/locks`, stale after 10 minutes) serialises shared resources; `edge` holds `edge-tunnel` around the fixed IAP port and the gcloud configuration directory. `arcane` holds `arcane-gitops` (stale after 3 hours) around `git`, `manager-upgrade`, and `stack-update`, because an update keeps the checkout for up to about two hours; the other `repo.ts` checkouts are not locked yet.
|
|
45
45
|
- `edge` retries one SSH call through the IAP tunnel when the first connection is closed during setup (`isTransientSshFailure`: exit 255 with "closed by remote host" or a reset), except `reboot`. The IAP tunnel is `lib/tunnel.ts`: `gcloud compute start-iap-tunnel <instance> 22 --local-host-port=localhost:<port>` (a documented flag; the hidden `--listen-on-stdin` is not used), ready when the port accepts a connection, closed after the ssh call. `gcloud auth activate-service-account` runs before every tunnel with `CLOUDSDK_CONFIG` under `~/.specialists/work/gcloud` and `CLOUDSDK_PYTHON` from the config, because the Homebrew cask ships no interpreter.
|
|
46
|
-
- `dns` builds every Technitium call from `TECHNITIUM_READS` and `TECHNITIUM_WRITES`; `key=value` record parameters pass through by name (`token` and `node` refused) because the API documents dozens of type-specific parameters.
|
|
46
|
+
- `dns` builds every Technitium call from `TECHNITIUM_READS` and `TECHNITIUM_WRITES`; `key=value` record parameters pass through by name (`token` and `node` refused) because the API documents dozens of type-specific parameters. Every call goes to the cluster primary with one token; `node <fqdn>` adds Technitium's `node` parameter so the primary runs a read or `server-domain` on that node. Zone, record, and cluster writes are refused with `node` in code: the catalog zone and the cluster are the only replication paths. `technitium join` joins a fresh node: it logs in with Technitium's default login (refused once changed), creates a one-time admin with a random password on the primary for `initJoin`, and deletes it in `finally`; no password is stored or printed.
|
|
47
47
|
- `security` parses Wazuh alert lines locally (`summariseWazuh`, `summariseVulns`) so the guest never needs `jq`; `wazuh-vulns`, `wazuh-events` (every non-vulnerability alert of the last N minutes at or above a level, with the alert id and the FIM path, change, and `sha256_after`; at most the newest 1000), and `wazuh-vuln-events` (every vulnerability finding, compact) are local views over the same `wazuh-alerts` dump, not guest commands. `alerts` adds each ban's whole length (time left plus the alert's age, to the hour), the escalated bans (longer than CrowdSec's default 4 hours), and the top countries and networks. The Discord bridge's security checks use these through the entry point (`extensions/astro-discord/security-monitor.ts`).
|
|
48
48
|
- `arcane change-origin <path> <sha256|-> <utc>` (`lib/change-origin.ts`) fetches origin, hashes the file in the newest 30 commits touching `<project>/<file>` up to 15 minutes after the change, and reads the last 16 MiB of the audit log for our `stack-update`, `manager-upgrade`, `manager-rollback`, or `host db-restore` on that stack (from a minute before its start to ten minutes after its end). It takes no checkout lock: like `update-report`'s holds read, it only fetches and reads objects, never the working tree. On 2026-10-21 the "Old md5sum" values of the live 100020 alerts matched the repository's previous Grimoire commits, which confirms that Arcane syncs these files verbatim.
|
|
49
49
|
- TLS pinning for self-signed consoles is `lib/pinned.ts` (`pinnedRequest`); `network` and `proxmox` use it with a `*CertSha256` config value obtained once through the wrapper's `fingerprint` command.
|
package/specialists/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A specialist is a Pi subagent that is the only way to operate one area of the ho
|
|
|
7
7
|
| `astro.arcane` | Arcane container platform (VM 100) and its GitOps repository | Every `arcane-cli` operation except its own `config`, `auth`, `self-update`; `update-report` (fresh check of every stack with running and latest release versions); `release-notes <stack>/<service>` (GitHub notes between the two versions); `change-origin <path> <sha256|-> <utc>` (whether a deployment-file change Wazuh saw is a GitOps commit or one of our operations); `project-status`, `deployment check|wait`; `stack-update <stack>` (a stack's pending image updates through GitOps, redeploy, checks, and rollback; across a major version only with `--confirm`, owner approval; held stacks in the repository's `update-holds.json` are refused); `manager-upgrade <version>` and `manager-rollback <stamp>` (the documented manager upgrade, owner approval); `host <command>`: sanitized host checks (memory, stats, logs, OOM, kernel OOM, audit, capacity, storage, Docker usage, service and queue checks) `db-list|db-dump|db-restore` for Mealie and Paperless, and `supabase-backup` (both Supabase databases, roles, and the pgsodium key) through user `spc-arcane` on VM 100; Compose changes of GitOps-managed projects through `git show|write|commit|push`, then `arcane-cli gitops` sync |
|
|
8
8
|
| `astro.identity` | Zitadel; Pomerium, nginx, lego on VM 104; `02-pulsar-proxmox/dmz/` in the homelab repository | Any Zitadel API call (v2, management, admin, auth) with responses redacted; `dmz status|journal|config-template|render|pomerium-restart|nginx-reload|lego-renew|deploy-config`; `git` on the homelab checkout, writes limited to `02-pulsar-proxmox/dmz/` |
|
|
9
9
|
| `astro.network` | UniFi consoles of sites 37 and Mira, FreeRADIUS (LXC 108), Tailscale (LXC 105) | Read and write everything the UniFi Network API offers on either console (cloud connector, local console as read fallback); Site Manager reads; RADIUS and Tailscale checks on Pulsar |
|
|
10
|
-
| `astro.dns` | Technitium primary
|
|
10
|
+
| `astro.dns` | Technitium cluster `dns.home.arpa` (primary `technitium1` on Synapse, `technitium2` in LXC 107, `technitium3` at Mira); Cloudflare zones `37pla.net`, `monadeo.com` | Read zones, records, settings, and cluster state on every node through the primary, resolve, stats; create and delete zones, add, update, delete records, initialize and delete the cluster, join a fresh node, remove a node, set a node's server domain; Cloudflare zones and record add, update, delete |
|
|
11
11
|
| `astro.edge` | Frontdoor VPS (`frontdoor-1337`) over an IAP tunnel; `00-frontdoor-vps/` in the homelab repository | `probe` the public path; `route-probe` (status of the Supabase, Grimoire, and Mealie public routes from Cortex); `vps status|nginx-conf|nginx-test|journal|wg|bouncer|updates|package|changelog|auto-upgrades|deploy-nginx|reboot --confirm`; `git` on the homelab checkout, writes limited to `00-frontdoor-vps/` |
|
|
12
12
|
| `astro.security` | Wazuh, CrowdSec, rsyslog archive on VM 106 | Read-only: `status`, `attention`, `agents`, `alerts`, `decisions`, `bouncers`, `metrics`, `wazuh-alerts`, `wazuh-vulns`, `wazuh-events`, `wazuh-vuln-events`, `wazuh-log`, `remote-hosts`, `remote-log`, `journal` |
|
|
13
13
|
| `astro.backup` | vzdump, the shared Restic repository (Pulsar host config, Arcane app backups), GCS offsite from LXC 102 | Status, journals, and manual runs of every layer; `restic-snapshots|stats|ls`, `restic-restore` into `/var/tmp/spc-restore` on Pulsar, `restore-clean` |
|
|
@@ -36,14 +36,14 @@ Host: Cortex (macOS on Apple silicon; Homebrew git; the specialists' Node, trend
|
|
|
36
36
|
- `arcane`: `ZITADEL_KEY_JSON`, `GITOPS_DEPLOY_KEY_B64`, `ZITADEL_USER_ID` (plain), `SSH_KEY_ARCANE_HOST_B64` (user `spc-arcane` on VM 100, for `host`, `manager-*`), and optionally `MEALIE_API_KEY` (only `host mealie-api` reads it).
|
|
37
37
|
- `identity`: `ZITADEL_PAT`, `SSH_KEY_DMZ_B64`, `HOMELAB_DEPLOY_KEY_B64`.
|
|
38
38
|
- `network`: `UNIFI_API_KEY` (account key: unifi.ui.com, Settings, API Keys), `UNIFI_LOCAL_37_API_KEY` and `UNIFI_LOCAL_MIRA_API_KEY` (each console: Network, Settings, Integrations), `SSH_KEY_PULSAR_B64`.
|
|
39
|
-
- `dns`: `TECHNITIUM_TOKEN
|
|
39
|
+
- `dns`: `TECHNITIUM_TOKEN` (API token of user `spc-dns` on the cluster primary), `CLOUDFLARE_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`.
|
|
40
40
|
- `edge`: `GCP_SA_KEY_JSON` (service account key), `SSH_KEY_FRONTDOOR_B64`, `HOMELAB_DEPLOY_KEY_B64`.
|
|
41
41
|
- `security`: `SSH_KEY_OBS_B64`.
|
|
42
42
|
- `backup`: `SSH_KEY_PULSAR_B64`, `SSH_KEY_ARCANE_B64`.
|
|
43
43
|
- `proxmox`: `PVE_TOKEN_ID` (plain, `spc-proxmox@pve!cortex`), `PVE_TOKEN_SECRET`, `SSH_KEY_PULSAR_B64`.
|
|
44
44
|
- `inference`: `SSH_KEY_NEXUS_B64`.
|
|
45
45
|
- `media`: `TMDB_ACCESS_TOKEN` (TMDB API Read Access Token), `OMDB_API_KEY`, `RADARR_API_KEY`, `SONARR_API_KEY` (Settings, General, Security; each app has one), `SABNZBD_API_KEY` (the API key, not the NZB key, which can only add NZBs and cannot read or pause the queue).
|
|
46
|
-
2. **Identities.** Zitadel (`https://auth.37pla.net/ui/console`): service user `spc-arcane` with Access Token Type JWT and a JSON key; service user `spc-identity` with a Personal Access Token and the Instance Owner role. Technitium (
|
|
46
|
+
2. **Identities.** Zitadel (`https://auth.37pla.net/ui/console`): service user `spc-arcane` with Access Token Type JWT and a JSON key; service user `spc-identity` with a Personal Access Token and the Instance Owner role. Technitium (cluster primary): user `spc-dns` in the Administrators group with an API token; the cluster syncs the user to every node. Cloudflare: an account-owned API token with `Zone:Read` and `DNS:Edit` on both zones. GCP project `frontdoor-1337`: service account `spc-edge` with `roles/iap.tunnelResourceAccessor` and `roles/compute.viewer`, JSON key. Proxmox (`ssh pulsar`): user `spc-proxmox@pve`, role `SpecialistGuest` = `VM.Audit VM.PowerMgmt VM.Snapshot VM.Snapshot.Rollback VM.Config.CPU VM.Config.Memory VM.Config.Options VM.Config.Network VM.Config.CDROM VM.GuestAgent.Audit`, ACLs `PVEAuditor` on `/` and `SpecialistGuest` on `/vms` for both the user and the token `spc-proxmox@pve!cortex` (`-privsep 1`).
|
|
47
47
|
3. **Services.** Arcane (Settings, Authentication, Federated Credentials): Issuer `https://auth.37pla.net`, Audience `387825541182390275`, Subject exact = `spc-arcane` user ID, Role Admin, Global, lifetime 300. UniFi: the account key and a local key per console (fields above) and policies on 37 allowing Cortex `10.0.40.37` to TCP 22 on `10.0.20.10`, `10.0.10.37`, `10.0.90.10`, TCP 5380 on `10.0.40.53`, `10.0.40.54`, TCP 8006 on `10.0.10.37`, and TCP 8081 on `10.0.60.5`. GitHub: `spc-arcane-gitops` as a write deploy key on `astronaute77/arcane`, `spc-edge-homelab` and `spc-identity-homelab` as write deploy keys on `astronaute77/homelab`.
|
|
48
48
|
4. **Sudo and user**, as an administrator:
|
|
49
49
|
```sh
|
|
@@ -73,7 +73,7 @@ Host: Cortex (macOS on Apple silicon; Homebrew git; the specialists' Node, trend
|
|
|
73
73
|
"homelabRemote": "git@github.com:astronaute77/homelab.git", "homelabBranch": "main", "repoArea": "02-pulsar-proxmox/dmz", "pomeriumConfig": "02-pulsar-proxmox/dmz/config.yaml" }
|
|
74
74
|
{ "unifi37HostId": "<from: specialist-cli network -- unifi cloud /v1/hosts>", "unifi37LocalUrl": "https://10.0.10.1/proxy/network/integration", "unifi37CertSha256": "<from: specialist-cli network -- unifi 37 fingerprint>",
|
|
75
75
|
"unifiMiraHostId": "<the same>", "unifiMiraLocalUrl": "https://192.168.1.1/proxy/network/integration", "unifiMiraCertSha256": "<the same>", "pulsarHost": "10.0.10.37", "pulsarUser": "root" }
|
|
76
|
-
{ "technitiumPrimaryUrl": "http://10.0.40.53:5380", "
|
|
76
|
+
{ "technitiumPrimaryUrl": "http://10.0.40.53:5380", "technitiumCatalog": "cluster-catalog.dns.home.arpa" }
|
|
77
77
|
{ "gcloud": "/usr/local/libexec/specialist-gcloud/current/bin/gcloud", "gcloudPython": "/usr/local/libexec/specialist-python/current/bin/python3",
|
|
78
78
|
"project": "frontdoor-1337", "zone": "us-east1-c", "instance": "frontdoor-1337", "serviceAccount": "spc-edge@frontdoor-1337.iam.gserviceaccount.com",
|
|
79
79
|
"iapLocalPort": 22337, "sshUser": "spc-edge", "publicIp": "35.237.66.101", "probeHost": "auth.37pla.net",
|
package/specialists/dns/run.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
1
2
|
import { readConfig } from "../lib/config.ts";
|
|
2
3
|
import { ServiceError, UsageError } from "../lib/errors.ts";
|
|
3
4
|
import { main } from "../lib/main.ts";
|
|
@@ -8,25 +9,30 @@ import { readSecret } from "../lib/secrets.ts";
|
|
|
8
9
|
const SERVICE = "dns";
|
|
9
10
|
|
|
10
11
|
interface DnsConfig extends Record<string, string> {
|
|
12
|
+
/** API of the cluster primary; every other node is reached through it with the `node` parameter. */
|
|
11
13
|
technitiumPrimaryUrl: string;
|
|
12
|
-
|
|
13
|
-
/** Catalog zone new primary zones join, so the secondary receives them. */
|
|
14
|
+
/** Catalog zone new primary zones join, so the other nodes receive them. */
|
|
14
15
|
technitiumCatalog: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const SHAPE = { technitiumPrimaryUrl: "string",
|
|
18
|
+
const SHAPE = { technitiumPrimaryUrl: "string", technitiumCatalog: "string" } as const;
|
|
18
19
|
|
|
19
20
|
const CLOUDFLARE_API = "https://api.cloudflare.com/client/v4";
|
|
20
21
|
const TIMEOUT_MS = 30_000;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** Below the gate's 60 s limit for the dns tool; a join transfers the primary's whole configuration. */
|
|
23
|
+
const JOIN_TIMEOUT_MS = 55_000;
|
|
24
|
+
/** Technitium's documented default login on a fresh install; a join replaces it with the primary's users. */
|
|
25
|
+
const DEFAULT_LOGIN = { user: "admin", pass: "admin" } as const;
|
|
26
|
+
const NODE_URL = /^https?:\/\/[0-9.]+:[0-9]{1,5}\/?$/;
|
|
27
|
+
const IPV4 = /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/;
|
|
24
28
|
|
|
25
29
|
const NAME = /^[A-Za-z0-9_.-]{1,253}$/;
|
|
26
30
|
const RECORD_TYPE = /^[A-Z0-9]{1,10}$/;
|
|
27
31
|
const PARAM_KEY = /^[a-zA-Z]{1,40}$/;
|
|
28
32
|
const STATS_TYPES = ["LastHour", "LastDay", "LastWeek", "LastMonth", "LastYear"];
|
|
29
33
|
const HEX_ID = /^[0-9a-f]{32}$/;
|
|
34
|
+
const NODE_ID = /^[0-9]{1,10}$/;
|
|
35
|
+
const IP_LIST = /^[0-9A-Fa-f:.]+(,[0-9A-Fa-f:.]+)*$/;
|
|
30
36
|
|
|
31
37
|
/** Technitium HTTP API reads, valid on both nodes. */
|
|
32
38
|
export const TECHNITIUM_READS: Readonly<Record<string, { args: [number, number]; help: string }>> = {
|
|
@@ -35,24 +41,33 @@ export const TECHNITIUM_READS: Readonly<Record<string, { args: [number, number];
|
|
|
35
41
|
"zone-options": { args: [1, 1], help: "zone-options <zone> zone settings, including its catalog" },
|
|
36
42
|
resolve: { args: [1, 2], help: "resolve <domain> [type] query this server (type default A)" },
|
|
37
43
|
stats: { args: [0, 1], help: `stats [${STATS_TYPES.join("|")}] dashboard counters` },
|
|
44
|
+
"cluster-state": { args: [0, 0], help: "cluster-state cluster nodes, their state, and this server's addresses" },
|
|
45
|
+
settings: { args: [0, 0], help: "settings all server settings (secrets redacted)" },
|
|
38
46
|
};
|
|
39
47
|
|
|
40
|
-
/** Technitium writes; the primary only, the
|
|
48
|
+
/** Technitium writes; zone and cluster writes on the primary only, the other nodes follow through the catalog and the cluster. */
|
|
41
49
|
export const TECHNITIUM_WRITES: Readonly<Record<string, { args: [number, number]; help: string }>> = {
|
|
42
50
|
"zone-create": { args: [1, 1], help: "zone-create <zone> Primary zone, member of the configured catalog" },
|
|
43
51
|
"zone-delete": { args: [1, 1], help: "zone-delete <zone> delete a zone and every record in it" },
|
|
44
52
|
"record-add": { args: [3, 40], help: "record-add <zone> <domain> <type> <key=value>... e.g. ipAddress=10.0.40.99 ttl=300" },
|
|
45
53
|
"record-update": { args: [3, 40], help: "record-update <zone> <domain> <type> <key=value>... e.g. ipAddress=10.0.40.99 newIpAddress=10.0.40.98" },
|
|
46
54
|
"record-delete": { args: [3, 40], help: "record-delete <zone> <domain> <type> <key=value>... e.g. ipAddress=10.0.40.99" },
|
|
55
|
+
"cluster-init": { args: [2, 2], help: "cluster-init <clusterDomain> <ip[,ip]> make the primary the Primary node of a new cluster" },
|
|
56
|
+
"cluster-delete": { args: [0, 0], help: "cluster-delete remove the cluster from the primary (only without Secondary nodes)" },
|
|
57
|
+
"cluster-remove": { args: [1, 1], help: "cluster-remove <secondaryNodeId> ask a Secondary node to leave the cluster" },
|
|
58
|
+
"server-domain": { args: [1, 1], help: "server-domain <name> DNS Server Domain of the target node (also with node)" },
|
|
47
59
|
};
|
|
48
60
|
|
|
49
61
|
const HELP = `dns specialist
|
|
50
62
|
|
|
51
|
-
technitium
|
|
63
|
+
technitium primary <command> [args] the cluster primary
|
|
64
|
+
technitium node <fqdn> <command> [args] another cluster node, through the primary (reads and server-domain)
|
|
65
|
+
technitium join <nodeUrl> <nodeIp> join a fresh node (default login) as a Secondary node, e.g. http://10.1.40.53:5380 10.1.40.53
|
|
66
|
+
reads:
|
|
52
67
|
${Object.values(TECHNITIUM_READS)
|
|
53
68
|
.map((r) => ` ${r.help}`)
|
|
54
69
|
.join("\n")}
|
|
55
|
-
|
|
70
|
+
writes (primary; the other nodes follow through the catalog zone and the cluster):
|
|
56
71
|
${Object.values(TECHNITIUM_WRITES)
|
|
57
72
|
.map((w) => ` ${w.help}`)
|
|
58
73
|
.join("\n")}
|
|
@@ -67,7 +82,8 @@ ${Object.values(TECHNITIUM_WRITES)
|
|
|
67
82
|
export interface TechnitiumRequest {
|
|
68
83
|
path: string;
|
|
69
84
|
params: Record<string, string>;
|
|
70
|
-
|
|
85
|
+
/** Refused when another node is targeted. */
|
|
86
|
+
primaryOnly: boolean;
|
|
71
87
|
}
|
|
72
88
|
|
|
73
89
|
export function assertName(value: string | undefined, what: string): string {
|
|
@@ -97,28 +113,28 @@ export function technitiumRequest(catalog: string, args: string[]): TechnitiumRe
|
|
|
97
113
|
}
|
|
98
114
|
switch (name) {
|
|
99
115
|
case "zones":
|
|
100
|
-
return { path: "/api/zones/list", params: rest[0] === undefined ? {} : { filterName: rest[0] },
|
|
116
|
+
return { path: "/api/zones/list", params: rest[0] === undefined ? {} : { filterName: rest[0] }, primaryOnly: false };
|
|
101
117
|
case "records": {
|
|
102
118
|
const zone = assertName(rest[0], "zone");
|
|
103
119
|
const domain = rest[1] === undefined ? zone : assertName(rest[1], "domain");
|
|
104
|
-
return { path: "/api/zones/records/get", params: { domain, zone, listZone: rest[1] === undefined ? "true" : "false" },
|
|
120
|
+
return { path: "/api/zones/records/get", params: { domain, zone, listZone: rest[1] === undefined ? "true" : "false" }, primaryOnly: false };
|
|
105
121
|
}
|
|
106
122
|
case "zone-options":
|
|
107
|
-
return { path: "/api/zones/options/get", params: { zone: assertName(rest[0], "zone") },
|
|
123
|
+
return { path: "/api/zones/options/get", params: { zone: assertName(rest[0], "zone") }, primaryOnly: false };
|
|
108
124
|
case "resolve": {
|
|
109
125
|
const type = rest[1] ?? "A";
|
|
110
126
|
if (!RECORD_TYPE.test(type)) throw new UsageError("type must be a record type such as A, AAAA, CNAME, TXT");
|
|
111
|
-
return { path: "/api/dnsClient/resolve", params: { server: "this-server", domain: assertName(rest[0], "domain"), type },
|
|
127
|
+
return { path: "/api/dnsClient/resolve", params: { server: "this-server", domain: assertName(rest[0], "domain"), type }, primaryOnly: false };
|
|
112
128
|
}
|
|
113
129
|
case "stats": {
|
|
114
130
|
const type = rest[0] ?? "LastHour";
|
|
115
131
|
if (!STATS_TYPES.includes(type)) throw new UsageError(`stats type must be one of ${STATS_TYPES.join(", ")}`);
|
|
116
|
-
return { path: "/api/dashboard/stats/get", params: { type },
|
|
132
|
+
return { path: "/api/dashboard/stats/get", params: { type }, primaryOnly: false };
|
|
117
133
|
}
|
|
118
134
|
case "zone-create":
|
|
119
|
-
return { path: "/api/zones/create", params: { zone: assertName(rest[0], "zone"), type: "Primary", catalog },
|
|
135
|
+
return { path: "/api/zones/create", params: { zone: assertName(rest[0], "zone"), type: "Primary", catalog }, primaryOnly: true };
|
|
120
136
|
case "zone-delete":
|
|
121
|
-
return { path: "/api/zones/delete", params: { zone: assertName(rest[0], "zone") },
|
|
137
|
+
return { path: "/api/zones/delete", params: { zone: assertName(rest[0], "zone") }, primaryOnly: true };
|
|
122
138
|
case "record-add":
|
|
123
139
|
case "record-update":
|
|
124
140
|
case "record-delete": {
|
|
@@ -129,8 +145,27 @@ export function technitiumRequest(catalog: string, args: string[]): TechnitiumRe
|
|
|
129
145
|
for (const fixed of ["zone", "domain", "type"]) {
|
|
130
146
|
if (fixed in params) throw new UsageError(`${fixed} is a positional argument`);
|
|
131
147
|
}
|
|
132
|
-
return { path: `/api/zones/records/${name.slice("record-".length)}`, params: { ...params, zone, domain, type: rest[2] },
|
|
148
|
+
return { path: `/api/zones/records/${name.slice("record-".length)}`, params: { ...params, zone, domain, type: rest[2] }, primaryOnly: true };
|
|
149
|
+
}
|
|
150
|
+
case "cluster-state":
|
|
151
|
+
return { path: "/api/admin/cluster/state", params: { includeServerIpAddresses: "true" }, primaryOnly: false };
|
|
152
|
+
case "settings":
|
|
153
|
+
return { path: "/api/settings/get", params: {}, primaryOnly: false };
|
|
154
|
+
case "cluster-init": {
|
|
155
|
+
if (!IP_LIST.test(rest[1])) throw new UsageError("cluster-init needs a comma separated list of IP addresses");
|
|
156
|
+
return {
|
|
157
|
+
path: "/api/admin/cluster/init",
|
|
158
|
+
params: { clusterDomain: assertName(rest[0], "clusterDomain"), primaryNodeIpAddresses: rest[1] },
|
|
159
|
+
primaryOnly: true,
|
|
160
|
+
};
|
|
133
161
|
}
|
|
162
|
+
case "cluster-delete":
|
|
163
|
+
return { path: "/api/admin/cluster/primary/delete", params: { forceDelete: "false" }, primaryOnly: true };
|
|
164
|
+
case "cluster-remove":
|
|
165
|
+
if (!NODE_ID.test(rest[0])) throw new UsageError("cluster-remove needs the numeric Secondary node id from cluster-state");
|
|
166
|
+
return { path: "/api/admin/cluster/primary/removeSecondary", params: { secondaryNodeId: rest[0] }, primaryOnly: true };
|
|
167
|
+
case "server-domain":
|
|
168
|
+
return { path: "/api/settings/set", params: { dnsServerDomain: assertName(rest[0], "server domain") }, primaryOnly: false };
|
|
134
169
|
default:
|
|
135
170
|
throw new UsageError(`unknown technitium command: ${name}`);
|
|
136
171
|
}
|
|
@@ -140,32 +175,105 @@ interface TechnitiumResponse {
|
|
|
140
175
|
status?: string;
|
|
141
176
|
errorMessage?: string;
|
|
142
177
|
response?: unknown;
|
|
178
|
+
/** Set by the login call only. */
|
|
179
|
+
token?: string;
|
|
143
180
|
}
|
|
144
181
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
157
|
-
});
|
|
182
|
+
interface ClusterNode {
|
|
183
|
+
url: string;
|
|
184
|
+
ipAddresses?: string[];
|
|
185
|
+
type: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** POSTs a form to a Technitium API and returns the parsed body; `what` names the server in errors. */
|
|
189
|
+
async function technitiumCall(base: string, path: string, params: Record<string, string>, token: string | undefined, what: string, timeoutMs = TIMEOUT_MS): Promise<TechnitiumResponse> {
|
|
190
|
+
const headers: Record<string, string> = { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" };
|
|
191
|
+
if (token !== undefined) headers.Authorization = `Bearer ${token}`;
|
|
192
|
+
const response = await fetch(new URL(path, base), { method: "POST", headers, body: new URLSearchParams(params), signal: AbortSignal.timeout(timeoutMs) });
|
|
158
193
|
const text = await response.text();
|
|
159
194
|
let parsed: TechnitiumResponse;
|
|
160
195
|
try {
|
|
161
196
|
parsed = JSON.parse(text) as TechnitiumResponse;
|
|
162
197
|
} catch {
|
|
163
|
-
throw new ServiceError(`Technitium ${
|
|
198
|
+
throw new ServiceError(`Technitium ${what} answered ${response.status} with a non-JSON body`);
|
|
164
199
|
}
|
|
165
200
|
if (parsed.status !== "ok") {
|
|
166
|
-
throw new ServiceError(`Technitium ${
|
|
201
|
+
throw new ServiceError(`Technitium ${what}: ${parsed.status ?? response.status}${parsed.errorMessage ? `: ${parsed.errorMessage}` : ""}`);
|
|
202
|
+
}
|
|
203
|
+
return parsed;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function parseJoinArgs(args: string[]): { nodeUrl: string; nodeIp: string } {
|
|
207
|
+
if (args.length !== 2 || !NODE_URL.test(args[0]) || !IPV4.test(args[1])) {
|
|
208
|
+
throw new UsageError("technitium join <nodeUrl> <nodeIp>, e.g. http://10.1.40.53:5380 10.1.40.53");
|
|
209
|
+
}
|
|
210
|
+
return { nodeUrl: args[0], nodeIp: args[1] };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Joins a fresh node to the cluster. Technitium's join runs on the joining node and needs an admin session there plus an admin
|
|
215
|
+
* username and password of the primary, so a one-time admin with a random password exists on the primary only during the call.
|
|
216
|
+
*/
|
|
217
|
+
async function join(config: DnsConfig, args: string[]): Promise<number> {
|
|
218
|
+
const { nodeUrl, nodeIp } = parseJoinArgs(args);
|
|
219
|
+
const status = await fetch(new URL("/api/status", nodeUrl), { signal: AbortSignal.timeout(TIMEOUT_MS) }).then((r) => r.json() as Promise<{ hasDefaultCredentials?: boolean }>);
|
|
220
|
+
if (status.hasDefaultCredentials !== true) throw new UsageError(`${nodeUrl} no longer has the default login; joining a configured node stays an owner task`);
|
|
221
|
+
const session = await technitiumCall(nodeUrl, "/api/user/login", DEFAULT_LOGIN, undefined, "joining node");
|
|
222
|
+
if (session.token === undefined) throw new ServiceError("joining node returned no session token");
|
|
223
|
+
|
|
224
|
+
const token = readSecret(SERVICE, "TECHNITIUM_TOKEN");
|
|
225
|
+
const state = await technitiumCall(config.technitiumPrimaryUrl, "/api/admin/cluster/state", {}, token, "primary");
|
|
226
|
+
const primary = ((state.response as { nodes?: ClusterNode[] } | undefined)?.nodes ?? []).find((n) => n.type === "Primary");
|
|
227
|
+
const primaryIp = primary?.ipAddresses?.[0];
|
|
228
|
+
if (primary === undefined || primaryIp === undefined) throw new ServiceError("the primary reports no initialized cluster");
|
|
229
|
+
|
|
230
|
+
const user = `spc-join-${randomBytes(4).toString("hex")}`;
|
|
231
|
+
const pass = randomBytes(24).toString("base64url");
|
|
232
|
+
await technitiumCall(config.technitiumPrimaryUrl, "/api/admin/users/create", { user, pass, displayName: "one-time cluster join" }, token, "primary");
|
|
233
|
+
try {
|
|
234
|
+
await technitiumCall(config.technitiumPrimaryUrl, "/api/admin/users/set", { user, memberOfGroups: "Administrators" }, token, "primary");
|
|
235
|
+
const joined = await technitiumCall(
|
|
236
|
+
nodeUrl,
|
|
237
|
+
"/api/admin/cluster/initJoin",
|
|
238
|
+
{
|
|
239
|
+
secondaryNodeIpAddresses: nodeIp,
|
|
240
|
+
primaryNodeUrl: primary.url,
|
|
241
|
+
primaryNodeIpAddress: primaryIp,
|
|
242
|
+
ignoreCertificateErrors: "true",
|
|
243
|
+
primaryNodeUsername: user,
|
|
244
|
+
primaryNodePassword: pass,
|
|
245
|
+
},
|
|
246
|
+
session.token,
|
|
247
|
+
"joining node",
|
|
248
|
+
JOIN_TIMEOUT_MS,
|
|
249
|
+
);
|
|
250
|
+
printJson({ node: nodeUrl, status: joined.status, response: redactSecrets(joined.response ?? null) });
|
|
251
|
+
} finally {
|
|
252
|
+
await technitiumCall(config.technitiumPrimaryUrl, "/api/admin/users/delete", { user }, token, "primary");
|
|
253
|
+
}
|
|
254
|
+
return 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Splits `primary <command>` or `node <fqdn> <command>` into the target node (undefined for the primary) and the command. */
|
|
258
|
+
export function technitiumTarget(args: string[]): { node: string | undefined; rest: string[] } {
|
|
259
|
+
if (args[0] === "primary") return { node: undefined, rest: args.slice(1) };
|
|
260
|
+
if (args[0] === "node") {
|
|
261
|
+
const node = assertName(args[1], "node");
|
|
262
|
+
if (!node.includes(".")) throw new UsageError("node must be the node's domain name, e.g. technitium2.dns.home.arpa");
|
|
263
|
+
return { node, rest: args.slice(2) };
|
|
167
264
|
}
|
|
168
|
-
|
|
265
|
+
throw new UsageError("technitium primary <command> [args] | technitium node <fqdn> <command> [args]");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async function technitium(config: DnsConfig, args: string[]): Promise<number> {
|
|
269
|
+
if (args[0] === "join") return join(config, args.slice(1));
|
|
270
|
+
const { node, rest } = technitiumTarget(args);
|
|
271
|
+
const request = technitiumRequest(config.technitiumCatalog, rest);
|
|
272
|
+
if (node !== undefined && request.primaryOnly) throw new UsageError("zone and cluster writes go to the primary; the other nodes follow through the catalog zone and the cluster");
|
|
273
|
+
const params = node === undefined ? request.params : { ...request.params, node };
|
|
274
|
+
const target = node ?? "primary";
|
|
275
|
+
const parsed = await technitiumCall(config.technitiumPrimaryUrl, request.path, params, readSecret(SERVICE, "TECHNITIUM_TOKEN"), target);
|
|
276
|
+
printJson({ node: target, status: parsed.status, response: redactSecrets(parsed.response ?? null) });
|
|
169
277
|
return 0;
|
|
170
278
|
}
|
|
171
279
|
|
|
@@ -4,7 +4,7 @@ import { join } from "node:path";
|
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { refusedPrefix, command as arcaneCommand } from "./arcane/run.ts";
|
|
6
6
|
import { buildBackupRemote, command as backupCommand } from "./backup/run.ts";
|
|
7
|
-
import { parseParams, parseRecordFilters, technitiumRequest, command as dnsCommand } from "./dns/run.ts";
|
|
7
|
+
import { parseJoinArgs, parseParams, parseRecordFilters, technitiumRequest, technitiumTarget, command as dnsCommand } from "./dns/run.ts";
|
|
8
8
|
import { buildVpsRemote, command as edgeCommand, isTransientSshFailure, PUBLIC_ROUTES, routeProbe } from "./edge/run.ts";
|
|
9
9
|
import { API_PREFIXES, buildDmzRemote, validateApiPath, command as identityCommand } from "./identity/run.ts";
|
|
10
10
|
import { buildInferenceRemote, command as inferenceCommand } from "./inference/run.ts";
|
|
@@ -163,12 +163,12 @@ describe("network wrapper", () => {
|
|
|
163
163
|
|
|
164
164
|
describe("dns wrapper", () => {
|
|
165
165
|
it("maps technitium commands to documented API paths", () => {
|
|
166
|
-
expect(technitiumRequest("catalog.invalid", ["zones"])).toEqual({ path: "/api/zones/list", params: {},
|
|
167
|
-
expect(technitiumRequest("catalog.invalid", ["zones", "*.37pla.net"])).toEqual({ path: "/api/zones/list", params: { filterName: "*.37pla.net" },
|
|
166
|
+
expect(technitiumRequest("catalog.invalid", ["zones"])).toEqual({ path: "/api/zones/list", params: {}, primaryOnly: false });
|
|
167
|
+
expect(technitiumRequest("catalog.invalid", ["zones", "*.37pla.net"])).toEqual({ path: "/api/zones/list", params: { filterName: "*.37pla.net" }, primaryOnly: false });
|
|
168
168
|
expect(technitiumRequest("catalog.invalid", ["records", "37pla.net"])).toEqual({
|
|
169
169
|
path: "/api/zones/records/get",
|
|
170
170
|
params: { domain: "37pla.net", zone: "37pla.net", listZone: "true" },
|
|
171
|
-
|
|
171
|
+
primaryOnly: false,
|
|
172
172
|
});
|
|
173
173
|
expect(technitiumRequest("catalog.invalid", ["records", "37pla.net", "kuma.37pla.net"]).params.listZone).toBe("false");
|
|
174
174
|
expect(technitiumRequest("catalog.invalid", ["resolve", "auth.37pla.net"]).params).toEqual({ server: "this-server", domain: "auth.37pla.net", type: "A" });
|
|
@@ -176,16 +176,43 @@ describe("dns wrapper", () => {
|
|
|
176
176
|
expect(technitiumRequest("catalog.invalid", ["zone-create", "lab.test"])).toEqual({
|
|
177
177
|
path: "/api/zones/create",
|
|
178
178
|
params: { zone: "lab.test", type: "Primary", catalog: "catalog.invalid" },
|
|
179
|
-
|
|
179
|
+
primaryOnly: true,
|
|
180
180
|
});
|
|
181
181
|
expect(technitiumRequest("catalog.invalid", ["record-add", "37pla.net", "kuma.37pla.net", "A", "ipAddress=10.0.40.30", "ttl=300"])).toEqual({
|
|
182
182
|
path: "/api/zones/records/add",
|
|
183
183
|
params: { ipAddress: "10.0.40.30", ttl: "300", zone: "37pla.net", domain: "kuma.37pla.net", type: "A" },
|
|
184
|
-
|
|
184
|
+
primaryOnly: true,
|
|
185
185
|
});
|
|
186
186
|
expect(technitiumRequest("catalog.invalid", ["record-delete", "37pla.net", "kuma.37pla.net", "A", "ipAddress=10.0.40.30"]).path).toBe("/api/zones/records/delete");
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
+
it("maps cluster and settings commands", () => {
|
|
190
|
+
expect(technitiumRequest("c", ["cluster-state"])).toEqual({ path: "/api/admin/cluster/state", params: { includeServerIpAddresses: "true" }, primaryOnly: false });
|
|
191
|
+
expect(technitiumRequest("c", ["settings"])).toEqual({ path: "/api/settings/get", params: {}, primaryOnly: false });
|
|
192
|
+
expect(technitiumRequest("c", ["cluster-init", "dns.home.arpa", "10.0.40.53"])).toEqual({
|
|
193
|
+
path: "/api/admin/cluster/init",
|
|
194
|
+
params: { clusterDomain: "dns.home.arpa", primaryNodeIpAddresses: "10.0.40.53" },
|
|
195
|
+
primaryOnly: true,
|
|
196
|
+
});
|
|
197
|
+
expect(technitiumRequest("c", ["cluster-delete"]).params).toEqual({ forceDelete: "false" });
|
|
198
|
+
expect(technitiumRequest("c", ["cluster-remove", "811905692"]).params).toEqual({ secondaryNodeId: "811905692" });
|
|
199
|
+
expect(technitiumRequest("c", ["server-domain", "technitium1"])).toEqual({ path: "/api/settings/set", params: { dnsServerDomain: "technitium1" }, primaryOnly: false });
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("targets the primary or another node by domain name", () => {
|
|
203
|
+
expect(technitiumTarget(["primary", "zones"])).toEqual({ node: undefined, rest: ["zones"] });
|
|
204
|
+
expect(technitiumTarget(["node", "technitium2.dns.home.arpa", "zones"])).toEqual({ node: "technitium2.dns.home.arpa", rest: ["zones"] });
|
|
205
|
+
expect(() => technitiumTarget(["secondary", "zones"])).toThrow(UsageError);
|
|
206
|
+
expect(() => technitiumTarget(["node", "technitium2", "zones"])).toThrow(/domain name/);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("validates join arguments", () => {
|
|
210
|
+
expect(parseJoinArgs(["http://10.1.40.53:5380", "10.1.40.53"])).toEqual({ nodeUrl: "http://10.1.40.53:5380", nodeIp: "10.1.40.53" });
|
|
211
|
+
expect(() => parseJoinArgs(["http://evil.example:5380", "10.1.40.53"])).toThrow(UsageError);
|
|
212
|
+
expect(() => parseJoinArgs(["http://10.1.40.53:5380", "10.1.40.53,10.0.40.1"])).toThrow(UsageError);
|
|
213
|
+
expect(() => parseJoinArgs(["http://10.1.40.53:5380"])).toThrow(UsageError);
|
|
214
|
+
});
|
|
215
|
+
|
|
189
216
|
it("rejects malformed names, types, and parameters", () => {
|
|
190
217
|
expect(() => technitiumRequest("c", ["records", "bad zone"])).toThrow(/DNS name/);
|
|
191
218
|
expect(() => technitiumRequest("c", ["record-add", "z.test", "a.z.test", "a", "ipAddress=1.2.3.4"])).toThrow(/record type/);
|
|
@@ -194,7 +221,9 @@ describe("dns wrapper", () => {
|
|
|
194
221
|
expect(() => technitiumRequest("c", ["record-add", "z.test", "a.z.test", "A", "zone=other"])).toThrow(/positional/);
|
|
195
222
|
expect(() => technitiumRequest("c", ["stats", "Forever"])).toThrow(/stats type/);
|
|
196
223
|
expect(() => technitiumRequest("c", ["zone-delete"])).toThrow(/1 argument/);
|
|
197
|
-
expect(() => technitiumRequest("c", ["
|
|
224
|
+
expect(() => technitiumRequest("c", ["flush"])).toThrow(/unknown technitium command/);
|
|
225
|
+
expect(() => technitiumRequest("c", ["cluster-init", "dns.home.arpa", "10.0.40.53;rm"])).toThrow(/IP addresses/);
|
|
226
|
+
expect(() => technitiumRequest("c", ["cluster-remove", "node2"])).toThrow(/numeric/);
|
|
198
227
|
expect(parseParams(["comments=a=b"])).toEqual({ comments: "a=b" });
|
|
199
228
|
});
|
|
200
229
|
|