From 8b09dbd1bd869ab51f0f877b8c35f7a39db3849d Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 16 Sep 2023 17:41:25 +0300 Subject: [PATCH] fix host validation, impove debug message --- src/public/api/push.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/public/api/push.php b/src/public/api/push.php index 435ae5b..ff928b8 100644 --- a/src/public/api/push.php +++ b/src/public/api/push.php @@ -35,12 +35,12 @@ foreach (json_decode(file_get_contents(__DIR__ . '/../../config/nodes.json')) as if (empty($thisUrl->host->name) || empty($manifestUrl->host->name) || - $manifestUrl->host->name == $thisUrl->host->name) // @TODO some mirrors could be available, improve condition + $manifestUrl->host->name == $thisUrl->host->name) // @TODO some mirrors could be available on same host sub-folders, improve condition { continue; } - $connectionWhiteList[] = $manifestUrl->host->name; + $connectionWhiteList[] = str_replace(['[',']'], false, $manifestUrl->host->name); } // API import enabled @@ -79,7 +79,10 @@ else if (!in_array($_SERVER['REMOTE_ADDR'], $connectionWhiteList)) $response = [ 'status' => false, - 'message' => _('Access denied for this host') + 'message' => sprintf( + _('Access denied for host "%s"'), + $_SERVER['REMOTE_ADDR'] + ) ]; }