Beispiel #1
0
 public void RemoveExpiredRecords()
 {
     foreach (KeyValuePair <DnsResourceRecordType, IReadOnlyList <DnsResourceRecord> > entry in _entries)
     {
         if (DnsResourceRecord.IsRRSetStale(entry.Value))
         {
             _entries.TryRemove(entry.Key, out _); //RR Set is expired; remove entry
         }
     }
 }
Beispiel #2
0
            public void SetRecords(DnsResourceRecordType type, IReadOnlyList <DnsResourceRecord> records)
            {
                if ((records.Count > 0) && (records[0].RDATA is DnsSpecialCacheRecord splRecord) && splRecord.IsFailure)
                {
                    //call trying to cache failure record
                    if (_entries.TryGetValue(type, out IReadOnlyList <DnsResourceRecord> existingRecords))
                    {
                        if ((existingRecords.Count > 0) && !(existingRecords[0].RDATA is DnsSpecialCacheRecord existingSplRecord && existingSplRecord.IsFailure) && !DnsResourceRecord.IsRRSetStale(existingRecords))
                        {
                            return; //skip to avoid overwriting a useful record with a failure record
                        }
                    }
                }

                _entries[type] = records;
            }