Fix: DNS server returns the correct TTL
This commit is contained in:
@ -52,9 +52,16 @@ func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error) {
|
||||
}
|
||||
|
||||
q := m.Question[0]
|
||||
cache := r.cache.Get(q.String())
|
||||
cache, expireTime := r.cache.GetWithExpire(q.String())
|
||||
if cache != nil {
|
||||
return cache.(*D.Msg).Copy(), nil
|
||||
msg = cache.(*D.Msg).Copy()
|
||||
if len(msg.Answer) > 0 {
|
||||
ttl := uint32(expireTime.Sub(time.Now()).Seconds())
|
||||
for _, answer := range msg.Answer {
|
||||
answer.Header().Ttl = ttl
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if msg != nil {
|
||||
|
Reference in New Issue
Block a user