feat(api): 新增节点墙检测自动托管与显隐

新增定时墙检测命令与节点托管字段,自动为开启托管的父
节点创建检测任务,并在 blocked 时自动隐藏节点、normal
时仅恢复由墙检测自动隐藏的节点

更新自动上线服务以尊重 blocked 与自动隐藏状态,避免疑
似被墙节点被重新发布;同时补齐管理端墙检测托管开关、
刷新入口、批量设置与相关测试和知识库同步
This commit is contained in:
yinjianm
2026-04-28 00:51:49 +08:00
parent 73b1696b0a
commit ff50030364
27 changed files with 998 additions and 24 deletions
@@ -3,6 +3,7 @@
namespace Tests\Unit;
use App\Models\Server;
use App\Models\ServerGfwCheck;
use App\Services\ServerAutoOnlineService;
use App\Services\ServerService;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -44,6 +45,56 @@ class ServerAutoOnlineServiceTest extends TestCase
$this->assertTrue($manualOffline->fresh()->show);
}
public function test_sync_keeps_gfw_blocked_auto_online_node_hidden(): void
{
$managedOnline = $this->makeServer([
'name' => 'managed-gfw-blocked',
'show' => true,
'auto_online' => true,
'gfw_check_enabled' => true,
]);
ServerService::touchNode($managedOnline);
ServerGfwCheck::create([
'server_id' => $managedOnline->id,
'status' => ServerGfwCheck::STATUS_BLOCKED,
'checked_at' => time(),
]);
$result = app(ServerAutoOnlineService::class)->sync();
$this->assertSame(1, $result['total']);
$this->assertSame(1, $result['updated']);
$this->assertSame(0, $result['shown']);
$this->assertSame(1, $result['hidden']);
$this->assertFalse($managedOnline->fresh()->show);
$this->assertTrue($managedOnline->fresh()->gfw_auto_hidden);
}
public function test_sync_ignores_blocked_status_when_gfw_check_is_disabled(): void
{
$managedOnline = $this->makeServer([
'name' => 'managed-gfw-disabled',
'show' => false,
'auto_online' => true,
'gfw_check_enabled' => false,
]);
ServerService::touchNode($managedOnline);
ServerGfwCheck::create([
'server_id' => $managedOnline->id,
'status' => ServerGfwCheck::STATUS_BLOCKED,
'checked_at' => time(),
]);
$result = app(ServerAutoOnlineService::class)->sync();
$this->assertSame(1, $result['total']);
$this->assertSame(1, $result['updated']);
$this->assertSame(1, $result['shown']);
$this->assertTrue($managedOnline->fresh()->show);
}
private function makeServer(array $attributes = []): Server
{
return Server::create(array_merge([
@@ -56,6 +107,8 @@ class ServerAutoOnlineServiceTest extends TestCase
'group_ids' => [1],
'show' => false,
'auto_online' => false,
'gfw_check_enabled' => true,
'gfw_auto_hidden' => false,
'enabled' => true,
], $attributes));
}