mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
update laravel + filament & improve agent deny
This commit is contained in:
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateAgentAllow extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AgentAllowResource::class;
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
clear_agent_allow_deny_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,9 @@ class EditAgentAllow extends EditRecord
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave()
|
||||
{
|
||||
clear_agent_allow_deny_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ class DeniesRelationManager extends RelationManager
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->required()->maxLength(255),
|
||||
Forms\Components\TextInput::make('peer_id')->required()->maxLength(255),
|
||||
Forms\Components\TextInput::make('agent')->required()->maxLength(255),
|
||||
Forms\Components\Textarea::make('comment'),
|
||||
Forms\Components\TextInput::make('name')->required()->maxLength(255)->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('peer_id')->required()->maxLength(255)->label(__('label.agent_deny.peer_id')),
|
||||
Forms\Components\TextInput::make('agent')->required()->maxLength(255)->label(__('label.agent_deny.agent')),
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ class DeniesRelationManager extends RelationManager
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
Tables\Columns\TextColumn::make('peer_id'),
|
||||
Tables\Columns\TextColumn::make('agent'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('peer_id')->label(__('label.agent_deny.peer_id')),
|
||||
Tables\Columns\TextColumn::make('agent')->label(__('label.agent_deny.agent')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateAgentDeny extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AgentDenyResource::class;
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
clear_agent_allow_deny_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,9 @@ class EditAgentDeny extends EditRecord
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave()
|
||||
{
|
||||
clear_agent_allow_deny_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Repositories;
|
||||
use App\Exceptions\ClientNotAllowedException;
|
||||
use App\Models\AgentAllow;
|
||||
use App\Models\AgentDeny;
|
||||
use Illuminate\Support\Collection;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class AgentAllowRepository extends BaseRepository
|
||||
@@ -73,7 +74,7 @@ class AgentAllowRepository extends BaseRepository
|
||||
public function checkClient($peerId, $agent, $debug = false)
|
||||
{
|
||||
//check from high version to low version, if high version allow, stop!
|
||||
$allows = NexusDB::remember("all_agent_allows", 600, function () {
|
||||
$allows = NexusDB::remember("all_agent_allows", 3600, function () {
|
||||
return AgentAllow::query()
|
||||
->orderBy('peer_id_start', 'desc')
|
||||
->orderBy('agent_start', 'desc')
|
||||
@@ -189,7 +190,11 @@ class AgentAllowRepository extends BaseRepository
|
||||
|
||||
private function checkIsDenied($peerId, $agent, $familyId)
|
||||
{
|
||||
$agentDenies = AgentDeny::query()->where('family_id', $familyId)->get();
|
||||
/** @var Collection $allDenies */
|
||||
$allDenies = NexusDB::remember("all_agent_denies", 3600, function () {
|
||||
return AgentDeny::query()->get()->groupBy('family_id');
|
||||
});
|
||||
$agentDenies = $allDenies->get($familyId, []);
|
||||
foreach ($agentDenies as $agentDeny) {
|
||||
if ($agentDeny->agent == $agent && preg_match("/^" . $agentDeny->peer_id . "/", $peerId)) {
|
||||
return $agentDeny;
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
"ext-zend-opcache": "*",
|
||||
"doctrine/dbal": "^3.1",
|
||||
"elasticsearch/elasticsearch": "^7.16",
|
||||
"filament/filament": "2.16.52",
|
||||
"filament/filament": "2.17.14",
|
||||
"flowframe/laravel-trend": "^0.1.1",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"geoip2/geoip2": "~2.0",
|
||||
"hashids/hashids": "^4.1",
|
||||
"imdbphp/imdbphp": "^7.0",
|
||||
"laravel/framework": "9.41.0",
|
||||
"laravel/framework": "9.52.4",
|
||||
"laravel/octane": "^1.2",
|
||||
"laravel/sanctum": "^2.10",
|
||||
"laravel/tinker": "^2.5",
|
||||
|
||||
1340
composer.lock
generated
1340
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-05');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-06');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -1063,6 +1063,13 @@ function clear_inbox_count_cache($uid)
|
||||
}
|
||||
}
|
||||
|
||||
function clear_agent_allow_deny_cache()
|
||||
{
|
||||
do_log("clear_agent_allow_deny_cache");
|
||||
\Nexus\Database\NexusDB::cache_del("all_agent_allows");
|
||||
\Nexus\Database\NexusDB::cache_del("all_agent_denies");
|
||||
}
|
||||
|
||||
|
||||
function user_can($permission, $fail = false, $uid = 0): bool
|
||||
{
|
||||
|
||||
@@ -211,7 +211,7 @@ return [
|
||||
],
|
||||
'agent_deny' => [
|
||||
'label' => 'Agent deny',
|
||||
'peer_id' => 'Peer ID',
|
||||
'peer_id' => 'Peer ID starts',
|
||||
'agent' => 'Agent',
|
||||
],
|
||||
'claim' => [
|
||||
|
||||
@@ -213,7 +213,7 @@ return [
|
||||
],
|
||||
'agent_deny' => [
|
||||
'label' => '拒绝客戶端',
|
||||
'peer_id' => 'Peer ID',
|
||||
'peer_id' => 'Peer ID 起始',
|
||||
'agent' => 'Agent',
|
||||
],
|
||||
'claim' => [
|
||||
|
||||
@@ -210,7 +210,7 @@ return [
|
||||
],
|
||||
'agent_deny' => [
|
||||
'label' => '拒絕客戶端',
|
||||
'peer_id' => 'Peer ID',
|
||||
'peer_id' => 'Peer ID 超始',
|
||||
'agent' => 'Agent',
|
||||
],
|
||||
'claim' => [
|
||||
|
||||
Reference in New Issue
Block a user