Base Resource Record class for objects returned in answers, authorities and additional record DNS responses.
コード例 #1
0
ファイル: DNSCache.cs プロジェクト: bpaziaud/Hermod
        /// <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);
            }
        }
コード例 #2
0
ファイル: DNSCache.cs プロジェクト: Vanaheimr/Hermod
        /// <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;

            }
        }
コード例 #3
0
ファイル: DNSInfo.cs プロジェクト: Vanaheimr/Hermod
 internal void AddAnswer(ADNSResourceRecord ResourceRecord)
 {
     this._Answers.Add(ResourceRecord);
 }
コード例 #4
0
 internal void AddAnswer(ADNSResourceRecord ResourceRecord)
 {
     this._Answers.Add(ResourceRecord);
 }