Skip to content

Add opt-in records endpoint with CNAME and SRV support - #121

Closed
xhess wants to merge 1 commit into
0xFelix:mainfrom
xhess:feat/cname-srv
Closed

xhess wants to merge 1 commit into
0xFelix:mainfrom
xhess:feat/cname-srv

Conversation

@xhess

@xhess xhess commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

Adds a new, opt-in endpoint group records with two endpoints:

  • POST /records/present
  • POST /records/cleanup

Both take a JSON body with fqdn, type and value. Supported types are
A, 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
endpoints in the config file or ENDPOINTS in the environment, so
existing setups are not affected.

Behaviour

  • CNAME: the target is validated as a hostname, lowercased and made
    absolute (target.example.com -> target.example.com.). A CNAME at the
    zone apex is rejected. present replaces an existing CNAME, since only
    one CNAME per name is allowed.
  • SRV: the value is priority weight port target. Priority, weight and
    port must be 0-65535 and are normalized (05060 -> 5060); the target
    is validated and made absolute, and .
    is accepted as "service not available". present adds the record to
    an 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. cleanup removes only the matching record.
  • A, AAAA, TXT: same validation and replace semantics as the existing
    endpoints.

Example:

curl -u user:pass -H 'Content-Type: application/json' \
  -d '{"fqdn":"_minecraft._tcp.survival.example.com","type":"SRV","value":"0 5 25565 mc1.example.com"}' \
  https://proxy.example.com/records/present

Tests

  • Unit tests for binding and validation of all record types in
    pkg/middleware/bind_test.go.
  • Unit tests for ENDPOINTS parsing and for records being off by
    default in pkg/config/config_test.go.
  • Functional tests in tests/records_test.go for 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 test and make functest pass.
  • Tested manually against the real Hetzner Cloud API: creating a CNAME
    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

Adds POST /records/present and /records/cleanup taking JSON fqdn, type
and value for A, AAAA, TXT, CNAME and SRV records. CNAME/SRV targets are
validated and made absolute. SRV records are added to an existing RRSet
instead of replacing it, so several targets can share one name. The
endpoint group is not enabled by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: xhess <github@die-hessens.de>
@xhess xhess closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant