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;
}