Chore: fix typos
This commit is contained in:
@@ -30,28 +30,25 @@ func withHosts(hosts *trie.DomainTrie[netip.Addr], mapping *cache.LruCache[strin
|
||||
return next(ctx, r)
|
||||
}
|
||||
|
||||
qName := strings.TrimRight(q.Name, ".")
|
||||
record := hosts.Search(qName)
|
||||
host := strings.TrimRight(q.Name, ".")
|
||||
|
||||
record := hosts.Search(host)
|
||||
if record == nil {
|
||||
return next(ctx, r)
|
||||
}
|
||||
|
||||
ip := record.Data
|
||||
if mapping != nil {
|
||||
mapping.SetWithExpire(ip.Unmap().String(), qName, time.Now().Add(time.Second*5))
|
||||
}
|
||||
|
||||
msg := r.Copy()
|
||||
|
||||
if ip.Is4() && q.Qtype == D.TypeA {
|
||||
rr := &D.A{}
|
||||
rr.Hdr = D.RR_Header{Name: q.Name, Rrtype: D.TypeA, Class: D.ClassINET, Ttl: 1}
|
||||
rr.Hdr = D.RR_Header{Name: q.Name, Rrtype: D.TypeA, Class: D.ClassINET, Ttl: 10}
|
||||
rr.A = ip.AsSlice()
|
||||
|
||||
msg.Answer = []D.RR{rr}
|
||||
} else if ip.Is6() && q.Qtype == D.TypeAAAA {
|
||||
rr := &D.AAAA{}
|
||||
rr.Hdr = D.RR_Header{Name: q.Name, Rrtype: D.TypeAAAA, Class: D.ClassINET, Ttl: 1}
|
||||
rr.Hdr = D.RR_Header{Name: q.Name, Rrtype: D.TypeAAAA, Class: D.ClassINET, Ttl: 10}
|
||||
rr.AAAA = ip.AsSlice()
|
||||
|
||||
msg.Answer = []D.RR{rr}
|
||||
@@ -59,6 +56,10 @@ func withHosts(hosts *trie.DomainTrie[netip.Addr], mapping *cache.LruCache[strin
|
||||
return next(ctx, r)
|
||||
}
|
||||
|
||||
if mapping != nil {
|
||||
mapping.SetWithExpire(ip.Unmap().String(), host, time.Now().Add(time.Second*10))
|
||||
}
|
||||
|
||||
ctx.SetType(context.DNSTypeHost)
|
||||
msg.SetRcode(r, D.RcodeSuccess)
|
||||
msg.Authoritative = true
|
||||
|
||||
Reference in New Issue
Block a user