You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -15,7 +15,7 @@ class LogViewerMiddleware
|
||||
return to_route('login');
|
||||
}
|
||||
|
||||
if (hasPermission('view_server_logs') === '' || hasPermission('view_server_logs') === '0') {
|
||||
if (! hasPermission('view_server_logs')) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,22 +18,22 @@ class RealClientIpMiddleware
|
||||
];
|
||||
|
||||
foreach ($proxyHeaders as $header) {
|
||||
if (! empty(\Illuminate\Support\Facades\Request::server($header))) {
|
||||
$ip = \Illuminate\Support\Facades\Request::server($header);
|
||||
if (str_contains((string) $ip, ',')) {
|
||||
[$ip] = explode(',', (string) $ip);
|
||||
$value = $request->server->get($header);
|
||||
if (is_string($value) && $value !== '') {
|
||||
$candidate = $value;
|
||||
if (str_contains($candidate, ',')) {
|
||||
[$candidate] = explode(',', $candidate);
|
||||
}
|
||||
$ip = trim((string) $ip);
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
// Set the real IP as REMOTE_ADDR
|
||||
$request->server->set('REMOTE_ADDR', $ip);
|
||||
$candidate = trim($candidate);
|
||||
if (filter_var($candidate, FILTER_VALIDATE_IP)) {
|
||||
$request->server->set('REMOTE_ADDR', $candidate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling for REMOTE_ADDR with multiple IPs
|
||||
$remoteAddr = \Illuminate\Support\Facades\Request::server('REMOTE_ADDR');
|
||||
$remoteAddr = $request->server->get('REMOTE_ADDR');
|
||||
if (is_string($remoteAddr) && str_contains($remoteAddr, ',')) {
|
||||
[$ip] = explode(',', $remoteAddr);
|
||||
$ip = trim($ip);
|
||||
|
||||
@@ -40,7 +40,18 @@ class VPNCheckerMiddleware
|
||||
$userIp = $request->ip();
|
||||
$apiResponse = $ipService->ipLookup($userIp);
|
||||
|
||||
$asn = $apiResponse['asn']['asn'] ?? '';
|
||||
$asn = '';
|
||||
if (is_array($apiResponse)) {
|
||||
$asnSection = $apiResponse['asn'] ?? null;
|
||||
if (is_array($asnSection)) {
|
||||
$asnValue = $asnSection['asn'] ?? null;
|
||||
if (is_string($asnValue)) {
|
||||
$asn = $asnValue;
|
||||
} elseif (is_int($asnValue)) {
|
||||
$asn = (string) $asnValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$asnWhitelisted = WebsiteIpWhitelist::where('asn', $asn)
|
||||
->where('whitelist_asn', '=', '1')
|
||||
->exists();
|
||||
@@ -61,8 +72,11 @@ class VPNCheckerMiddleware
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($apiResponse['threat']) && is_array($apiResponse['threat'])) {
|
||||
$filteredThreats = array_diff_key($apiResponse['threat'], array_flip(['blocklists', 'is_icloud_relay', 'is_datacenter', 'is_tor', 'is_proxy']));
|
||||
if (is_array($apiResponse) && isset($apiResponse['threat']) && is_array($apiResponse['threat'])) {
|
||||
$filteredThreats = array_diff_key(
|
||||
$apiResponse['threat'],
|
||||
array_flip(['blocklists', 'is_icloud_relay', 'is_datacenter', 'is_tor', 'is_proxy'])
|
||||
);
|
||||
|
||||
if (in_array(true, $filteredThreats, true)) {
|
||||
WebsiteIpBlacklist::create([
|
||||
|
||||
Reference in New Issue
Block a user