/// <summary> /// Adds or Updates a Dns Cache Result to the list of entries /// </summary> /// <param name="Result"></param> public void AddOrUpdate(DnsCacheResult Result) { // Add if the entry already exists if (Entries.ContainsKey(Result.HostName)) { Entries[Result.HostName] = Result; } else // Update entry { Entries.Add(Result.HostName, Result); } }
/// <summary> /// Queries the DNS Cache for the Gamespy hosts, and verifies that the /// IP addresses in the DNS Cache match that of the desired redirect IP /// </summary> public static bool VerifyDNSCache(IProgress <DnsCacheResult> Progress = null) { // Nothing to do here if redirects are disabled if (!RedirectsEnabled) { return(false); } // Grab our saved hosts file IP addresses if (RedirectMethod != RedirectMode.DnsServer) { // Grab hosts file base HostsFile hFile = (RedirectMethod == RedirectMode.HostsFile) ? HostsFileSys as HostsFile : HostsFileIcs as HostsFile; // Fetch our saved IPAddresses GamespyServerAddress = (hFile.HasEntry("master.gamespy.com")) ? hFile.Get("master.gamespy.com") : null; StatsServerAddress = (hFile.HasEntry(Bf2StatsHost)) ? hFile.Get(Bf2StatsHost) : null; } // Flush our cache report DnsCacheReport.Entries.Clear(); // Verify Gamespy Server IP addresses if (GamespyServerAddress != null) { foreach (string address in GamespyHosts) { // Create new report DnsCacheResult Result = new DnsCacheResult(address, GamespyServerAddress); // Add the result to the report DnsCacheReport.AddOrUpdate(Result); // Report progress if we have a progress object if (Progress != null) { Progress.Report(Result); } } } // Verify Stats Server address if (StatsServerAddress != null) { // Create new report DnsCacheResult Result = new DnsCacheResult(Bf2StatsHost, StatsServerAddress); // Add the result to the report DnsCacheReport.AddOrUpdate(Result); // Report progress if we have a progress object if (Progress != null) { Progress.Report(Result); } } // Set internal DnsCacheReport.LastRefresh = DateTime.Now; return(DnsCacheReport.ErrorFree); }