Repository navigation
Add opt-in records endpoint with CNAME and SRV support - #122
Conversation
|
Thanks for the contribution. Interesting stuff! I'll have a look at this tomorrow afternoon! |
0xFelix
left a comment
There was a problem hiding this comment.
Looks good overall, thanks!
Added some comments. Could you prefix the commit with feat:?
|
While addressing the review I ran an additional review pass over the records endpoint and found a few issues in the new code, which are fixed in the updated commit as well:
I also noticed a few things that already exist on |
Parse IP addresses of the plain, nic and directadmin endpoints with a shared helper that rejects zones and unmaps IPv4-mapped IPv6 addresses, and pass the canonical address on instead of the raw input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: xhess <github@die-hessens.de>
0xFelix
left a comment
There was a problem hiding this comment.
Thanks! We're getting close. A few more comments, mostly nits apart from the SRV . target.
0xFelix
left a comment
There was a problem hiding this comment.
Thanks! Could you squash the fix commit into the feat commit? Two small comments otherwise.
Add /records/present and /records/cleanup, which accept A, AAAA, TXT, CNAME and SRV records. The endpoint is disabled by default. SRV values are appended to the record set unless a replace is requested, CNAME conflicts are rejected and RECORD_TYPES/recordTypes restricts the accepted types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: xhess <github@die-hessens.de>
|
Thanks for all the iterations! |
Summary
Adds a new, opt-in endpoint group
recordswith two endpoints:POST /records/presentPOST /records/cleanupBoth take a JSON body with
fqdn,typeandvalue. Supported types areA, AAAA, TXT, CNAME and SRV, so CNAME and SRV records can now be managed
through the proxy. The existing endpoints are unchanged and still only
accept A, AAAA and TXT.
The group is not enabled by default. It has to be listed explicitly via
endpointsin the config file orENDPOINTSin the environment, soexisting setups are not affected.
Behaviour
absolute (
target.example.com->target.example.com.). A CNAME at thezone apex is rejected.
presentreplaces an existing CNAME, since onlyone CNAME per name is allowed.
priority weight port target. Priority, weight andport must be 0-65535 and are normalized (
05060->5060); the targetis validated and made absolute, and
.is accepted as "service not available".
presentadds the record toan existing RRSet instead of replacing it, so several targets can share
one name (e.g. a primary and a backup server). Adding a record that
already exists is a no-op.
cleanupremoves only the matching record.endpoints.
Example:
Tests
pkg/middleware/bind_test.go.ENDPOINTSparsing and forrecordsbeing off bydefault in
pkg/config/config_test.go.tests/records_test.gofor creating, replacing(CNAME), adding (SRV, with and without a TTL change), skipping an
existing SRV record, cleanup of CNAME and SRV records, invalid input,
denied access (401) and the endpoint being disabled (404).
make lint,make testandmake functestpass.and an SRV record, adding a second SRV record to the same name,
re-sending an existing record (no-op, also with leading zeros), and
cleaning up single SRV and CNAME records. All results were verified on
the Hetzner nameservers.
🤖 Generated with Claude Code