looterz / grimd

:zap: fast dns proxy that can run anywhere, built to black-hole internet advertisements and malware servers
MIT License
1.38k stars 108 forks source link

Proper TTL support for DNS response #37

Closed emdioh closed 5 years ago

emdioh commented 6 years ago

I've changed the response cache to use the actual responses TTL for expiration. The Get() operation also updates the TTL field in the answer so that it is consistent with the expected expiration.

elico commented 6 years ago

@emdioh Looks pretty interesting. Was there a specific reason to use uint32 instead of uint? .. I am not sure if from memory perceptive it would be better. I hope that GoLang sort these memory thingies out at compilation time.

emdioh commented 6 years ago

I used uint32 because it's what dns.RR_Header uses uint for the ttl and I saw no reason to keep casting back and forth. uint is at least 32 bit, so this change will not increase the memory usage.

elico commented 6 years ago

@emdioh Thanks. I remembered that this is the data-structure but for some reason what is well understood to some is weird to others.

emdioh commented 6 years ago

@looterz wdyt?

looterz commented 5 years ago

Sorry that took awhile, thanks for the PR.