コード例 #1
0
        public static void PushToDatabase(StatusContainer status, long bruteForceTime, string identifier, KeySearcherSettings settings, KeySearcher keySearcher)
        {
            if (string.IsNullOrEmpty(settings.EvaluationHost))
            {
                return;
            }

            var connectionString = "Data Source=" + settings.EvaluationHost + ";";

            connectionString += "User ID=" + settings.EvaluationUser + ";";
            connectionString += "Password="******";";
            connectionString += "Initial Catalog=" + settings.EvaluationDatabase;

            var sqlConnection = new SqlConnection();

            try
            {
                sqlConnection.ConnectionString = connectionString;
                sqlConnection.Open();

                // You can get the server version
                // SQLConnection.ServerVersion
            }
            catch (Exception ex)
            {
                sqlConnection.Dispose();
                keySearcher.GuiLogMessage("DB Error: " + ex.Message, NotificationLevel.Error);
                return;
            }

            var globalProgress        = status.GlobalProgress.ToString(CultureInfo.CreateSpecificCulture("en-US"));
            var dhtTimeInMilliseconds = status.DhtOverheadInReadableTime.TotalMilliseconds.ToString(CultureInfo.CreateSpecificCulture("en-US"));
            var sqlStatement          = string.Format("INSERT INTO [statistics] ([host],[date],[localFinishedChunks],[currentChunk],[globalProgress],[totalAmountOfParticipants],[totalDhtRequests],[requestsPerNode],[retrieveRequests],[removeRequests],[storeRequests],[dhtTimeInMilliseconds],[dhtOverheadInPercent],[storedBytes],[retrievedBytes],[totalBytes],[sentBytesByLinkManager],[receivedBytesByLinkManager],[totalBytesByLinkManager],[bruteForceTimeInMilliseconds],[identifier],[processID]) "
                                                      + "VALUES ('{0}', GetDate(), {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, '{11}', {12}, {13}, {14}, {15}, {16}, {17}, {18}, '{19}', {20});",
                                                      Environment.MachineName, status.LocalFinishedChunks, status.CurrentChunk, globalProgress, status.TotalAmountOfParticipants, status.TotalDhtRequests, status.RequestsPerNode, status.RetrieveRequests, status.RemoveRequests, status.StoreRequests, dhtTimeInMilliseconds, status.DhtOverheadInPercent, status.StoredBytes, status.RetrievedBytes, status.TotalBytes, status.SentBytesByLinkManager, status.ReceivedBytesByLinkManager, status.TotalBytesByLinkManager, bruteForceTime, identifier, Process.GetCurrentProcess().Id);

            try
            {
                var command = new SqlCommand(sqlStatement, sqlConnection);
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                keySearcher.GuiLogMessage("DB Error: " + ex.Message, NotificationLevel.Error);
            }
            finally
            {
                sqlConnection.Close();
                sqlConnection.Dispose();
            }
        }
コード例 #2
0
        public Leaf FindNextLeaf()
        {
            // REMOVEME uncommenting the next line will cause a search for the next free pattern starting from the root node - for every leaf!
            //Reset();

            statusContainer.IsSearchingForReservedNodes = false;
            if (statisticsGenerator != null)
            {
                statisticsGenerator.MarkStartOfNodeSearch();
            }

            var nodeBeforeStarting = currentNode;
            var foundNode          = FindNextLeaf(SearchOption.SkipReservedLeafs);

            if (foundNode == null && skippedReservedNodes)
            {
                if (keySearcher != null)
                {
                    keySearcher.GuiLogMessage("Searching again with reserved nodes enabled...", NotificationLevel.Info);
                }

                currentNode = nodeBeforeStarting;
                statusContainer.IsSearchingForReservedNodes = true;
                foundNode   = FindNextLeaf(SearchOption.UseReservedLeafs);
                currentNode = foundNode;

                if (statisticsGenerator != null)
                {
                    statisticsGenerator.MarkEndOfNodeSearch();
                }
                return(foundNode);
            }

            currentNode = foundNode;

            if (statisticsGenerator != null)
            {
                statisticsGenerator.MarkEndOfNodeSearch();
            }
            return(foundNode);
        }
コード例 #3
0
        public void StatusKeyButton()
        {
            if (!keysearcher.IsKeySearcherRunning)
            {
                keysearcher.GuiLogMessage(Resources.KeySearcher_must_be_running_to_copy_the_status_key_, NotificationLevel.Error);
                return;
            }

            var generator = new StorageKeyGenerator(keysearcher, this);
            var statusKey = generator.GenerateStatusKey();

            try
            {
                Clipboard.SetDataObject(statusKey, true);
                keysearcher.GuiLogMessage(string.Format(Resources.Status_key___0___has_been_copied_to_clipboard_, statusKey),
                                          NotificationLevel.Info);
            }
            catch (ExternalException e)
            {
                // TODO: externalize
                keysearcher.GuiLogMessage(string.Format("Accessing clipboard has failed, please try again later: {0}", e.Message), NotificationLevel.Error);
                return;
            }
        }