コード例 #1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (btnConnect.Text == "&Connect")
            {
                // Clear the log.
                tbData.Text = "";

                // Create a tester instance.
                tester = new HeimdallCheck();
                tester.SetAddress(tbAddress.Text, (ushort)numPort.Value);
                tester.SetLogin(tbUsername.Text, tbPassword.Text);

                // Before we connect, freeze the settings from further tampering.
                FreezeSettings();

                // Change the Connect/Disconnect button.
                btnConnect.Text = "&Disconnect";

                // Start the test and run the timer.
                UpdateStatus("Starting a heimdall test...");
                tester.Start();
                refreshTimer.Start();
            }
            else
            {
                txtPhase.Text = "Aborted";
                tester.Stop();
                btnConnect.Text = "&Connect";
                UpdateStatus("Test aborted!");
                StopTest();
            }
        }
コード例 #2
0
        /*** Helper Methods (PRIVATE) ***/
        private HeimdallCheck RunHeimdallCheck(string username, string password)
        {
            HeimdallCheck hc = new HeimdallCheck();

            hc.SetAddress(AppSettings.Address, AppSettings.Port);
            hc.SetLogin(username, password);
            hc.Start();
            nRequestsMade++;
            return(hc);
        }
コード例 #3
0
        /*** Methods ***/
        public void Start()
        {
            bReady = false;

            // Create an array for the right amount of heimdalls & init all.
            int nHeimdalls = AppSettings.HeimdallAmount;

            statusList = new HeimdallStatus[nHeimdalls];
            for (int i = 0; i < nHeimdalls; i++)
            {
                statusList[i].HasHeimdall   = false;
                statusList[i].HasHorton     = false;
                statusList[i].HasTribble    = false;
                statusList[i].HeimdallQTEMP = 0;
                statusList[i].HortonQTEMP   = 0;
                statusList[i].TribbleQTEMP  = 0;
                statusList[i].Hits          = 0;
            }

            // Determine the maximal amount of requests we should make.
            nMaxRequests = AppSettings.ConnectionAttempts;

            // Create a checklist and run the checks.
            HeimdallCheck[] cl        = new HeimdallCheck[AppSettings.UserAmount];
            string[]        usernames = new string[AppSettings.UserList.Count];
            AppSettings.UserList.Keys.CopyTo(usernames, 0);

            for (int i = 0; i < cl.Length; i++)
            {
                string username = usernames[i];
                string password = AppSettings.UserList[username];
                cl[i] = RunHeimdallCheck(username, password);
            }

            checkList = cl;
            // From here, use Update() periodically to keep things going.
        }
コード例 #4
0
        public void Update()
        {
            // If the lookup is ready, we have nothing to do here.
            if (bReady)
            {
                return;
            }

            // Go through each check and handle it.
            foreach (HeimdallCheck hdc in checkList)
            {
                // If the check is still running, let it run.
                if (hdc.Running)
                {
                    continue;
                }

                //-- From here, we assume that the check is complete.

                // If there was an error, log it and don't count the readings.
                if (hdc.Error)
                {
                    Errors.Add(String.Format("HDC[{0}] C.ATT#{1}: {2} (Heimdall {3}{4}{5})",
                                             hdc.Name,
                                             RequestsMade,
                                             hdc.ErrorMessage,
                                             hdc.HeimdallNumber,
                                             hdc.HasHorton ? "" : " <NOHORTON>",
                                             hdc.HasTribble ? "" : " <NOTRIBBLE>"
                                             ));
                }
                else
                {
                    // I'll store the number locally to save unnecessary property
                    // access. Properties seem to work like functions/methods.
                    int hdn = hdc.HeimdallNumber - 1;

                    // If this check managed to detect a heimdall number, consider
                    // the readings important.
                    if (hdn >= 0)
                    {
                        statusList[hdn].HasHeimdall   = hdc.HasHeimdall;
                        statusList[hdn].HasHorton     = hdc.HasHorton;
                        statusList[hdn].HasTribble    = hdc.HasTribble;
                        statusList[hdn].HeimdallQTEMP = hdc.HeimdallQTEMP;
                        statusList[hdn].HortonQTEMP   = hdc.HortonQTEMP;
                        statusList[hdn].TribbleQTEMP  = hdc.TribbleQTEMP;
                        statusList[hdn].Hits++;
                    }
                }

                // Save the login data from this instance for possible reuse.
                string username = hdc.Name;

                // Now, we should reuse this name to do another check unless
                // we're done. If we're done, set the Ready flag.
                if (HasEverything() || nRequestsMade >= nMaxRequests)
                {
                    bReady = true;
                }
                else
                {
                    HeimdallCheck hc = RunHeimdallCheck(username, AppSettings.UserList[username]);

                    // Insert this instead of its "brother" in the list.
                    for (int i = 0; i < checkList.Length; i++)
                    {
                        if (checkList[i] == hdc)
                        {
                            checkList[i] = hc;
                        }
                    }
                }
            }
        }