fix host validation, impove debug message

This commit is contained in:
ghost 2023-09-16 17:41:25 +03:00
parent d1428b6a16
commit 8b09dbd1bd

View File

@ -35,12 +35,12 @@ foreach (json_decode(file_get_contents(__DIR__ . '/../../config/nodes.json')) as
if (empty($thisUrl->host->name) || if (empty($thisUrl->host->name) ||
empty($manifestUrl->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; continue;
} }
$connectionWhiteList[] = $manifestUrl->host->name; $connectionWhiteList[] = str_replace(['[',']'], false, $manifestUrl->host->name);
} }
// API import enabled // API import enabled
@ -79,7 +79,10 @@ else if (!in_array($_SERVER['REMOTE_ADDR'], $connectionWhiteList))
$response = $response =
[ [
'status' => false, 'status' => false,
'message' => _('Access denied for this host') 'message' => sprintf(
_('Access denied for host "%s"'),
$_SERVER['REMOTE_ADDR']
)
]; ];
} }