Base Resource Record class for objects returned in answers, authorities and additional record DNS responses.
Esempio n. 1
0
        /// <summary>
        /// Add the given DNS resource record to the DNS cache.
        /// </summary>
        /// <param name="Domainname">The domain name.</param>
        /// <param name="Origin">The origin of the DNS resource record.</param>
        /// <param name="ResourceRecord">The DNS resource record to add.</param>
        public DNSCache Add(String Domainname,
                            IPSocket Origin,
                            ADNSResourceRecord ResourceRecord)
        {
            lock (_DNSCache)
            {
                DNSCacheEntry CacheEntry = null;

                //Debug.WriteLine("[" + DateTime.Now + "] Adding '" + Domainname + "' to the DNS cache!");

                if (!_DNSCache.TryGetValue(Domainname, out CacheEntry))
                {
                    _DNSCache.Add(Domainname, new DNSCacheEntry(
                                      DateTime.Now + TimeSpan.FromSeconds(ResourceRecord.TimeToLive.TotalSeconds / 2),
                                      DateTime.Now + ResourceRecord.TimeToLive,
                                      new DNSInfo(Origin:               Origin,
                                                  QueryId:              new Random().Next(),
                                                  IsAuthorativeAnswer:  false,
                                                  IsTruncated:          false,
                                                  RecursionDesired:     false,
                                                  RecursionAvailable:   false,
                                                  ResponseCode:         DNSResponseCodes.NoError,
                                                  Answers:              new ADNSResourceRecord[1] {
                        ResourceRecord
                    },
                                                  Authorities:          new ADNSResourceRecord[0],
                                                  AdditionalRecords:    new ADNSResourceRecord[0])));
                }

                else
                {
                    // ToDo: Merge of DNS responses!
                    Debug.WriteLine("[" + DateTime.Now + "] Resource record for '" + Domainname + "' already exists within the DNS cache!");
                }

                return(this);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Add the given DNS resource record to the DNS cache.
        /// </summary>
        /// <param name="Domainname">The domain name.</param>
        /// <param name="Origin">The origin of the DNS resource record.</param>
        /// <param name="ResourceRecord">The DNS resource record to add.</param>
        public DNSCache Add(String              Domainname,
                            IPSocket            Origin,
                            ADNSResourceRecord  ResourceRecord)
        {
            lock (_DNSCache)
            {

                DNSCacheEntry CacheEntry = null;

                //Debug.WriteLine("[" + DateTime.Now + "] Adding '" + Domainname + "' to the DNS cache!");

                if (!_DNSCache.TryGetValue(Domainname, out CacheEntry))
                    _DNSCache.Add(Domainname, new DNSCacheEntry(
                                                         DateTime.Now + TimeSpan.FromSeconds(ResourceRecord.TimeToLive.TotalSeconds / 2),
                                                         DateTime.Now + ResourceRecord.TimeToLive,
                                                         new DNSInfo(Origin:               Origin,
                                                                     QueryId:              new Random().Next(),
                                                                     IsAuthorativeAnswer:  false,
                                                                     IsTruncated:          false,
                                                                     RecursionDesired:     false,
                                                                     RecursionAvailable:   false,
                                                                     ResponseCode:         DNSResponseCodes.NoError,
                                                                     Answers:              new ADNSResourceRecord[1] { ResourceRecord },
                                                                     Authorities:          new ADNSResourceRecord[0],
                                                                     AdditionalRecords:    new ADNSResourceRecord[0])));

                else
                {

                    // ToDo: Merge of DNS responses!
                    Debug.WriteLine("[" + DateTime.Now + "] Resource record for '" + Domainname + "' already exists within the DNS cache!");

                }

                return this;

            }
        }
Esempio n. 3
0
 internal void AddAnswer(ADNSResourceRecord ResourceRecord)
 {
     this._Answers.Add(ResourceRecord);
 }
Esempio n. 4
0
 internal void AddAnswer(ADNSResourceRecord ResourceRecord)
 {
     this._Answers.Add(ResourceRecord);
 }