From 1bf327cc0072ab048c1e6524b454d7d89a81e810 Mon Sep 17 00:00:00 2001 From: tracer Date: Sat, 29 Jan 2022 14:56:07 +0100 Subject: [PATCH] modified curl handling Signed-off-by: tracer --- src/Controller/CheckController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controller/CheckController.php b/src/Controller/CheckController.php index 06a475c..c2dd61a 100644 --- a/src/Controller/CheckController.php +++ b/src/Controller/CheckController.php @@ -21,6 +21,7 @@ class CheckController */ function sendCommand(String $serverName, int $versionIP, String $apiKey, String $command, String $type, bool $post = false, array $body = []): array { + $error = false; $curl = curl_init(); if ($type == "panel") { curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command); @@ -28,7 +29,8 @@ class CheckController curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command); } curl_setopt(handle: $curl, option: CURLOPT_RETURNTRANSFER, value: 1); - curl_setopt(handle: $curl, option: CURLOPT_TIMEOUT_MS, value: 1000); + curl_setopt(handle: $curl, option: CURLOPT_TIMEOUT_MS, value: 3000); + curl_setopt(handle: $curl, option: CURLOPT_HTTP_VERSION, value: CURL_HTTP_VERSION_2TLS); if ($versionIP == 4) { curl_setopt(handle: $curl, option: CURLOPT_IPRESOLVE, value: CURL_IPRESOLVE_V4); @@ -66,10 +68,12 @@ class CheckController $result = 'Unhandled error: ' . $httpResponse; } } else { + $error = true; $result = curl_error(handle: $curl); } curl_close(handle: $curl); return [ + 'error' => true, 'data' => $result, 'header' => $httpResponse ?? '' ];