update mq cotroller
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Controller\AbstractController;
|
||||
use App\Middleware\AuthMiddleware;
|
||||
use App\Middleware\PermissionMiddleware;
|
||||
use App\Service\MqStatusService;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
@@ -86,9 +87,25 @@ class MqStatusController extends AbstractController
|
||||
'data' => $data,
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
Log::get()->error('MQ status query failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
|
||||
// 脱敏:mask 异常消息中的敏感信息(IP、端口、认证凭证)
|
||||
$safe_message = preg_replace(
|
||||
[
|
||||
'/\/\/[^:]+:[^@]+@/', // user:pass@ → //***:***@
|
||||
'/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', // IP 地址
|
||||
'/:\d{4,5}(?=[\/\s\)]|$)/', // 端口号
|
||||
],
|
||||
['//***:***@', '***.***.***.***', ':****'],
|
||||
$e->getMessage()
|
||||
);
|
||||
|
||||
return $this->response->json([
|
||||
'code' => 500,
|
||||
'message' => 'RabbitMQ 连接异常: ' . $e->getMessage(),
|
||||
'message' => 'RabbitMQ 连接异常: ' . $safe_message,
|
||||
'data' => null,
|
||||
])->withStatus(500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user