-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: dns interceptor ip ttl #3770
Conversation
This fixes so that the record lives at most ttl time since lookup by not refreshing the timeout when picked.
lib/interceptor/dns.js
Outdated
const records = { records: { 4: null, 6: null } } | ||
for (const record of addresses) { | ||
record.timestamp = timestamp | ||
record.ttl = opts.maxTTL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the record already contains a ttl
let's preserve it, otherwise default to maxTTL
.
On top, let's use the min from both values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added it.
How do you feel about expecting the record result to be in ms? dns.lookup
doesn't usually provide ttl. dns.resolve
does, but it's ttl, and other time properties, are in seconds.
https://nodejs.org/api/dns.html#dnsresolveanyhostname-callback
Take the minimum value between the record TTL and the maxTTL from options. The record TTL value is expected to be in ms even though the `dns.resolve` methods provide it in seconds. The reasons are that: * it avoids extra manipulation in the `setRecords` method * `dns.lookup` does not provide ttl * custom provided lookup method's using `dns.resolve` must be manipulated anyway by adding a value for the family.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This relates to...
How long time to cache the dns records from the dns interceptor.
Rationale
For how long time the dns records from the dns interceptor should live.
Changes
Set timestamp once on each resolved record and compare the ttl to that timestamp. If the record is too old, remove it.
Features
Bug Fixes
N/A
Breaking Changes and Deprecations
Status