Skip to content

Conversation

@gucci-on-fleek
Copy link
Collaborator

While replying to #161, I noticed that .RR() gives odd results for SRV and ServiceBinding records at the zone apex:

package main

import (
	"fmt"
	"time"

	"github.com/libdns/libdns"
)

func main() {
	records := []libdns.Record{
		libdns.ServiceBinding{
			Name:          "@",
			Scheme:        "examplescheme",
			URLSchemePort: 1234,
			TTL:           1 * time.Hour,
			Priority:      1,
			Target:        ".",
			Params:        libdns.SvcParams{},
		},
		libdns.SRV{
			Name:      "@",
			Service:   "exampleservice",
			Transport: "tcp",
			TTL:       1 * time.Hour,
			Priority:  1,
			Weight:    2,
			Target:    ".",
		},
	}

	rrs := make([]libdns.RR, len(records))
	for i, record := range records {
		rrs[i] = record.RR()
	}

	for _, rr := range rrs {
		fmt.Println(rr.Name)
	}
}
_1234._examplescheme.@
_exampleservice._tcp.@

libdns has no problem parsing names like _1234._examplescheme.@, but users would typically expect _1234._examplescheme instead, so I've updated the code to trim any .@ suffixes.

@gucci-on-fleek gucci-on-fleek requested a review from mholt April 19, 2025 06:52
Copy link
Contributor

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Nice catch.

@mholt mholt merged commit db2a2dd into libdns:master Apr 19, 2025
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.

2 participants