private void UpdateCacheStatus()
{
// Stop drawing the gamespy redirect section until we are ready
groupBox31.SuspendLayout();
bool GsIsFaulted = false;
// Resets Stats Address Boxes
if (Redirector.StatsServerAddress == null)
{
SSAddress1.Text = "Disabled";
SSAddress2.Text = "";
SStatus.Image = Resources.error;
}
// Resets Gamespy Address Boxes
if (Redirector.GamespyServerAddress == null)
{
GSAddress1.Text = "Disabled";
GSAddress2.Text = "";
GStatus.Image = Resources.error;
}
// Check Stats
foreach (DnsCacheResult Res in Redirector.DnsCacheReport.Entries.Values)
{
// Simplify this. If we got what we wanted, just display the supplied address
string addy = (Res.GotExpectedResult || Res.IsFaulted)
? Res.ExpectedAddress.ToString()
: Res.ResultAddresses[0].ToString();
// Stats Server
if (Res.HostName == Redirector.Bf2StatsHost)
{
if (Res.IsFaulted)
{
SSAddress1.Text = "Unable to fetch the stats server address from the Windows DNS Cache";
SSAddress2.Text = "";
SStatus.Image = Resources.error;
continue;
}
SSAddress1.Text = "Configured Address: " + Res.ExpectedAddress;
SSAddress2.Text = "Found Address: " + addy;
SStatus.Image = Res.GotExpectedResult ? Resources.check : Resources.warning;
}
else // Gamespy Server
{
// Quit if we have faulted
if (GsIsFaulted) continue;
GsIsFaulted = (Res.GotExpectedResult == false || Res.IsFaulted);
if (Res.IsFaulted)
{
GSAddress1.Text = "Unable to fetch one of the Gamespy server addresses from the Windows DNS Cache";
GSAddress2.Text = "";
GStatus.Image = Resources.error;
continue;
}
GSAddress1.Text = "Configured Address: " + Res.ExpectedAddress;
GSAddress2.Text = "Found Address: " + addy;
GStatus.Image = Res.GotExpectedResult ? Resources.check : Resources.warning;
}
}
// Update changes
groupBox31.ResumeLayout();
// Update Hosts Status Pic
if (Redirector.DnsCacheReport.ErrorFree)
{
HostsStatusPic.Image = Resources.check;
Tipsy.SetToolTip(HostsStatusPic, "Gamespy redirects are active and working");
}
else
{
HostsStatusPic.Image = Resources.warning;
Tipsy.SetToolTip(HostsStatusPic, "Gamespy redirects are NOT working");
}
}