From df991e26dc2c058f1cedd6a9bf99753493ea67a6 Mon Sep 17 00:00:00 2001 From: jessevz Date: Tue, 17 Mar 2026 13:34:09 +0100 Subject: [PATCH 1/3] Removed rule splitting --- src/inc/api/APISendBenchmark.php | 21 ----- src/inc/defines/DConfig.php | 6 -- src/inc/utils/TaskUtils.php | 90 ------------------- .../20260317120000_remove-rule-split.sql | 2 + .../20260317120000_remove-rule-split.sql | 2 + 5 files changed, 4 insertions(+), 117 deletions(-) create mode 100644 src/migrations/mysql/20260317120000_remove-rule-split.sql create mode 100644 src/migrations/postgres/20260317120000_remove-rule-split.sql diff --git a/src/inc/api/APISendBenchmark.php b/src/inc/api/APISendBenchmark.php index 6ea9cbe8d..eb96182d4 100644 --- a/src/inc/api/APISendBenchmark.php +++ b/src/inc/api/APISendBenchmark.php @@ -34,7 +34,6 @@ public function execute($QUERY = array()) { if ($task == null) { $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Invalid task ID!"); } - $taskWrapper = Factory::getTaskWrapperFactory()->get($task->getTaskWrapperId()); $qF1 = new QueryFilter(Assignment::AGENT_ID, $this->agent->getId(), "="); $qF2 = new QueryFilter(Assignment::TASK_ID, $task->getId(), "="); @@ -56,26 +55,6 @@ public function execute($QUERY = array()) { DServerLog::log(DServerLog::ERROR, "Invalid speed test benchmark result!", [$this->agent, $benchmark]); $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Invalid benchmark result!"); } - - // Here we check if the benchmark result would require to split the task and check if the task can be split - if (SConfig::getInstance()->getVal(DConfig::RULE_SPLIT_DISABLE) == 0 && $task->getUsePreprocessor() == 0 && $split[1] > $task->getChunkTime() * 1000 * 2 && $taskWrapper->getTaskType() == DTaskTypes::NORMAL) { - // test if we have a large rule file - DServerLog::log(DServerLog::INFO, "Potential rule split required", [$this->agent, $task]); - /** @var $files File[] */ - $files = Util::getFileInfo($task, AccessUtils::getAccessGroupsOfAgent($this->agent))[3]; - foreach ($files as $file) { - if ($file->getFileType() == DFileType::RULE) { - // test if splitting makes sense here - if (Util::countLines(Factory::getStoredValueFactory()->get(DDirectories::FILES)->getVal() . "/" . $file->getFilename()) > $split[1] / 1000 / $task->getChunkTime() || SConfig::getInstance()->getVal(DConfig::RULE_SPLIT_ALWAYS)) { - // --> split - DServerLog::log(DServerLog::INFO, "Rule splitting possible on file", [$this->agent, $task, $file]); - TaskUtils::splitByRules($task, $taskWrapper, $files, $file, $split); - $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Task was split due to benchmark!"); - } - } - } - } - break; case PValuesBenchmarkType::RUN_TIME: if (!is_numeric($benchmark) || $benchmark <= 0) { diff --git a/src/inc/defines/DConfig.php b/src/inc/defines/DConfig.php index 8fd9df13f..8b6cd5af2 100644 --- a/src/inc/defines/DConfig.php +++ b/src/inc/defines/DConfig.php @@ -158,9 +158,6 @@ public static function getConfigType($config) { DConfig::EMAIL_SENDER_NAME => DConfigType::STRING_INPUT, DConfig::DEFAULT_BENCH => DConfigType::TICKBOX, DConfig::SHOW_TASK_PERFORMANCE => DConfigType::TICKBOX, - DConfig::RULE_SPLIT_ALWAYS => DConfigType::TICKBOX, - DConfig::RULE_SPLIT_SMALL_TASKS => DConfigType::TICKBOX, - DConfig::RULE_SPLIT_DISABLE => DConfigType::TICKBOX, DConfig::AGENT_STAT_LIMIT => DConfigType::NUMBER_INPUT, DConfig::AGENT_DATA_LIFETIME => DConfigType::NUMBER_INPUT, DConfig::AGENT_STAT_TENSION => DConfigType::TICKBOX, @@ -232,9 +229,6 @@ public static function getConfigDescription($config) { DConfig::EMAIL_SENDER_NAME => "Sender's name on emails sent from " . APP_NAME . ".", DConfig::DEFAULT_BENCH => "Use speed benchmark as default.", DConfig::SHOW_TASK_PERFORMANCE => "Show cracks/minute for tasks which are running.", - DConfig::RULE_SPLIT_SMALL_TASKS => "When rule splitting is applied for tasks, always make them a small task.", - DConfig::RULE_SPLIT_ALWAYS => "Even do rule splitting when there are not enough rules but just the benchmark is too high.
Can result in subtasks with just one rule.", - DConfig::RULE_SPLIT_DISABLE => "Disable automatic task splitting with large rule files.", DConfig::AGENT_STAT_LIMIT => "Maximal number of data points showing of agent gpu data.", DConfig::AGENT_DATA_LIFETIME => "Minimum time in seconds how long agent gpu/cpu utilisation and gpu temperature data is kept on the server.", DConfig::AGENT_STAT_TENSION => "Draw straigth lines in agent data graph instead of bezier curves.", diff --git a/src/inc/utils/TaskUtils.php b/src/inc/utils/TaskUtils.php index c2ab206f5..93a369601 100644 --- a/src/inc/utils/TaskUtils.php +++ b/src/inc/utils/TaskUtils.php @@ -912,96 +912,6 @@ public static function createTask($hashlistId, $name, $attackCmd, $chunkTime, $s return $task; } - /** - * Splits a given task into subtasks within a supertask by splitting the rule file - * @param Task $task - * @param TaskWrapper $taskWrapper - * @param File[] $files - * @param File $splitFile - * @param array $split - */ - public static function splitByRules($task, $taskWrapper, $files, $splitFile, $split) { - // calculate how much we need to split - $numSplits = floor($split[1] / 1000 / $task->getChunkTime()); - // replace countLines with fileLineCount? Could be a better option: not OS-dependent - $numLines = Util::countLines(Factory::getStoredValueFactory()->get(DDirectories::FILES)->getVal() . "/" . $splitFile->getFilename()); - $linesPerFile = floor($numLines / $numSplits) + 1; - - // create the temporary rule files - $newFiles = []; - $content = explode("\n", str_replace("\r\n", "\n", file_get_contents(Factory::getStoredValueFactory()->get(DDirectories::FILES)->getVal() . "/" . $splitFile->getFilename()))); - $count = 0; - $taskId = $task->getId(); - for ($i = 0; $i < $numLines; $i += $linesPerFile, $count++) { - $copy = []; - for ($j = $i; $j < $i + $linesPerFile && $j < sizeof($content); $j++) { - $copy[] = $content[$j]; - } - $filename = $splitFile->getFilename() . "_p$taskId-$count"; - $path = Factory::getStoredValueFactory()->get(DDirectories::FILES)->getVal() . "/" . $splitFile->getFilename() . "_p$taskId-$count"; - file_put_contents($path, implode("\n", $copy) . "\n"); - $f = new File(null, $filename, Util::filesize($path), $splitFile->getIsSecret(), DFileType::TEMPORARY, $taskWrapper->getAccessGroupId(), Util::fileLineCount($path)); - $f = Factory::getFileFactory()->save($f); - $newFiles[] = $f; - } - - // take out the split file from the file list - for ($i = 0; $i < sizeof($files); $i++) { - if ($files[$i]->getId() == $splitFile->getId()) { - unset($files[$i]); - break; - } - } - - // create new tasks as supertask - $newWrapper = new TaskWrapper(null, 0, 0, DTaskTypes::SUPERTASK, $taskWrapper->getHashlistId(), $taskWrapper->getAccessGroupId(), $task->getTaskName() . " (From Rule Split)", 0, 0); - $newWrapper = Factory::getTaskWrapperFactory()->save($newWrapper); - $prio = sizeof($newFiles) + 1; - foreach ($newFiles as $newFile) { - $newTask = new Task(null, - "Part " . (sizeof($newFiles) + 2 - $prio), - str_replace($splitFile->getFilename(), $newFile->getFilename(), $task->getAttackCmd()), - $task->getChunkTime(), - $task->getStatusTimer(), - 0, - 0, - $prio, - $task->getMaxAgents(), - $task->getColor(), - (SConfig::getInstance()->getVal(DConfig::RULE_SPLIT_SMALL_TASKS) == 0) ? 0 : 1, - $task->getIsCpuTask(), - $task->getUseNewBench(), - $task->getSkipKeyspace(), - $task->getCrackerBinaryId(), - $task->getCrackerBinaryTypeId(), - $newWrapper->getId(), - 0, - '', - 0, - 0, - 0, - 0, - '' - ); - $newTask = Factory::getTaskFactory()->save($newTask); - $taskFiles = []; - $taskFiles[] = new FileTask(null, $newFile->getId(), $newTask->getId()); - foreach ($files as $f) { - $taskFiles[] = new FileTask(null, $f->getId(), $newTask->getId()); - FileDownloadUtils::addDownload($f->getId()); - } - Factory::getFileTaskFactory()->massSave($taskFiles); - $prio--; - } - $newWrapper->setPriority($taskWrapper->getPriority()); - $newWrapper->setMaxAgents($taskWrapper->getMaxAgents()); - Factory::getTaskWrapperFactory()->update($newWrapper); - - // cleanup - TaskUtils::deleteTask($task); - Factory::getTaskWrapperFactory()->delete($taskWrapper); - } - /** * @param $agent Agent * @param bool $all set true to get all matching tasks for this agent diff --git a/src/migrations/mysql/20260317120000_remove-rule-split.sql b/src/migrations/mysql/20260317120000_remove-rule-split.sql new file mode 100644 index 000000000..aa9e389d0 --- /dev/null +++ b/src/migrations/mysql/20260317120000_remove-rule-split.sql @@ -0,0 +1,2 @@ +DELETE FROM Config +where item in ('ruleSplitSmallTasks', 'ruleSplitAlways', 'ruleSplitDisable'); \ No newline at end of file diff --git a/src/migrations/postgres/20260317120000_remove-rule-split.sql b/src/migrations/postgres/20260317120000_remove-rule-split.sql new file mode 100644 index 000000000..aa9e389d0 --- /dev/null +++ b/src/migrations/postgres/20260317120000_remove-rule-split.sql @@ -0,0 +1,2 @@ +DELETE FROM Config +where item in ('ruleSplitSmallTasks', 'ruleSplitAlways', 'ruleSplitDisable'); \ No newline at end of file From 29c0cffc018bc6cacc7a162985c90cec86e65358 Mon Sep 17 00:00:00 2001 From: jessevz Date: Tue, 17 Mar 2026 13:41:57 +0100 Subject: [PATCH 2/3] Fixed copilot review --- src/inc/api/APISendBenchmark.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/inc/api/APISendBenchmark.php b/src/inc/api/APISendBenchmark.php index eb96182d4..e63a479f3 100644 --- a/src/inc/api/APISendBenchmark.php +++ b/src/inc/api/APISendBenchmark.php @@ -8,19 +8,12 @@ use Hashtopolis\inc\agent\PValues; use Hashtopolis\inc\agent\PValuesBenchmarkType; use Hashtopolis\inc\defines\DConfig; -use Hashtopolis\inc\defines\DDirectories; -use Hashtopolis\inc\defines\DTaskTypes; -use Hashtopolis\inc\utils\AccessUtils; -use Hashtopolis\inc\defines\DFileType; use Hashtopolis\inc\defines\DServerLog; use Hashtopolis\dba\models\Agent; use Hashtopolis\dba\models\Assignment; use Hashtopolis\dba\QueryFilter; use Hashtopolis\dba\Factory; -use Hashtopolis\dba\models\File; use Hashtopolis\inc\SConfig; -use Hashtopolis\inc\utils\TaskUtils; -use Hashtopolis\inc\Util; class APISendBenchmark extends APIBasic { public function execute($QUERY = array()) { From d8defb2b66e789d1775643cda45f648bcab89150 Mon Sep 17 00:00:00 2001 From: jessevz Date: Tue, 17 Mar 2026 14:50:12 +0100 Subject: [PATCH 3/3] Removed rulesplit constants --- src/inc/defines/DConfig.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/inc/defines/DConfig.php b/src/inc/defines/DConfig.php index 8b6cd5af2..4372b061f 100644 --- a/src/inc/defines/DConfig.php +++ b/src/inc/defines/DConfig.php @@ -18,9 +18,6 @@ class DConfig { const BLACKLIST_CHARS = "blacklistChars"; const DISP_TOLERANCE = "disptolerance"; const DEFAULT_BENCH = "defaultBenchmark"; - const RULE_SPLIT_SMALL_TASKS = "ruleSplitSmallTasks"; - const RULE_SPLIT_ALWAYS = "ruleSplitAlways"; - const RULE_SPLIT_DISABLE = "ruleSplitDisable"; const AGENT_DATA_LIFETIME = "agentDataLifetime"; const DISABLE_TRIMMING = "disableTrimming"; const PRIORITY_0_START = "priority0Start";