Skip to content

Commit

Permalink
update AAAA record lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
yabinma committed Sep 27, 2024
1 parent af45ae4 commit 5d47772
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dns/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"golang.org/x/exp/slog"
)

const (
ttlTimeout = 3600
)

var dnsMapMutex = sync.Mutex{} // used to mutex functions of the DNS

type DNSResolver struct {
Expand Down Expand Up @@ -77,7 +81,7 @@ func (d *DNSResolver) RegisterA(record dnsRecord) error {
defer dnsMapMutex.Unlock()

r := new(dns.A)
r.Hdr = dns.RR_Header{Name: dns.Fqdn(record.Name), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 3600}
r.Hdr = dns.RR_Header{Name: dns.Fqdn(record.Name), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: ttlTimeout}
r.A = net.ParseIP(record.RData)

d.DnsEntriesCacheStore[buildDNSEntryKey(record.Name, record.Type)] = r
Expand All @@ -92,11 +96,13 @@ func (d *DNSResolver) RegisterAAAA(record dnsRecord) error {
defer dnsMapMutex.Unlock()

r := new(dns.AAAA)
r.Hdr = dns.RR_Header{Name: record.Name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 3600}
r.Hdr = dns.RR_Header{Name: dns.Fqdn(record.Name), Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: ttlTimeout}
r.AAAA = net.ParseIP(record.RData)

d.DnsEntriesCacheStore[buildDNSEntryKey(record.Name, record.Type)] = r

slog.Info("registering AAAA record successfully", "Info", d.DnsEntriesCacheStore[buildDNSEntryKey(record.Name, record.Type)])

return nil
}

Expand Down

0 comments on commit 5d47772

Please sign in to comment.