-
-
Notifications
You must be signed in to change notification settings - Fork 674
fix: dns interceptor ip ttl #3770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ class DNSInstance { | |
| return | ||
| } | ||
|
|
||
| this.setRecords(origin, addresses) | ||
| this.setRecords(origin, newOpts, addresses) | ||
| const records = this.#records.get(origin.hostname) | ||
|
|
||
| const ip = this.pick( | ||
|
|
@@ -111,15 +111,9 @@ class DNSInstance { | |
| const results = new Map() | ||
|
|
||
| for (const addr of addresses) { | ||
| const record = { | ||
| address: addr.address, | ||
| ttl: opts.maxTTL, | ||
| family: addr.family | ||
| } | ||
|
|
||
| // On linux we found duplicates, we attempt to remove them with | ||
| // the latest record | ||
| results.set(`${record.address}:${record.family}`, record) | ||
| results.set(`${addr.address}:${addr.family}`, addr) | ||
| } | ||
|
|
||
| cb(null, results.values()) | ||
|
|
@@ -171,24 +165,24 @@ class DNSInstance { | |
| return ip | ||
| } | ||
|
|
||
| const timestamp = Date.now() | ||
| // Record TTL is already in ms | ||
| if (ip.timestamp != null && timestamp - ip.timestamp > ip.ttl) { | ||
| if (Date.now() - ip.timestamp > ip.ttl) { // record TTL is already in ms | ||
| // We delete expired records | ||
| // It is possible that they have different TTL, so we manage them individually | ||
| family.ips.splice(position, 1) | ||
| return this.pick(origin, hostnameRecords, affinity) | ||
| } | ||
|
|
||
| ip.timestamp = timestamp | ||
|
|
||
| this.lastIpFamily = newIpFamily | ||
| return ip | ||
| } | ||
|
|
||
| setRecords (origin, addresses) { | ||
| setRecords (origin, opts, addresses) { | ||
| const timestamp = Date.now() | ||
| const records = { records: { 4: null, 6: null } } | ||
| for (const record of addresses) { | ||
| record.timestamp = timestamp | ||
| record.ttl = opts.maxTTL | ||
|
||
|
|
||
| const familyRecords = records.records[record.family] ?? { ips: [] } | ||
|
|
||
| familyRecords.ips.push(record) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.