From 9da810ba3db20b32d18f75571cbe9d67d7969689 Mon Sep 17 00:00:00 2001 From: mercury Date: Fri, 16 Aug 2024 02:21:29 +0400 Subject: [PATCH] fix empty rules route --- app/bot.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/bot.php b/app/bot.php index 41b0e29..bdc3f8b 100644 --- a/app/bot.php +++ b/app/bot.php @@ -4622,6 +4622,7 @@ DNS-over-HTTPS with IP: $c['route'] = $this->addRuleSet($c['route']); $c['route'] = $this->addPackageRule($c['route']); $c['route'] = $this->createRuleSet($c['route'], $uid); + $c['route'] = $this->clearEmptyRules($c['route']); break; } @@ -4629,6 +4630,16 @@ DNS-over-HTTPS with IP: echo json_encode($c); } + public function clearEmptyRules($route) + { + foreach ($route['rules'] as $k => $v) { + if (count($v) == 1) { + unset($route['rules'][$k]); + } + } + return $route; + } + public function addPackageRule($route) { foreach ($route['rules'] as $k => $v) {