mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 12:14:45 +02:00
Fix trusted proxies settings & Move ips to config & Add ipv6 (#692)
* Fix blank proxy & Move hardcoded cloudflare ips * Add cloudflare's ipv6 * Pull from url innstead of hardcoded * Remove Service
This commit is contained in:
parent
9d02aeb130
commit
340ae8099b
@ -25,6 +25,8 @@ use Filament\Notifications\Notification;
|
|||||||
use Filament\Pages\Concerns\HasUnsavedDataChangesAlert;
|
use Filament\Pages\Concerns\HasUnsavedDataChangesAlert;
|
||||||
use Filament\Pages\Concerns\InteractsWithHeaderActions;
|
use Filament\Pages\Concerns\InteractsWithHeaderActions;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Notification as MailNotification;
|
use Illuminate\Support\Facades\Notification as MailNotification;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
@ -149,7 +151,7 @@ class Settings extends Page implements HasForms
|
|||||||
->separator()
|
->separator()
|
||||||
->splitKeys(['Tab', ' '])
|
->splitKeys(['Tab', ' '])
|
||||||
->placeholder('New IP or IP Range')
|
->placeholder('New IP or IP Range')
|
||||||
->default(env('TRUSTED_PROXIES', config('trustedproxy.proxies')))
|
->default(env('TRUSTED_PROXIES', implode(',', config('trustedproxy.proxies'))))
|
||||||
->hintActions([
|
->hintActions([
|
||||||
FormAction::make('clear')
|
FormAction::make('clear')
|
||||||
->label('Clear')
|
->label('Clear')
|
||||||
@ -162,23 +164,26 @@ class Settings extends Page implements HasForms
|
|||||||
->label('Set to Cloudflare IPs')
|
->label('Set to Cloudflare IPs')
|
||||||
->icon('tabler-brand-cloudflare')
|
->icon('tabler-brand-cloudflare')
|
||||||
->authorize(fn () => auth()->user()->can('update settings'))
|
->authorize(fn () => auth()->user()->can('update settings'))
|
||||||
->action(fn (Set $set) => $set('TRUSTED_PROXIES', [
|
->action(function (Client $client, Set $set) {
|
||||||
'173.245.48.0/20',
|
$ips = collect();
|
||||||
'103.21.244.0/22',
|
try {
|
||||||
'103.22.200.0/22',
|
$response = $client->request(
|
||||||
'103.31.4.0/22',
|
'GET',
|
||||||
'141.101.64.0/18',
|
'https://api.cloudflare.com/client/v4/ips',
|
||||||
'108.162.192.0/18',
|
config('panel.guzzle')
|
||||||
'190.93.240.0/20',
|
);
|
||||||
'188.114.96.0/20',
|
if ($response->getStatusCode() === 200) {
|
||||||
'197.234.240.0/22',
|
$result = json_decode($response->getBody(), true)['result'];
|
||||||
'198.41.128.0/17',
|
foreach (['ipv4_cidrs', 'ipv6_cidrs'] as $value) {
|
||||||
'162.158.0.0/15',
|
$ips->push(...data_get($result, $value));
|
||||||
'104.16.0.0/13',
|
}
|
||||||
'104.24.0.0/14',
|
$ips->unique();
|
||||||
'172.64.0.0/13',
|
}
|
||||||
'131.0.72.0/22',
|
} catch (GuzzleException $e) {
|
||||||
])),
|
}
|
||||||
|
|
||||||
|
$set('TRUSTED_PROXIES', $ips->values()->all());
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user