mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
728 B
PHP
32 lines
728 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Symfony\Component\HttpFoundation\IpUtils;
|
|
|
|
class BouncerService
|
|
{
|
|
public static function checkIp($ip)
|
|
{
|
|
$knownCloudCidrs = Cache::rememberForever('pf:bouncer-service:check-ip:known-cloud-cidrs', function () {
|
|
$file = Storage::get('bouncer/all.json');
|
|
|
|
if ($file === null) {
|
|
return [];
|
|
}
|
|
|
|
$decoded = json_decode($file, true);
|
|
|
|
if ($decoded === null || !is_array($decoded)) {
|
|
return [];
|
|
}
|
|
|
|
return $decoded;
|
|
});
|
|
|
|
return IpUtils::checkIp($ip, $knownCloudCidrs);
|
|
}
|
|
}
|