Beispiel #1
0
        /// <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);
            }
        }
Beispiel #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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 /// <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));
     }
 }
Beispiel #5
0
        /// <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;

            }
        }