コード例 #1
0
ファイル: DNSCache.cs プロジェクト: bpaziaud/Hermod
        /// <summary>
        /// Add the given DNS information to the DNS cache.
        /// </summary>
        /// <param name="Domainname">The domain name.</param>
        /// <param name="DNSInformation">The DNS information to add.</param>
        public DNSCache Add(String Domainname,
                            DNSInfo DNSInformation)
        {
            lock (_DNSCache)
            {
                DNSCacheEntry CacheEntry = null;

                if (!_DNSCache.TryGetValue(Domainname, out CacheEntry))
                {
                    _DNSCache.Add(Domainname, new DNSCacheEntry(
                                      DateTime.Now + TimeSpan.FromSeconds(DNSInformation.Answers.First().TimeToLive.TotalSeconds / 2),
                                      DateTime.Now + DNSInformation.Answers.First().TimeToLive,
                                      DNSInformation));
                }

                else
                {
                    // ToDo: Merge of DNS responses!
                    _DNSCache[Domainname] = new DNSCacheEntry(
                        DateTime.Now + TimeSpan.FromSeconds(DNSInformation.Answers.First().TimeToLive.TotalSeconds / 2),
                        DateTime.Now + DNSInformation.Answers.First().TimeToLive,
                        DNSInformation);
                }

                return(this);
            }
        }
コード例 #2
0
 /// <summary>
 /// Create a new DNS cache entry.
 /// </summary>
 /// <param name="RefreshTime">The timestamp of the last refresh.</param>
 /// <param name="EndOfLife">The timestamp when this entry gets invalidated.</param>
 /// <param name="DNSInfo">The cached DNS information.</param>
 public DNSCacheEntry(DateTime RefreshTime,
                      DateTime EndOfLife,
                      DNSInfo DNSInfo)
 {
     this._RefreshTime = RefreshTime;
     this._EndOfLife   = EndOfLife;
     this._DNSInfo     = DNSInfo;
 }
コード例 #3
0
ファイル: DNSCacheEntry.cs プロジェクト: Vanaheimr/Hermod
 /// <summary>
 /// Create a new DNS cache entry.
 /// </summary>
 /// <param name="RefreshTime">The timestamp of the last refresh.</param>
 /// <param name="EndOfLife">The timestamp when this entry gets invalidated.</param>
 /// <param name="DNSInfo">The cached DNS information.</param>
 public DNSCacheEntry(DateTime  RefreshTime,
                      DateTime  EndOfLife,
                      DNSInfo   DNSInfo)
 {
     this._RefreshTime  = RefreshTime;
     this._EndOfLife    = EndOfLife;
     this._DNSInfo      = DNSInfo;
 }
コード例 #4
0
ファイル: DNSClient.cs プロジェクト: bpaziaud/Hermod
 /// <summary>
 /// Add a DNS cache entry.
 /// </summary>
 /// <param name="DomainName">The domain name.</param>
 /// <param name="DNSInformation">The DNS information</param>
 private void AddToCache(String DomainName,
                         DNSInfo DNSInformation)
 {
     if (DNSInformation.Answers != null)
     {
         DNSInformation.
         Answers.
         ForEach(ResourceRecord => _DNSCache.Add(DomainName,
                                                 DNSInformation.Origin,
                                                 ResourceRecord));
     }
 }
コード例 #5
0
ファイル: DNSCache.cs プロジェクト: Vanaheimr/Hermod
        /// <summary>
        /// Add the given DNS information to the DNS cache.
        /// </summary>
        /// <param name="Domainname">The domain name.</param>
        /// <param name="DNSInformation">The DNS information to add.</param>
        public DNSCache Add(String   Domainname,
                            DNSInfo  DNSInformation)
        {
            lock (_DNSCache)
            {

                DNSCacheEntry CacheEntry = null;

                if (!_DNSCache.TryGetValue(Domainname, out CacheEntry))
                    _DNSCache.Add(Domainname, new DNSCacheEntry(
                                                         DateTime.Now + TimeSpan.FromSeconds(DNSInformation.Answers.First().TimeToLive.TotalSeconds / 2),
                                                         DateTime.Now + DNSInformation.Answers.First().TimeToLive,
                                                         DNSInformation));

                else
                {
                    // ToDo: Merge of DNS responses!
                    _DNSCache[Domainname] = new DNSCacheEntry(
                                                       DateTime.Now + TimeSpan.FromSeconds(DNSInformation.Answers.First().TimeToLive.TotalSeconds / 2),
                                                       DateTime.Now + DNSInformation.Answers.First().TimeToLive,
                                                       DNSInformation);
                }

                return this;

            }
        }