Repository navigation
feat(dns): manage static DNS records - #12
Conversation
Add list, show, create, update, and delete for the controller's local static DNS records. Prefer the Integration DNS-policies API and fall back to v2 static-dns on older firmware. Co-authored-by: Cursor <[email protected]>
An update built from a v2 static-dns MX, TXT, or SRV record copied the stored TTL into the write, which validate then rejected even when the caller never passed --ttl. from_record now carries a TTL only for types that accept one. legacy_body stripped a trailing dot from every value, corrupting TXT data that ends in a dot. Only hostname-shaped values are stripped now. dns update resolves the second lookup by the id it already found rather than re-running name resolution, and the DNS absent-endpoint check reuses is_absent_legacy_endpoint instead of duplicating its markers.
|
Thanks for the PR, @MelonSmasher. Looks good! Merged. |
|
Follow-up on this: I pushed a change on top before releasing, in 0.4.3.
It needed no server flakiness to hit. Editing a record on v2 is now This does not affect the path you tested. On Network 10.6 update is still the native PUT on the Integration API, unchanged. The v2 fallback still lists, creates and deletes; only in-place update is refused there, and that is the one path the test plan left unchecked. One other fix in the same change: a record reporting a TTL of 0 was read as having no TTL, and the write path then substituted the 14400 default, so an update that never mentioned If you do have a v2-only controller and the delete-plus-create flow is awkward in practice, say so and I will look at it again. |
Summary
unifi dns list|show|create|update|deletefor the controller's local static DNS records (A, AAAA, CNAME, MX, TXT, SRV; NS can be listed and deleted).static-dnsAPI on older firmware. Domain-forward policies are omitted.dns deleteis confirmation-gated like the other destructive commands.Test plan
cargo test(full suite)cargo clippy --all-targets -- -D warningscargo fmt -- --checkdns list, create an A record, update its value, show by name, delete with--yes(also created and deleted AAAA, CNAME, MX, TXT, and SRV; raw policies matched what the CLI sent)dns deletewithout--yesexits 2 withkind: confirmation_requiredunifi schemapublishes the new commands, and--fieldsondns listrejects unknown namesMade with Cursor