From 2599e471213fe7f9c4e37036444144ef9d06f875 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Tue, 4 Jun 2024 20:08:04 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=83=20Sync=20Hub=20v0.54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- Dockerfile.debian | 2 +- front/plugins/sync/hub.php | 35 ++------------------------ install/install_dependencies.debian.sh | 2 +- 4 files changed, 5 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3abc2791..2a865b26 100755 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ RUN apk update --no-cache \ && apk add --no-cache bash zip lsblk gettext-envsubst sudo mtr tzdata s6-overlay \ && apk add --no-cache curl arp-scan iproute2 iproute2-ss nmap nmap-scripts traceroute net-tools net-snmp-tools bind-tools awake ca-certificates \ && apk add --no-cache sqlite php83 php83-fpm php83-cgi php83-curl php83-sqlite3 php83-session \ - && apk add --no-cache python3 nginx \ + && apk add --no-cache python3 python3-dev nginx \ && ln -s /usr/bin/awake /usr/bin/wakeonlan \ && bash -c "install -d -m 750 -o nginx -g www-data ${INSTALL_DIR} ${INSTALL_DIR}" \ && rm -f /etc/nginx/http.d/default.conf diff --git a/Dockerfile.debian b/Dockerfile.debian index ce533594..ddc3799e 100755 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -33,7 +33,7 @@ COPY --chmod=775 --chown=${USER_ID}:${USER_GID} . ${INSTALL_DIR}/ RUN apt-get install -y \ tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo \ nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools php-openssl \ - python3 iproute2 nmap python3-pip zip systemctl usbutils traceroute + python3 python3-dev iproute2 nmap python3-pip zip systemctl usbutils traceroute # Alternate dependencies RUN apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8.2-sqlite3 -y diff --git a/front/plugins/sync/hub.php b/front/plugins/sync/hub.php index 58c2b1a0..92a1557f 100755 --- a/front/plugins/sync/hub.php +++ b/front/plugins/sync/hub.php @@ -4,26 +4,6 @@ require '/app/front/php/server/init.php'; -// function decrypt_data($encoded_data, $key) { -// // Base64 decode the encrypted data -// $data = base64_decode($encoded_data); - -// // Extract the IV and the ciphertext -// $iv = substr($data, 0, 16); -// $ciphertext = substr($data, 16); - -// // Derive the key using SHA-256 -// $key = hash('sha256', $key, true); - -// // Decrypt the ciphertext using AES-256-CBC -// $decrypted_data = openssl_decrypt($ciphertext, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv); - -// // Remove padding -// $decrypted_data = rtrim($decrypted_data, "\0"); - -// return $decrypted_data; -// } - if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Retrieve the authorization header $headers = apache_request_headers(); @@ -43,14 +23,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $plugin_folder = $_POST['plugin_folder'] ?? ''; $node_name = $_POST['node_name'] ?? ''; - // $decoded_data = decrypt_data($data, getSettingValue('SYNC_encryption_key')); - - // if ($decoded_data === false or $decoded_data === null) { - // write_notification("[Plugin: Sync hub API] Bad Request: Decryption failed", "alert"); - // http_response_code(400); - // echo 'Bad Request: Decryption failed'; - // exit; - // } $storage_path = "/app/front/plugins/{$plugin_folder}"; @@ -63,12 +35,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } // Generate a unique file path to avoid overwriting existing files - $files = glob("{$storage_path}/last_result.{$node_name}.*.log"); - // $files = array_filter($files, function($file) { - // return preg_match('/last_result\.\d+\.log$/', basename($file)); - // }); + $files = glob("{$storage_path}/last_result.encoded.{$node_name}.*.log"); $file_count = count($files) + 1; - $file_path = "{$storage_path}/last_result.{$node_name}.{$file_count}.log"; + $file_path = "{$storage_path}/last_result.encoded.{$node_name}.{$file_count}.log"; // Save the decoded data to the file file_put_contents($file_path, $data); diff --git a/install/install_dependencies.debian.sh b/install/install_dependencies.debian.sh index 7ceb11b2..c9fb22cd 100755 --- a/install/install_dependencies.debian.sh +++ b/install/install_dependencies.debian.sh @@ -16,7 +16,7 @@ fi apt-get install -y \ tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo \ nginx-light php php-cgi php-fpm php-sqlite3 php-curl php-openssl sqlite3 dnsutils net-tools \ - python3 iproute2 nmap python3-pip zip systemctl usbutils traceroute + python3 python3-dev iproute2 nmap python3-pip zip systemctl usbutils traceroute # alternate dependencies sudo apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8.2-sqlite3 -y