MCPcopy
hub / github.com/nodejs/undici / setRecords

Method setRecords

lib/interceptor/dns.js:353–375  ·  view source on GitHub ↗
(origin, addresses)

Source from the content-addressed store, hash-verified

351 }
352
353 setRecords (origin, addresses) {
354 const timestamp = Date.now()
355 const records = { records: { 4: null, 6: null } }
356 let minTTL = this.#maxTTL
357 for (const record of addresses) {
358 record.timestamp = timestamp
359 if (typeof record.ttl === 'number') {
360 // The record TTL is expected to be in ms
361 record.ttl = Math.min(record.ttl, this.#maxTTL)
362 minTTL = Math.min(minTTL, record.ttl)
363 } else {
364 record.ttl = this.#maxTTL
365 }
366
367 const familyRecords = records.records[record.family] ?? { ips: [] }
368
369 familyRecords.ips.push(record)
370 records.records[record.family] = familyRecords
371 }
372
373 // We provide a default TTL if external storage will be used without TTL per record-level support
374 this.storage.set(origin.hostname, records, { ttl: minTTL })
375 }
376
377 deleteRecords (origin) {
378 this.storage.delete(origin.hostname)

Callers 1

runLookupMethod · 0.95

Calls 2

pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected