Skip to content

Commit

Permalink
Merge pull request #63 from telekom-mms/feature/handle-dname-records-…
Browse files Browse the repository at this point in the history
…in-dnsproxy

Handle DNAME records in DNS Proxy
  • Loading branch information
hwipl authored Mar 25, 2024
2 parents 9b9b57a + a30bc5d commit b2c2524
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions internal/dnsproxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ func (p *Proxy) handleRequest(w dns.ResponseWriter, r *dns.Msg) {
"ttl": ttl,
}).Debug("DNS-Proxy received CNAME in reply")
p.watches.AddTemp(rr.Target, ttl)

case dns.TypeDNAME:
// DNAME record, store temporary watch
rr, ok := a.(*dns.DNAME)
if !ok {
log.Error("DNS-Proxy received invalid DNAME record in reply")
continue
}
log.WithFields(log.Fields{
"target": rr.Target,
"ttl": ttl,
}).Debug("DNS-Proxy received DNAME in reply")
p.watches.AddTemp(rr.Target, ttl)
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/dnsproxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ func TestProxyHandleRequest(t *testing.T) {
reply := &dns.Msg{}
reply.SetReply(r)

dname, _ := dns.NewRR("test.example.com 3600 IN DNAME example.com.")
cname, _ := dns.NewRR("test.example.com 3600 IN CNAME example.com.")
a, _ := dns.NewRR("example.com. 3600 IN A 127.0.0.1")
aaaa, _ := dns.NewRR("example.com. 3600 IN AAAA ::1")

reply.Answer = []dns.RR{cname, aaaa, a}
reply.Answer = []dns.RR{dname, cname, aaaa, a}
if err := w.WriteMsg(reply); err != nil {
log.WithError(err).Error("error sending reply")
}
Expand Down

0 comments on commit b2c2524

Please sign in to comment.