Skip to content

Commit

Permalink
handler: imp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Dec 27, 2024
1 parent f80639a commit 9f9870f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions internal/handler/constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ type messageConstructor interface {
NewCompressedResponse(req *dns.Msg, code int) (resp *dns.Msg)

// NewPTRAnswer creates a new resource record for PTR response with the
// given FQDN and PTR domain.
NewPTRAnswer(fqdn, ptrDomain string) (ans *dns.PTR)
// given FQDN and PTR domain. Arguments must be fully qualified domain
// names.
NewPTRAnswer(fqdn, ptrFQDN string) (ans *dns.PTR)

// NewIPResponse creates a new A/AAAA response message for req with the
// given IP addresses. All IP addresses must be of the same family.
Expand Down Expand Up @@ -48,10 +49,10 @@ func (defaultConstructor) NewCompressedResponse(req *dns.Msg, code int) (resp *d

// NewPTRAnswer implements the [messageConstructor] interface for
// [defaultConstructor].
func (defaultConstructor) NewPTRAnswer(fqdn, ptrDomain string) (ans *dns.PTR) {
func (defaultConstructor) NewPTRAnswer(fqdn, ptrFQDN string) (ans *dns.PTR) {
return &dns.PTR{
Hdr: hdr(fqdn, dns.TypePTR),
Ptr: dns.Fqdn(ptrDomain),
Ptr: dns.Fqdn(ptrFQDN),
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (h *Default) resolveFromHosts(ctx context.Context, req *dns.Msg) (resp *dns
resp = h.messages.NewCompressedResponse(req, dns.RcodeSuccess)
name = req.Question[0].Name
for _, ptr := range ptrs {
resp.Answer = append(resp.Answer, h.messages.NewPTRAnswer(name, ptr))
resp.Answer = append(resp.Answer, h.messages.NewPTRAnswer(name, dns.Fqdn(ptr)))
}
default:
h.logger.DebugContext(ctx, "no hosts records found", "name", name, "qtype", q.Qtype)
Expand Down

0 comments on commit 9f9870f

Please sign in to comment.