Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
456ed195bb | ||
|
|
840bace83a |
No files matched your search
@@ -58,7 +58,7 @@ ## 独立文章发布 API
|
||||
|
||||
2026-11-02本地将“综合教程”改为“进阶教程”,地址仍 `/advanced`,并统一桌面/手机顶级栏目图标对齐,尚未发布。当前名称、命令和验收见[栏目导航维护](docs/maintenance/NAVIGATION.md)。
|
||||
|
||||
2026-11-07起“暂避风头模式”只隐藏机场广告和推荐,免费节点照常发布。命令 `php artisan site:quiet on|off|status`,操作、状态文件和回退见[暂避风头模式](docs/maintenance/QUIET_MODE.md)。
|
||||
2026-11-03本地新增“暂避风头模式”:暂停免费节点发布更新并隐藏机场广告/推荐,保留旧资源和其他文章。命令 `php artisan site:quiet on|off|status`,当前本地关闭、未发布;唯一实现、权限和验收见[暂避风头模式](docs/maintenance/QUIET_MODE.md)。
|
||||
|
||||
## SEO统一合同(2026-10-31)
|
||||
|
||||
@@ -73,5 +73,3 @@ ## SEO统一合同(2026-10-31)
|
||||
|
||||
|
||||
2026-11-03用户授权六项待发布改动及关联文章/图片全部上线,并明确开启暂避风头模式:正式cfn已完成Git发布、四篇文章API及四图交付、进阶教程改名和四篇置顶;生产模式开启,本地仍关闭。414项服务器检查和31个下载HEAD通过。此状态替代上文相应“仅本地/未发布”,但不恢复已撤下news;当前Git、回执、权限、验收和回退唯一见[六项发布记录](docs/maintenance/SIX_RELEASE_2026-11-03.md)。已完成服务器侧验收,未做线上页面验收。
|
||||
|
||||
2026-11-09公共域名自动选址与站内点击出口按[广告入口自动同步](docs/maintenance/DOMAINHUB_PUBLIC.md)维护;原投放开关保持最终决定权。
|
||||
@@ -9,7 +9,7 @@
|
||||
final class QuietMode extends Command
|
||||
{
|
||||
protected $signature = 'site:quiet {state=status : on, off, or status}';
|
||||
protected $description = 'Hide airport ads and recommendations';
|
||||
protected $description = 'Pause free-node publishing and hide airport promotions without deleting data';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
@@ -36,7 +36,7 @@ public function handle(): int
|
||||
} finally { if (is_file($temporary)) unlink($temporary); }
|
||||
\Spatie\ResponseCache\Facades\ResponseCache::clear();
|
||||
}
|
||||
$this->info('暂避风头模式:'.(SiteMode::quiet() ? '开启(机场广告及推荐隐藏,节点照常发布)' : '关闭(正常模式)'));
|
||||
$this->info('暂避风头模式:'.(SiteMode::quiet() ? '开启(节点更新暂停,机场广告隐藏)' : '关闭(正常模式)'));
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\{AirportDomains,SiteMode};
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
final class VerifyDomainHub extends Command
|
||||
{
|
||||
protected $signature='domainhub:verify';
|
||||
protected $description='Verify that the application reads the current public domain snapshot';
|
||||
public function handle(): int
|
||||
{
|
||||
$s=AirportDomains::snapshot();
|
||||
if (! $s || (int)getenv('DOMAINHUB_EXPECT_VERSION') !== ($s['manifest']['version']??null)) return self::FAILURE;
|
||||
$this->line(json_encode(['version'=>$s['manifest']['version'],'enabled'=>(bool)config('domainhub.enabled'),'quiet'=>SiteMode::quiet(),'banners'=>collect(config('advertising'))->map(fn($p)=>(bool)$p['enabled'])->all(),'recommendations'=>(bool)config('airport_recommendations.enabled')],JSON_THROW_ON_ERROR));
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ public function receive(Request $oRequest)
|
||||
$aOptTag = explode(",", $sOptTag);
|
||||
|
||||
$oCategory = Categories::where("sName", $sOptCategoryName)->first();
|
||||
\App\Services\SiteMode::assertUpdatesAllowed($oCategory?->sSlug);
|
||||
|
||||
if (!$oCategory) {
|
||||
$sMsg = "不存在的文章分类:{$sOptCategoryName}";
|
||||
@@ -63,6 +64,7 @@ public function receive(Request $oRequest)
|
||||
];
|
||||
|
||||
$oArticle = Articles::where("sSlug", $sSlug)->first();
|
||||
if ($oArticle) \App\Services\SiteMode::assertUpdatesAllowed($oArticle->oCategory?->sSlug);
|
||||
|
||||
if ($oArticle && \Illuminate\Support\Facades\DB::table('editorial_documents')->where('article_id',$oArticle->id)->exists()) {
|
||||
abort(409, 'This article is managed by the editorial API');
|
||||
@@ -186,6 +188,7 @@ public function receiveShadowrocketids(Request $oRequest)
|
||||
|
||||
public function receiveFreenode(Request $oRequest)
|
||||
{
|
||||
\App\Services\SiteMode::assertUpdatesAllowed('freenode');
|
||||
$sObjName = "nodehub:article_receive_freenodeV2";
|
||||
$oFlow = Flow::make($sObjName);
|
||||
|
||||
@@ -265,6 +268,7 @@ public function receiveFreenode(Request $oRequest)
|
||||
|
||||
public function receiveFreenode_laji(Request $oRequest)
|
||||
{
|
||||
\App\Services\SiteMode::assertUpdatesAllowed('freenode');
|
||||
$sObjName = "nodehub:article_receive_freenode";
|
||||
$oFlow = Flow::make($sObjName);
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ public function scopePublicVisible($query)
|
||||
protected static function booted()
|
||||
{
|
||||
static::saving(function ($article) {
|
||||
\App\Services\SiteMode::guardArticle($article);
|
||||
// Historical test fixtures and migration tooling may use the pre-SEO schema.
|
||||
if (!\Illuminate\Support\Facades\Schema::hasColumn('articles', 'sContentUpdatedAt')) return;
|
||||
if (!$article->exists || $article->isDirty(['sTitle','sTitleSub','sContent','sThumb','iCategoryId','iStatus','bPageThumb'])) {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
final class AirportDomains
|
||||
{
|
||||
public static function snapshot(): ?array
|
||||
{
|
||||
$path=config('domainhub.state_path');
|
||||
if (! $path || ! is_file($path)) return null;
|
||||
try {$s=json_decode(file_get_contents($path),true,32,JSON_THROW_ON_ERROR);} catch (\Throwable) {return null;}
|
||||
$m=$s['manifest']??[];
|
||||
$watermark=json_decode(@file_get_contents($path.'.watermark') ?: '{}',true);
|
||||
if (($watermark['version']??null)!==($m['version']??null) || ! is_string($s['digest']??null) || ! hash_equals($watermark['digest']??'', $s['digest'])) return null;
|
||||
if (($m['schema']??null)!=='domainhub.public.v1' || ($m['project']??null)!==config('domainhub.project') || ($m['environment']??null)!==config('domainhub.environment') || ($m['instance']??null)!==config('domainhub.instance')) return null;
|
||||
if (! is_int($s['checked_at']??null) || $s['checked_at']>time()+120 || time()-$s['checked_at']>config('domainhub.max_age')) return null;
|
||||
return $s;
|
||||
}
|
||||
public static function target(string $provider): ?string
|
||||
{
|
||||
if (! array_key_exists($provider,config('airport_recommendations.providers',[]))) return null;
|
||||
$s=self::snapshot(); $entry=$s['manifest']['providers'][$provider]['selected']??null;
|
||||
if (! $entry || ($entry['eligible']??false)!==true || ($entry['access']??null)!=='available' || ($entry['reason']??null)!==null) return null;
|
||||
if (! empty($entry['valid_until']) && strtotime($entry['valid_until'].' UTC')<=time()) return null;
|
||||
$url=$entry['url']??''; $u=parse_url($url);
|
||||
if (! filter_var($url,FILTER_VALIDATE_URL) || ($u['scheme']??null)!=='https' || empty($u['host']) || isset($u['user']) || isset($u['pass']) || isset($u['query']) || isset($u['fragment']) || (isset($u['port']) && $u['port']!==443)) return null;
|
||||
return $url;
|
||||
}
|
||||
public static function link(string $provider, string $placement): ?string
|
||||
{
|
||||
if (SiteMode::quiet()) return null;
|
||||
$enabled=$placement==='banner' ? config('advertising.'.$provider.'.enabled',false) : (config('airport_recommendations.enabled',false) && config('airport_recommendations.providers.'.$provider.'.enabled',false));
|
||||
if (! $enabled) return null;
|
||||
if (! config('domainhub.enabled')) return $placement==='banner' ? config('advertising.'.$provider.'.url') : config('airport_recommendations.providers.'.$provider.'.url');
|
||||
return self::target($provider) ? '/go/airport/'.$provider.'/'.$placement : null;
|
||||
}
|
||||
public static function redirect(string $provider, string $placement)
|
||||
{
|
||||
$headers=['Cache-Control'=>'no-store, private','X-Robots-Tag'=>'noindex, nofollow','Referrer-Policy'=>'no-referrer'];
|
||||
$target=config('domainhub.enabled') && self::link($provider,$placement) ? self::target($provider) : null;
|
||||
return $target ? response('',302,[...$headers,'Location'=>$target]) : response('该入口暂不可用,请返回查看其他内容。',410,$headers);
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,9 @@ final class ArticleRecommendations
|
||||
public static function providers(): array
|
||||
{
|
||||
if (SiteMode::quiet() || ! config('airport_recommendations.enabled')) return [];
|
||||
$providers = [];
|
||||
foreach (config('airport_recommendations.providers', []) as $key => $provider) {
|
||||
$url = AirportDomains::link($key, 'recommendation');
|
||||
if ($url) $providers[$key] = [...$provider, 'url' => $url];
|
||||
}
|
||||
$providers = array_filter(config('airport_recommendations.providers', []), fn ($p) =>
|
||||
($p['enabled'] ?? false) && filter_var($p['url'] ?? '', FILTER_VALIDATE_URL)
|
||||
&& in_array(parse_url($p['url'], PHP_URL_SCHEME), ['https', 'http'], true));
|
||||
uasort($providers, fn ($a, $b) => ($a['order'] ?? 0) <=> ($b['order'] ?? 0));
|
||||
return $providers;
|
||||
}
|
||||
@@ -30,7 +28,7 @@ public static function prepare(Articles $article): array
|
||||
|| $category?->oParent?->sSlug === 'client';
|
||||
$quiet = SiteMode::quiet();
|
||||
$enabled = $scope && self::providers() !== [];
|
||||
if (! $scope && ! $quiet) return ['body' => $html, 'enabled' => false, 'inline' => false];
|
||||
if (! $enabled && ! $quiet) return ['body' => $html, 'enabled' => false, 'inline' => false];
|
||||
|
||||
$inline = false;
|
||||
if (in_array($slug, ['freenode', 'shadowrocketids'], true)) {
|
||||
@@ -51,7 +49,7 @@ public static function prepare(Articles $article): array
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($quiet || ! $enabled) {
|
||||
if ($quiet) {
|
||||
$html = str_replace(self::SLOT, '', $html);
|
||||
$html = preg_replace('~<p\b[^>]*class=["\'][^"\']*airport-recommendation-jump[^"\']*["\'][^>]*>.*?</p>~si', '', $html);
|
||||
return ['body' => $html, 'enabled' => false, 'inline' => false];
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Articles;
|
||||
use App\Models\Categories;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
|
||||
final class SiteMode
|
||||
{
|
||||
public static function quiet(): bool
|
||||
@@ -9,7 +13,28 @@ public static function quiet(): bool
|
||||
$path = config('site_mode.state_path');
|
||||
if (! $path || ! is_file($path)) return (bool) config('site_mode.quiet', false);
|
||||
$state = json_decode((string) file_get_contents($path), true);
|
||||
// An unreadable/invalid operational flag keeps promotions hidden.
|
||||
// An unreadable/invalid operational flag must not silently resume publishing.
|
||||
return ! is_array($state) || ! is_bool($state['quiet'] ?? null) || $state['quiet'];
|
||||
}
|
||||
|
||||
public static function assertUpdatesAllowed(?string $type): void
|
||||
{
|
||||
if ($type !== 'freenode' || ! self::quiet()) return;
|
||||
throw new HttpResponseException(response()->json([
|
||||
'isDone' => false, 'status' => 'paused', 'code' => 'FREE_NODE_UPDATES_PAUSED',
|
||||
'message' => 'Free node updates are temporarily paused; existing publications are retained.',
|
||||
], 503, ['Retry-After' => '3600']));
|
||||
}
|
||||
|
||||
public static function guardArticle(Articles $article): void
|
||||
{
|
||||
if (! self::quiet()) return;
|
||||
$fields = ['sSlug','iCategoryId','sTitle','sTitleSub','sContent','sThumb',
|
||||
'iStatus','created_at','sDisplayPublishedAt','sResourceStatus','iResourceCount'];
|
||||
if ($article->exists && ! $article->isDirty($fields)) return;
|
||||
$ids = array_filter([$article->iCategoryId, $article->getRawOriginal('iCategoryId')]);
|
||||
if ($ids && Categories::whereIn('id', $ids)->where('sSlug', 'freenode')->exists()) {
|
||||
self::assertUpdatesAllowed('freenode');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'enabled' => env('DOMAINHUB_PUBLIC_ENABLED', false),
|
||||
'state_path' => env('DOMAINHUB_PUBLIC_STATE', storage_path('app/private/domainhub-public/state.json')),
|
||||
'project' => 'fna_v3',
|
||||
'environment' => env('APP_ENV', 'production') === 'production' ? 'production' : 'local',
|
||||
'instance' => 'advertising',
|
||||
'max_age' => 86400,
|
||||
];
|
||||
@@ -109,7 +109,8 @@ ## 2 当前文章登记
|
||||
| cfw-mac-legacy | 210 / 进阶教程 | Clash Verge Rev 使用教程:Mac 安装、订阅与系统代理 | `/a/m173.html` | [verge-mac.md](tutorials/verge-mac.md);本地API版本3 | Mac操作入口;#install DMG安装,#import 订阅,系统代理与退出排错;无设备联网实测 |
|
||||
| cfw-linux-legacy | 211 / 进阶教程 | Clash Verge Rev 使用教程:Linux 安装、订阅与代理设置 | `/a/m174.html` | [verge-linux.md](tutorials/verge-linux.md);本地API版本6 | Linux桌面入门;#install 包格式与架构,#import 订阅,#terminal 单条curl代理验证;不适用于无桌面的服务器 |
|
||||
| system-proxy-vs-tun | 365 / 进阶教程 | 系统代理和 TUN 有什么区别?接管范围、使用选择与排错 | `/a/system-proxy-vs-tun.html` | [system-proxy-tun.md](tutorials/system-proxy-tun.md);本地API版本1 | 桌面代理接管与出口选择;`#choose` 场景选择、`#switch` 切换检查、`#troubleshoot` 排错;三张流程图 |
|
||||
| clash-routing-modes | 366 / 进阶教程 | Clash 规则、全局和直连怎么选?代理组与分流排错教程 | `/a/clash-rule-global-direct.html` | [clash-routing-modes.md](tutorials/clash-routing-modes.md);2026-10-31本地ID366/版本1,正式ID382/版本1已发布 | 模式选择与代理组分流;`#groups` 组内选择、`#custom` 添加规则、`#verify` 验证新连接 |
|
||||
| clash-routing-modes | 366 / 进阶教程 | Clash 规则、全局和直连怎么选?代理组与分流排错教程 | `/a/clash-rule-global-direct.html` | [clash-routing-modes.md](tutorials/clash-routing-modes.md);2026-11-03本地ID366/版本2,正式ID382/版本2已发布(补测速入口) | 模式选择与代理组分流;`#groups` 组内选择、`#custom` 添加规则、`#verify` 验证新连接 |
|
||||
| clash-node-performance | 377 / 进阶教程 | 节点延迟低,为什么还是慢?Clash 测速与选节点指南 | `/a/clash-node-speed-test.html` | [node-performance.md](tutorials/node-performance.md);2026-11-03本地ID377/版本1,正式ID399/版本1已发布 | 延迟、吞吐量与稳定性;`#compare` 控制条件比较、`#auto` 自动选择边界、`#timeout` 超时排查;双比例纸艺图与两组HTML图解 |
|
||||
| free-nodes-explained | 375 / 新手教程(client) | 免费节点是什么?能用来做什么?给第一次接触的人看 | `/a/free-nodes-explained.html` | [free-nodes-explained.md](tutorials/newcomer/free-nodes-explained.md);本地API版本2(日常网页场景);2026-11-03正式ID397/版本1已发布并置顶 | 零基础概念说明;`#what` 中转机制、`#uses` 用途、`#three-things` 客户端/节点/订阅、`#start` 下一步。免费节点详情页自动关联。 |
|
||||
| shadowrocket-id-explained | 376 / 新手教程(client) | 免费小火箭 ID 是什么?账号、客户端和节点有什么区别? | `/a/shadowrocket-id-explained.html` | [shadowrocket-id-explained.md](tutorials/newcomer/shadowrocket-id-explained.md);本地API版本1;2026-11-03正式ID398/版本1已发布并置顶 | 解释 App Store 账号用途;`#difference` 概念区分、`#where` 与 iCloud 区别、`#resource-page` 账号页字段、`#installed` 安装后需要节点。免费小火箭ID详情页自动关联。 |
|
||||
| newcomer-start | 373 / 新手教程(client) | 新手指引:从免费订阅到第一次连接 | `/a/getting-started.html` | [start.md](tutorials/newcomer/start.md);本地API版本4(补基础说明入口);2026-11-03正式ID393/版本2已发布 | 先选设备,再下载安装、导入对应格式的免费订阅并连接。Windows、Mac、安卓、iPhone、Linux和路由器的入口都在这里。 |
|
||||
@@ -123,6 +124,8 @@ ## 2 当前文章登记
|
||||
|
||||
2026-10-31新教程正式ID382/版本1、本地ID366/版本1已发表;系统代理/TUN正文补入口后两环境均为API版本2(正式ID376、本地ID365)。正式发布时间14:58:28北京时间,IndexNow由VPS-003提交返回200,服务器HTTP与图哈希/锚点验收通过。唯一状态与恢复记录见[规则模式教程发布记录](../maintenance/ROUTING_MODES_2026-10-31.md)。
|
||||
|
||||
2026-11-03周期首篇测速教程正式ID399/版本1已发布,规则模式旧文升至版本2。发布、配图、点赞与验收见[测速教程发布记录](../maintenance/NODE_PERFORMANCE_2026-11-03.md)。
|
||||
|
||||
这里只登记长期编辑内容及值得复用的稳定资源说明,不逐条收录日更节点或账号文章。当前本地/正式稳定入口为 `/`(免费节点)、`/shadowrocketids`(免费小火箭ID)、`/history/freenode` 与 `/history/shadowrocketids`(对应往期)、`/client`(新手教程)、`/advanced`(进阶教程)。2026-11-03入口/往期调整已上线,实施及部署边界见[SEO实施维护](../maintenance/SEO_IMPLEMENTATION_2026-10-31.md#稳定入口与往期内容2026-11-02已本地实施未发布);平台入口和名称修改另按项目路由核对,不从名称自行拼接。
|
||||
|
||||
2026-10-29部署边界更新:上表10篇已通过本站API迁移到独立test并经用户确认后切到正式cfn,旧URL保留;生产发布以预览实际正文冻结再发布,未用test整库覆盖。test和生产的临时编辑密钥均在迁移后删除,接口默认关闭;后续本地写作继续使用本地API,正式编辑按明确任务与生产绑定启用。实际部署及验收统一见[发布记录](../maintenance/RELEASE_PREFLIGHT_2026-10-28.md#正式切换2026-10-29),上表ID仍为本地ID。
|
||||
@@ -168,6 +171,11 @@ ## 3 已有文章关系
|
||||
| clash-routing-modes | verge-windows-start `#enable` / cfw-mac-legacy `#enable` | 尚未完成基本连接时返回对应平台操作 | 2026-10-31本地与正式已发布 |
|
||||
| clash-routing-modes | system-proxy-vs-tun `#routing` / `#troubleshoot` | 解释接管和分流的区别,以及看不到连接时排错 | 2026-10-31本地与正式已发布 |
|
||||
| clash-routing-modes | mihomo-dns `#dns-2` | 出口正确但域名解析仍异常时继续查DNS | 2026-10-31本地与正式已发布 |
|
||||
| clash-node-performance | newcomer-start `#devices` / newcomer-clients `#verge` | 尚未导入订阅或需要安装时回到实际操作和Resource优先下载入口 | 2026-11-03本地与正式已发布 |
|
||||
| clash-node-performance | clash-routing-modes `#groups` | 比较节点前固定实际命中的代理组与出口 | 2026-11-03本地与正式已发布 |
|
||||
| clash-node-performance | system-proxy-vs-tun `#troubleshoot` | 连接列表找不到目标应用时检查接管 | 2026-11-03本地与正式已发布 |
|
||||
| clash-node-performance | free-nodes-explained `#free` | 解释免费节点可用性与负载变化 | 2026-11-03本地与正式已发布 |
|
||||
| clash-routing-modes | clash-node-performance `#compare` | 自动选择说明之后补充延迟低但下载慢的对比方法 | 2026-11-03本地与正式已发布 |
|
||||
|
||||
两篇Android教程通过订阅格式段落互链;Mac下载指南与操作教程互链,Linux从下载指南和真实Linux栏目获得入口,iOS沿用真实iOS栏目入口。系统代理与TUN专题由Windows和DNS正文提供入口,并指向三平台的基础操作及DNS专题。目录、标签、导航和热门榜不算正文关联;正文内链及锚点已经本地HTTP验证。
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 621 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 744 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"key": "cover",
|
||||
"prompt": "Use case: stylized-concept. Create one polished editorial illustration for a Chinese networking tutorial, landscape EXACT 3:2 canvas 1536x1024. Theme: a low response delay does not imply high sustained download speed. Medium: tactile paper-cut collage and realistic miniature diorama, layered fibrous cardstock, small folded paper objects, soft directional shadows, rich but restrained ink colors. Entirely original composition, no device trays, no laptops, no mountains or map roads. Scene: an intimate miniature parcel sorting workshop. A little vermilion express courier carrying a single cream envelope has just reached a compact clock-shaped arch at left; at right a broad turquoise conveyor is carrying MANY orderly cream parcels into a navy sorting warehouse. Single small fast delivery vs many parcels per second is the visual metaphor. Above the scene large bold immaculate Chinese title exactly '延迟低,为什么还慢?', with comfortable breathing room. Warm ivory backdrop, muted vermilion, petrol blue and teal palette, asymmetric diagonal tabletop view, engaging adult editorial craft aesthetic, not toy plastic. Only other text is subtle clearly legible exact website watermark 'clashfreenode.com' at bottom right with safe margins; no other English, no numeric fake benchmarks. Objects, title, watermark fully within canvas. Not a generic infographic with flat icons; beautiful tangible paper sculpture."
|
||||
},
|
||||
{
|
||||
"key": "hero",
|
||||
"prompt": "Use case: stylized-concept. Create one Chinese article hero illustration with EXACT 12:5 landscape canvas, width1920 height800, aspect2.4:1, NOT3:1 or16:9. Independently designed low wide composition about network response latency versus sustained throughput. Tactile fibrous paper collage combined with a handcrafted miniature parcel logistics diorama. In the left 40% a cream layered paper label with large dark navy Chinese typography exactly '看延迟,也看速度'; below in smaller Chinese exactly '选节点,还要看稳定性'. Along right 60% a long horizontal cross-section of a tiny parcel workshop: a red express trolley delivers one envelope through a compact brass paper stopwatch ring while a much wider turquoise paper conveyor behind it moves many cream parcels toward a paper warehouse. A row of regular small hanging warm lamps suggests consistent delivery. Camera is low oblique, different from a tall cover composition, spacious but not empty. Theme communicated by physical props, not arrows or technical chart. Palette ivory, petrol navy, muted vermilion and teal, natural soft light/shadows, real layered cut edges and folded-paper texture. No mountains, map roads, devices, trays, or potted plants. No outer borders, letterboxing or blank padded bands. Fill native12:5 frame with a deliberately arranged wide scene, never crop/stretch another picture. Exact small but crisp watermark 'clashfreenode.com' at bottom right safely inset. No other text."
|
||||
}
|
||||
]
|
||||
@@ -1 +1 @@
|
||||
<link rel="stylesheet" href="/css/tutorials.css"><div class="tutorial-body"><p>同一个网站,规则模式打不开,切成全局却正常;明明选了新节点,连接记录里还是另一个名字。遇到这类问题,先看这条连接实际走了哪条规则、哪个代理组,再决定要改什么。</p><p>本文以 Clash Verge Rev 和 Mihomo 为例,讲清规则、全局、直连三个模式,并完成一次“只让指定网站走指定出口”的配置。还没有完成导入和首次连接,可以先看 <a href="/a/clash-verge-rev-windows.html#enable">Windows 入门教程</a>;Mac 用户可以从<a href="/a/m173.html#enable">对应操作步骤</a>开始。</p><nav class="guide-toc" aria-label="文章目录"><strong>阅读路线</strong><a href="#modes">三个模式怎么选</a><a href="#groups">为什么换节点没效果</a><a href="#order">规则先后顺序</a><a href="#custom">添加一条网站规则</a><a href="#verify">从连接记录验证</a><a href="#troubleshoot">按现象排查</a></nav><h2 id="modes">01 三个模式,改变的是出口选择</h2><p>先确定前提:请求已经进入了客户端。系统代理、应用自身代理设置和 TUN 负责把流量送进来,下面三个模式负责决定进去以后怎样处理。未被接管的应用,不会因为切到全局就自动经过客户端;接管方式见<a href="/a/system-proxy-vs-tun.html#routing">系统代理与 TUN 的区别</a>。</p><div class="table-wrap"><table><thead><tr><th>模式</th><th>进入客户端后的普通业务连接</th><th>适合什么时候用</th></tr></thead><tbody><tr><td>规则(Rule)</td><td>按当前配置匹配规则,选择直连、代理组或其他策略</td><td>日常分流:不同网站使用不同出口</td></tr><tr><td>全局(Global)</td><td>使用 GLOBAL 组当前选择的节点或策略</td><td>临时对比:判断问题是否与分流结果有关</td></tr><tr><td>直连(Direct)</td><td>由本地网络直接连接目标</td><td>临时检查本地网络,或不需要代理出口时</td></tr></tbody></table></div><p>这三个模式是路由选择,不是速度档位。全局也要检查 GLOBAL 组究竟选了什么:如果选的是 DIRECT,结果仍然是直连;如果选的是另一个代理组,还要继续看那个组的选择。<a href="https://wiki.metacubex.one/config/general/">Mihomo 运行模式说明</a></p><p>直连模式也不等于退出客户端:系统代理、TUN 等入口可能仍开启。要停用接管,需要处理对应开关,不能只把模式改成“直连”。<a href="https://www.clashverge.dev/guide/term.html">Clash Verge Rev 名词解释</a></p><figure class="guide-figure"><img src="/images/editorial/98a43bdd771dd4c6c5ec6b87bb5f0ebf679fa2b228dddbb764adecf50b0374e9.png" alt="请求进入客户端后,规则模式按规则分流,全局模式使用 GLOBAL 选择,直连模式使用本地网络" width="1000" height="670"><figcaption>图 1:模式作用于已进入客户端的连接;切模式不会补上接管范围的缺口。</figcaption></figure><h2 id="groups">02 换了节点没效果,可能换错了组</h2><p>代理页里有“节点选择”“流媒体”“自动选择”等分组时,不要把它们当成一排作用相同的开关。规则通常先指向一个组,组再选节点,也可能继续选另一个组。</p><p>例如,一份配置把视频网站分给“影音”,普通网页交给“节点选择”。你在“节点选择”里换成节点乙,但“影音”仍直接选着节点甲,视频连接就可能继续走甲。只有“影音”选择了“节点选择”这个组,它才会沿着这条选择关系继续向下找出口。</p><figure class="guide-figure"><img src="/images/editorial/417b203a4af30200b6ed3b37d0b0e823a9b47db49e2d743b1110b35329cc5de8.png" alt="规则命中影音组后,该组直接选择节点甲时不经过节点选择组;选择节点选择组时才跟随其中的节点乙" width="1000" height="610"><figcaption>图 2:两种配置的差别在于“影音”组的选择。组名只是配置中的名称,实际关系要查看当前选择。</figcaption></figure><p>手动选择组(<code>select</code>)由你决定使用哪个选项;如果它选择的是自动选择组(<code>url-test</code>),后者仍会按自己的测速配置选择节点。想固定到具体节点,就检查整条选择路径,而不是只看最外层的组名。<a href="https://wiki.metacubex.one/config/proxy-groups/select/">手动选择组</a>与<a href="https://wiki.metacubex.one/config/proxy-groups/url-test/">自动选择组</a></p><p>实际排查时,可以在连接详情里找策略、代理链或类似字段。不同界面展示顺序可能不同,重点是认出“命中了哪个组”和“最终使用哪个节点”。</p><h2 id="order">03 先看顺序,再看规则写得对不对</h2><p>Mihomo 的路由规则从上往下匹配。通常前面命中的规则就决定Line truncated
|
||||
<link rel="stylesheet" href="/css/tutorials.css"><div class="tutorial-body"><p>同一个网站,规则模式打不开,切成全局却正常;明明选了新节点,连接记录里还是另一个名字。遇到这类问题,先看这条连接实际走了哪条规则、哪个代理组,再决定要改什么。</p><p>本文以 Clash Verge Rev 和 Mihomo 为例,讲清规则、全局、直连三个模式,并完成一次“只让指定网站走指定出口”的配置。还没有完成导入和首次连接,可以先看 <a href="/a/clash-verge-rev-windows.html#enable">Windows 入门教程</a>;Mac 用户可以从<a href="/a/m173.html#enable">对应操作步骤</a>开始。</p><nav class="guide-toc" aria-label="文章目录"><strong>阅读路线</strong><a href="#modes">三个模式怎么选</a><a href="#groups">为什么换节点没效果</a><a href="#order">规则先后顺序</a><a href="#custom">添加一条网站规则</a><a href="#verify">从连接记录验证</a><a href="#troubleshoot">按现象排查</a></nav><h2 id="modes">01 三个模式,改变的是出口选择</h2><p>先确定前提:请求已经进入了客户端。系统代理、应用自身代理设置和 TUN 负责把流量送进来,下面三个模式负责决定进去以后怎样处理。未被接管的应用,不会因为切到全局就自动经过客户端;接管方式见<a href="/a/system-proxy-vs-tun.html#routing">系统代理与 TUN 的区别</a>。</p><div class="table-wrap"><table><thead><tr><th>模式</th><th>进入客户端后的普通业务连接</th><th>适合什么时候用</th></tr></thead><tbody><tr><td>规则(Rule)</td><td>按当前配置匹配规则,选择直连、代理组或其他策略</td><td>日常分流:不同网站使用不同出口</td></tr><tr><td>全局(Global)</td><td>使用 GLOBAL 组当前选择的节点或策略</td><td>临时对比:判断问题是否与分流结果有关</td></tr><tr><td>直连(Direct)</td><td>由本地网络直接连接目标</td><td>临时检查本地网络,或不需要代理出口时</td></tr></tbody></table></div><p>这三个模式是路由选择,不是速度档位。全局也要检查 GLOBAL 组究竟选了什么:如果选的是 DIRECT,结果仍然是直连;如果选的是另一个代理组,还要继续看那个组的选择。<a href="https://wiki.metacubex.one/config/general/">Mihomo 运行模式说明</a></p><p>直连模式也不等于退出客户端:系统代理、TUN 等入口可能仍开启。要停用接管,需要处理对应开关,不能只把模式改成“直连”。<a href="https://www.clashverge.dev/guide/term.html">Clash Verge Rev 名词解释</a></p><figure class="guide-figure"><img src="/images/editorial/98a43bdd771dd4c6c5ec6b87bb5f0ebf679fa2b228dddbb764adecf50b0374e9.png" alt="请求进入客户端后,规则模式按规则分流,全局模式使用 GLOBAL 选择,直连模式使用本地网络" width="1000" height="670"><figcaption>图 1:模式作用于已进入客户端的连接;切模式不会补上接管范围的缺口。</figcaption></figure><h2 id="groups">02 换了节点没效果,可能换错了组</h2><p>代理页里有“节点选择”“流媒体”“自动选择”等分组时,不要把它们当成一排作用相同的开关。规则通常先指向一个组,组再选节点,也可能继续选另一个组。</p><p>例如,一份配置把视频网站分给“影音”,普通网页交给“节点选择”。你在“节点选择”里换成节点乙,但“影音”仍直接选着节点甲,视频连接就可能继续走甲。只有“影音”选择了“节点选择”这个组,它才会沿着这条选择关系继续向下找出口。</p><figure class="guide-figure"><img src="/images/editorial/417b203a4af30200b6ed3b37d0b0e823a9b47db49e2d743b1110b35329cc5de8.png" alt="规则命中影音组后,该组直接选择节点甲时不经过节点选择组;选择节点选择组时才跟随其中的节点乙" width="1000" height="610"><figcaption>图 2:两种配置的差别在于“影音”组的选择。组名只是配置中的名称,实际关系要查看当前选择。</figcaption></figure><p>手动选择组(<code>select</code>)由你决定使用哪个选项;如果它选择的是自动选择组(<code>url-test</code>),后者仍会按自己的测速配置选择节点。想固定到具体节点,就检查整条选择路径,而不是只看最外层的组名。<a href="https://wiki.metacubex.one/config/proxy-groups/select/">手动选择组</a>与<a href="https://wiki.metacubex.one/config/proxy-groups/url-test/">自动选择组</a></p><p>实际排查时,可以在连接详情里找策略、代理链或类似字段。不同界面展示顺序可能不同,重点是认出“命中了哪个组”和“最终使用哪个节点”。</p><p>自动选择更看重测试地址的响应时间,不等于下载速度排名。节点延迟很低却仍然卡顿时,可以按<a href="/a/clashLine truncated
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
实际排查时,可以在连接详情里找策略、代理链或类似字段。不同界面展示顺序可能不同,重点是认出“命中了哪个组”和“最终使用哪个节点”。
|
||||
|
||||
<p>自动选择更看重测试地址的响应时间,不等于下载速度排名。节点延迟很低却仍然卡顿时,可以按<a href="/a/clash-node-speed-test.html#compare">延迟、速度与稳定性的对比步骤</a>做一次小范围筛选。</p>
|
||||
|
||||
<h2 id="order">03 先看顺序,再看规则写得对不对</h2>
|
||||
|
||||
Mihomo 的路由规则从上往下匹配。通常前面命中的规则就决定了后续策略,因此“更精确”不会自动获得更高优先级;精确规则如果排在已经覆盖它的规则之后,仍可能用不上。涉及 UDP 等条件时,还要注意目标策略是否具备相应支持。[路由规则与优先级](https://wiki.metacubex.one/config/rules/)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<link rel="stylesheet" href="/css/tutorials.css"><div class="tutorial-body"><figure class="guide-figure tutorial-hero"><img src="/images/editorial/63809168da585b4e88c2cd9b24f70251b4967115b1ec4483d31d50946500027b.jpg" width="1942" height="809" alt="纸艺快递车送出一封信,宽传送带持续输送包裹,分别比喻响应延迟与传输速度" decoding="async"></figure><p>节点列表里,一个显示 60 ms,另一个显示 180 ms。选了数字小的,网页却断断续续,下载也不快。这并不矛盾:<strong>延迟描述等一次响应要多久,下载速度描述一段时间能收到多少数据。</strong> 两者有关联,却不能互相换算。</p><p>挑节点,先用延迟测试排除明显不可用的选项,再用自己真正要完成的操作做比较。下面以 Clash Verge Rev 等使用 Mihomo 内核的客户端为例,说明测试数字怎么读、自动选择组怎么判断,以及遇到超时应该查哪里。</p><p>如果你还没有导入订阅,先按<a href="/a/getting-started.html#devices">新手指引</a>完成第一次连接;需要安装软件,可以从<a href="/a/proxy-clients.html#verge">客户端下载总览</a>选择对应版本。</p><nav class="guide-toc" aria-label="文章目录"><strong>阅读路线</strong><a href="#metrics">三个指标</a><a href="#test-path">测试测到了哪里</a><a href="#compare">比较两条节点</a><a href="#auto">自动选择的边界</a><a href="#timeout">超时怎么查</a><a href="#choose">按用途留下节点</a></nav><h2 id="metrics">01 延迟、速度、稳定性,分别看</h2><p>可以把网络传输想成送包裹:第一件到得早,不代表后面每秒都能送来很多件;平均送得多,也可能时快时慢。网络里的延迟、带宽与实际吞吐量也是不同指标。<a href="https://www.cloudflare.com/learning/performance/glossary/what-is-latency/">延迟与吞吐量的区别</a></p><figure class="starter-process"><div><b>延迟:等多久</b><span>一次测试要等多长时间<br>常见单位:ms</span></div><div><b>吞吐量:传多少</b><span>持续传输时每秒收到多少数据<br>常见单位:Mbps、MB/s</span></div><div><b>稳定性:是否连续</b><span>反复使用时会不会超时、停顿<br>看多次结果和实际过程</span></div><figcaption>同一条线路需要从不同角度观察;延迟数字不是综合评分。</figcaption></figure><p><strong>网页交互</strong>更容易让你感受到等待一次响应的时间;<strong>文件下载</strong>更依赖持续传输能力;<strong>通话等实时应用</strong>还需要关注中断、丢包和时延变化。一个短请求成功,不能代替对这些实际任务的验证。</p><p>速度单位也别看错:小写 b 表示 bit,大写 B 表示 Byte。按十进制单位换算,80 Mbps 相当于 10 MB/s;实际文件下载还受协议开销和整个传输路径影响。节点旁边的 80 ms 则是时间,和这两个速度没有这样的换算关系。</p><h2 id="test-path">02 节点旁的数字,取决于怎么测、测哪里</h2><p>在 Mihomo 的 URL 测试里,客户端通过节点向指定测试地址发起 HTTP 请求。它不是直接调用系统的 ICMP ping,也不是下载大文件测带宽。不同客户端、测试选项及内核设置可能采用不同计时方式,跨软件看到的数字不宜直接排在一起比较。</p><figure class="guide-diagram"><div class="diagram-label">同一节点,两个不同目的地</div><div class="guide-flow"><div>你的设备<small>发起请求</small></div><span>→</span><div>所选节点<small>转发连接</small></div><span>→</span><div>测试地址<small>得到一次延迟结果</small></div></div><div class="guide-branch">实际使用时,最后一站换成你要访问的网站。测试地址可用,不代表这个网站的访问路径和响应情况也相同。</div><figcaption>图中是简化路径。健康检查地址由配置决定,不能把一次测试的结果理解成“到所有网站都这么快”。</figcaption></figure><p>例如,健康检查很快,实际网站却响应缓慢,可能是节点到两个目的地的路径或网站服务状态不同。反过来,测试地址暂时不可用,也不能单凭一个红色结果认定该节点无法访问任何网站。健康检查的测试地址、超时时限和期望状态码都参与判断。<a href="https://wiki.metacubex.one/config/proxy-groups/">Mihomo 代理组配置</a></p><p>因此,比较节点时尽量使用<strong>同一个客户端、同一个测试地址、相近时间和同一网络</strong>。先把条件固定,数字才有比较价值。</p><h2 id="compare">03 用一次小范围对比,找到真正好用的节点</h2><p>不必把几十条免费节点全部跑满带宽。先从能通过测试的选项里挑两三条,逐条比较。</p><ol><li><strong>固定使用条件。</strong> 暂停正在进行的大文件下载和云盘同步,保持同Line truncated
|
||||
@@ -0,0 +1,101 @@
|
||||
<figure class="guide-figure tutorial-hero"><img src="/images/editorial/63809168da585b4e88c2cd9b24f70251b4967115b1ec4483d31d50946500027b.jpg" width="1942" height="809" alt="纸艺快递车送出一封信,宽传送带持续输送包裹,分别比喻响应延迟与传输速度" decoding="async"></figure>
|
||||
|
||||
节点列表里,一个显示 60 ms,另一个显示 180 ms。选了数字小的,网页却断断续续,下载也不快。这并不矛盾:**延迟描述等一次响应要多久,下载速度描述一段时间能收到多少数据。** 两者有关联,却不能互相换算。
|
||||
|
||||
挑节点,先用延迟测试排除明显不可用的选项,再用自己真正要完成的操作做比较。下面以 Clash Verge Rev 等使用 Mihomo 内核的客户端为例,说明测试数字怎么读、自动选择组怎么判断,以及遇到超时应该查哪里。
|
||||
|
||||
如果你还没有导入订阅,先按[新手指引](/a/getting-started.html#devices)完成第一次连接;需要安装软件,可以从[客户端下载总览](/a/proxy-clients.html#verge)选择对应版本。
|
||||
|
||||
<nav class="guide-toc" aria-label="文章目录"><strong>阅读路线</strong><a href="#metrics">三个指标</a><a href="#test-path">测试测到了哪里</a><a href="#compare">比较两条节点</a><a href="#auto">自动选择的边界</a><a href="#timeout">超时怎么查</a><a href="#choose">按用途留下节点</a></nav>
|
||||
|
||||
<h2 id="metrics">01 延迟、速度、稳定性,分别看</h2>
|
||||
|
||||
可以把网络传输想成送包裹:第一件到得早,不代表后面每秒都能送来很多件;平均送得多,也可能时快时慢。网络里的延迟、带宽与实际吞吐量也是不同指标。[延迟与吞吐量的区别](https://www.cloudflare.com/learning/performance/glossary/what-is-latency/)
|
||||
|
||||
<figure class="starter-process"><div><b>延迟:等多久</b><span>一次测试要等多长时间<br>常见单位:ms</span></div><div><b>吞吐量:传多少</b><span>持续传输时每秒收到多少数据<br>常见单位:Mbps、MB/s</span></div><div><b>稳定性:是否连续</b><span>反复使用时会不会超时、停顿<br>看多次结果和实际过程</span></div><figcaption>同一条线路需要从不同角度观察;延迟数字不是综合评分。</figcaption></figure>
|
||||
|
||||
**网页交互**更容易让你感受到等待一次响应的时间;**文件下载**更依赖持续传输能力;**通话等实时应用**还需要关注中断、丢包和时延变化。一个短请求成功,不能代替对这些实际任务的验证。
|
||||
|
||||
速度单位也别看错:小写 b 表示 bit,大写 B 表示 Byte。按十进制单位换算,80 Mbps 相当于 10 MB/s;实际文件下载还受协议开销和整个传输路径影响。节点旁边的 80 ms 则是时间,和这两个速度没有这样的换算关系。
|
||||
|
||||
<h2 id="test-path">02 节点旁的数字,取决于怎么测、测哪里</h2>
|
||||
|
||||
在 Mihomo 的 URL 测试里,客户端通过节点向指定测试地址发起 HTTP 请求。它不是直接调用系统的 ICMP ping,也不是下载大文件测带宽。不同客户端、测试选项及内核设置可能采用不同计时方式,跨软件看到的数字不宜直接排在一起比较。
|
||||
|
||||
<figure class="guide-diagram"><div class="diagram-label">同一节点,两个不同目的地</div><div class="guide-flow"><div>你的设备<small>发起请求</small></div><span>→</span><div>所选节点<small>转发连接</small></div><span>→</span><div>测试地址<small>得到一次延迟结果</small></div></div><div class="guide-branch">实际使用时,最后一站换成你要访问的网站。测试地址可用,不代表这个网站的访问路径和响应情况也相同。</div><figcaption>图中是简化路径。健康检查地址由配置决定,不能把一次测试的结果理解成“到所有网站都这么快”。</figcaption></figure>
|
||||
|
||||
例如,健康检查很快,实际网站却响应缓慢,可能是节点到两个目的地的路径或网站服务状态不同。反过来,测试地址暂时不可用,也不能单凭一个红色结果认定该节点无法访问任何网站。健康检查的测试地址、超时时限和期望状态码都参与判断。[Mihomo 代理组配置](https://wiki.metacubex.one/config/proxy-groups/)
|
||||
|
||||
因此,比较节点时尽量使用**同一个客户端、同一个测试地址、相近时间和同一网络**。先把条件固定,数字才有比较价值。
|
||||
|
||||
<h2 id="compare">03 用一次小范围对比,找到真正好用的节点</h2>
|
||||
|
||||
不必把几十条免费节点全部跑满带宽。先从能通过测试的选项里挑两三条,逐条比较。
|
||||
|
||||
1. **固定使用条件。** 暂停正在进行的大文件下载和云盘同步,保持同一个 Wi-Fi 或有线网络。保留当前可用节点的名称,方便随时切回。
|
||||
2. **确认实际出口。** 在目标网站对应的代理组中选中一个具体节点;若组里仍选择“自动选择”,测试过程中出口可能变化。打开连接记录,确认目标域名的新连接确实走了这条节点。组的嵌套关系见[代理组选择说明](/a/clash-rule-global-direct.html#groups)。
|
||||
3. **看几次延迟,而不是最低一次。** 隔开几秒测试三次,记下是否超时、结果是否大幅变化。三次只是快速筛选,不足以算出可靠丢包率,也不能代表全天表现。
|
||||
4. **做原本要做的事。** 打开同一个实际网页,检查文字、图片和登录等操作是否完整。仅看到缓存页面秒开不能作为连接恢复的证据,要确认有新的网络请求。
|
||||
5. **确实需要下载时再看持续速度。** 用同一来源、同一文件和同一下载方式,观察十几秒的持续速度与停顿,再停止测试。切到另一条节点重新建立连接后重复;别把浏览器单连接下载与测速工具的多连接峰值直接比较。
|
||||
|
||||
下面是一份**假设记录**,用于说明怎样做选择,不是节点测评结果,也不是速度及格线:
|
||||
|
||||
<div class="table-wrap">
|
||||
|
||||
| 候选节点 | 三次延迟测试 | 同一下载任务 | 同一网页操作 |
|
||||
| --- | --- | --- | --- |
|
||||
| 甲 | 60 / 65 / 62 ms | 约 0.8 MB/s,基本连续 | 能正常完成 |
|
||||
| 乙 | 180 / 185 / 178 ms | 约 4 MB/s,基本连续 | 能正常完成 |
|
||||
| 丙 | 45 ms / 超时 / 310 ms | 速度跳动,数次停住 | 偶尔失败 |
|
||||
|
||||
</div>
|
||||
|
||||
需要下载时,乙可能更合适;以短小网页交互为主时,可以继续对比甲与乙的实际等待感受。丙虽然出现过最低数字,但不能因此排第一。免费节点的负载和可用性会变化,这张记录只帮助你决定**现在用哪条**,不适合做永久排名。
|
||||
|
||||
<h2 id="auto">04 “自动选择”为什么没有选到下载最快的?</h2>
|
||||
|
||||
Mihomo 的 `url-test` 组围绕测试地址的延迟与可用性来选节点。它不会通过持续下载每条线路的大文件,替你比较下载吞吐量,所以选中的节点可能响应很快,却不适合你的大文件任务。[自动选择组说明](https://wiki.metacubex.one/config/proxy-groups/url-test/)
|
||||
|
||||
读配置时,先看这几个字段的含义,不必为了一个更小的数字就改配置:
|
||||
|
||||
<div class="table-wrap">
|
||||
|
||||
| 字段 | 表示什么 | 容易误解的地方 |
|
||||
| --- | --- | --- |
|
||||
| `url` | 健康检查访问的地址 | 不是对所有目标网站的综合检测 |
|
||||
| `interval` | 定时检查间隔,单位为秒 | 不是连续实时测速;调短也不会增加节点带宽 |
|
||||
| `timeout` | 一次健康检查的超时限制,单位为毫秒 | 调大只给请求更多等待时间,不会让慢连接加速 |
|
||||
| `tolerance` | 自动选择组的节点切换容差,单位为毫秒 | 当前节点正常时,不一定为了几毫秒差异切换 |
|
||||
| `lazy` | 是否在该策略组未被选用时暂停检查 | 看见旧测试值,不一定是客户端卡住了 |
|
||||
|
||||
</div>
|
||||
|
||||
如果订阅通过 `use` 引入 `proxy-providers`,还要看相应代理集合的 `health-check` 配置。不要以为改了代理组的测试地址,就同时改好了所有节点的健康检查。[代理组通用字段](https://wiki.metacubex.one/config/proxy-groups/)与[代理集合健康检查](https://wiki.metacubex.one/config/proxy-providers/#health-check)
|
||||
|
||||
当自动选择的结果不适合当前任务,可以在手动选择组中暂时固定到已经比较过的具体节点;使用结束后再决定是否恢复自动。直接编辑下载下来的订阅正文,可能被下一次更新覆盖;如果只是要固定选择,优先使用客户端现有的组内选择操作。
|
||||
|
||||
<h2 id="timeout">05 超时不等于只有一种故障</h2>
|
||||
|
||||
先观察是“一条失败”“所有测试都失败”,还是“测试正常、实际操作失败”。这三种情况的下一步不同。
|
||||
|
||||
<div class="table-wrap">
|
||||
|
||||
| 现象 | 先做什么 |
|
||||
| --- | --- |
|
||||
| 只有一条节点反复失败,其他正常 | 换一条可用节点对比;这条线路暂时不可用时先跳过,不必重装客户端 |
|
||||
| 所有节点测试失败,但实际网页可用 | 检查测试地址、超时和期望状态;确认测试结果是否及时刷新 |
|
||||
| 所有节点和实际访问都失败 | 先确认本地网络正常、订阅已成功更新,再看日志中的连接错误;不要同时改 DNS、TUN 和路由 |
|
||||
| 延迟正常,只有一个网站失败 | 核对这个网站的新连接、实际出口及网站自身状态,不能用测试地址的成功替代它 |
|
||||
| 切了节点,表现完全不变 | 看实际命中的代理组,重新建立目标连接,排除旧连接、缓存或目标流量未被接管 |
|
||||
|
||||
</div>
|
||||
|
||||
连接列表里根本找不到目标应用时,先看[系统代理与 TUN 的排查方法](/a/system-proxy-vs-tun.html#troubleshoot)。如果有记录,却走了别的节点,就回到分流和组内选择。先找到问题发生的位置,再考虑改参数。
|
||||
|
||||
<h2 id="choose">06 最后留下常用节点和一个备选</h2>
|
||||
|
||||
对免费节点来说,实用的选择是:当前任务能完成、连续使用没有明显停顿,再从中挑响应更合适的线路。保留一个经过同样操作验证的备选,比反复追逐列表里最低的毫秒数更方便。
|
||||
|
||||
普通浏览看页面与操作是否完整;下载看持续速度和停顿;通话则直接检查声音是否连贯。不同用途可以有不同选择,无需给一条节点评出适用于所有场景的总分。
|
||||
|
||||
如果不清楚节点为什么会失效、订阅更新又能改变什么,可以接着看[免费节点的用途与限制](/a/free-nodes-explained.html#free)。订阅里有多少条、测试时某一条多快,都不能保证你下一次使用时仍有同样表现。
|
||||
@@ -154,5 +154,3 @@ ## 本任务高度调整正式状态(2026-10-31)
|
||||
2026-10-31用户再次指定品牌大小写为 `HardNerd`(H/N大写)。内置image_gen只替换字标大小写,保持上一版品牌/标语比例、间距、图标与背景。当前素材 `public/images/ads/hn-ad-compact-HardNerd-20261031.png`(2020×778),提示词 `output/compact-ads-20261031/hn-hardnerd-case-prompt.txt`;本地随机组件引用及alt同步,旧图保留,未发布。
|
||||
|
||||
2026-11-03本地新增统一[暂避风头模式](QUIET_MODE.md),可临时隐藏本站机场广告及推荐,单独广告开关和原数据保留。验收后本地恢复关闭,未部署;操作账号、状态优先级和发布范围以该文为准。
|
||||
|
||||
2026-11-09公共域名自动选址与站内点击出口按[广告入口自动同步](DOMAINHUB_PUBLIC.md)维护;原投放开关保持最终决定权。
|
||||
@@ -39,5 +39,3 @@ ## Hardnerd优惠补齐(2026-10-31)
|
||||
用户确认hardnerd同样使用`clashfreenode.com`享9折。仅更新共享推荐配置的HN coupon/discount及对应渲染断言,所有引用页随配置/响应缓存刷新生效,无需逐篇编辑正文。不创建或修改HN服务端优惠码,不执行下单或优惠核销。Git提交、正式HEAD、恢复点和服务器验收回执见`output/hn-coupon-20261031/`。
|
||||
|
||||
2026-11-03本地新增统一[暂避风头模式](QUIET_MODE.md),可临时隐藏本站机场广告及推荐,单独广告开关和原数据保留。验收后本地恢复关闭,未部署;操作账号、状态优先级和发布范围以该文为准。
|
||||
|
||||
2026-11-09公共域名自动选址与站内点击出口按[广告入口自动同步](DOMAINHUB_PUBLIC.md)维护;原投放开关保持最终决定权。
|
||||
@@ -1,21 +0,0 @@
|
||||
# 广告入口自动同步
|
||||
|
||||
2026-11-09用户授权三端对齐及任何聊天的统一入口。权威合同为[DomainHub公共域名](/Users/hellcat/Documents/GemCodes/atom/codex/output/docs/domainhub-public.md)。FNA只消费 fuc/dpl/hn 公共用途,绝不根据名称猜后台、订阅或支付地址。
|
||||
|
||||
`AirportDomains`统一供横幅、推荐表、教程末尾和旧推广块使用;无可选项时隐藏该家,全部为空也移除已识别旧推广,正文数据库/订阅载荷不写入。价格、优惠、素材和布局不改。`/go/airport/{fuc|dpl|hn}/{banner|recommendation}`在点击时核对快照、租约、水位、quiet及对应投放开关:可用302/no-store,否则410,不接收任意目标URL。旧页面仍服从最新状态。响应缓存既有配置不启用缓存;新出口no-store/noindex。
|
||||
|
||||
`DOMAINHUB_PUBLIC_ENABLED`仅切换地址来源,不打开广告。私有state/config在`storage/app/private/domainhub-public/`,密钥只由同步进程持有。config保存Hub bootstrap、专用调用方、状态路径和`php artisan domainhub:verify`运行回读命令。24小时后无成功同步则不使用;独立watermark不随代码回退。生产每4小时版本补拉,每日上海08:10完整拉取,各自systemd由FNA服务器nginx用户执行。收到撤销先原子应用,运行读取成功才ACK。
|
||||
|
||||
FNA是广告无候选Critical/base的唯一汇报方,按每个服务商去重;恢复notification/base。私有`.alerts`保存事件/稳定正文/幂等键/回执/重试,`.runtime`保留模式上下文。quiet或手动关广告不取消域名监测,也不因恢复打开广告。只读异常、签名失败和重试均不输出秘密;uncertain停止另发,需核实。
|
||||
|
||||
本地测试:空池、旧推广、过期、quiet、各投放开关、旧页面点击撤销、单调水位。共享consumer测试在ATOM覆盖签名/环境/版本、ACK顺序、重试与去重。发布时先关闭新来源、备份并拉取有效快照/核对解析结果,再开启新来源;不得在无快照时静默退回硬编码地址。回退保留禁选快照和水位;仅回退视图时保留统一解析器。实际Git/定时器/回执状态见下方回执。
|
||||
|
||||
## 2026-11-09已发布
|
||||
|
||||
生产Git:`8142e5e23e14464f5d9cde49d65d0a5dc70cd4a2`;恢复点VPS-003:`/var/lib/fna-deploy/domainhub-public-20261109/backup`。原版本`a365cde888cb3a722489938c81b287b22a63dd3e`。部署保留生成标签云的线上修改、data.ms和编辑图片;没有覆盖其他任务。生产原quiet=false、三个横幅开关false、推荐表true均逐项核对保持。配置缓存通过单次新PHP进程生成,规避旧StatOrderLikes文件名/类名不一致引起的config:cache第二次启动冲突,没有修改该遗留命令。
|
||||
|
||||
DomainHub client3,production/advertising,当前版本34/applied;FUC→fu-nav3.com,DPL→dp-link.net,HN→hardnerd.net。FNA两只timer已active:每4小时版本同步、上海08:10完整拉取。真实三个推荐出口302/no-store和三个关闭横幅出口410/no-store通过;资源入口规范跳转到首页后正文三家均使用站内固定出口。
|
||||
|
||||
TeleHub client19仅critical/notification→base;全部服务商有候选,当前无故障告警,不制造测试事故。13项PHP测试90断言及共享消费者6项测试通过;原有弃用提示不属于本次变更。已完成服务器侧验收,未做线上页面验收。当前文档及状态文件是后续维护入口,不把原设计的“待实施”当作现状。
|
||||
|
||||
2026-11-09用户进一步指定版本检查改为每4小时;开机90秒检查、每天北京时间08:10完整同步和统一命令变更后立即同步保持。仅从对应Git提交安装同步timer,应用代码版本沿用上述功能版本;备份及源提交回执在同服务器`/var/lib/fna-deploy/domainhub-public-20261109/interval-4h/`。回退只恢复该timer后daemon-reload并重启timer,不重启业务进程。
|
||||
@@ -0,0 +1,189 @@
|
||||
{
|
||||
"release_id": "3165b364-89db-497a-9cca-4c14fdcac288",
|
||||
"bundle_hash": "dc1078b1bc97eb7a856dd40e2b844921d9c4e8eeb5cb53146000558f223fd72e",
|
||||
"draft_id": "3165b364-89db-497a-9cca-4c14fdcac288",
|
||||
"publication_request_id": "fcd5fdb7-9174-41f7-9f0a-95b21566b666",
|
||||
"phase": "complete",
|
||||
"review": {
|
||||
"hash": "340dc14a5a3345ae0b920473452a426251041add0afce29935d6efbd7eb8c62b",
|
||||
"digest": "ad37373ac0affc5c74b8bdf86f2ff0dd9d35b9f765370cee4581081c5170b461",
|
||||
"rendered_at": "2026-11-03T07:41:53+00:00"
|
||||
},
|
||||
"receipt": {
|
||||
"publication_id": "fcd5fdb7-9174-41f7-9f0a-95b21566b666",
|
||||
"status": "published",
|
||||
"articles": [
|
||||
{
|
||||
"content_key": "clash-node-performance",
|
||||
"article_id": 399,
|
||||
"revision": 1,
|
||||
"content_changed": true,
|
||||
"url": "https://clashfreenode.com/a/clash-node-speed-test.html"
|
||||
},
|
||||
{
|
||||
"content_key": "clash-routing-modes",
|
||||
"article_id": 382,
|
||||
"revision": 2,
|
||||
"content_changed": true,
|
||||
"url": "https://clashfreenode.com/a/clash-rule-global-direct.html"
|
||||
}
|
||||
],
|
||||
"effects": {
|
||||
"indexnow": {
|
||||
"status": "done",
|
||||
"attempts": 1,
|
||||
"http_status": 200,
|
||||
"urls": [
|
||||
"https://clashfreenode.com/a/clash-node-speed-test.html",
|
||||
"https://clashfreenode.com/advanced",
|
||||
"https://clashfreenode.com/a/clash-rule-global-direct.html"
|
||||
],
|
||||
"submitted_at": "2026-11-03T07:46:06+00:00",
|
||||
"result": "received"
|
||||
},
|
||||
"cache": {
|
||||
"status": "done"
|
||||
},
|
||||
"search": {
|
||||
"status": "done",
|
||||
"method": "meilisearch",
|
||||
"index": "cfn_articles_v3",
|
||||
"documents": 2
|
||||
},
|
||||
"sitemap": {
|
||||
"status": "done",
|
||||
"method": "database-driven"
|
||||
}
|
||||
}
|
||||
},
|
||||
"published_at": "2026-11-03T07:46:05+00:00",
|
||||
"readback": [
|
||||
{
|
||||
"content_key": "clash-node-performance",
|
||||
"article_id": 399,
|
||||
"revision_matches": true,
|
||||
"content_matches": true,
|
||||
"body_sha256": "80685935f9601c3924442da1aca0e4c7d65441622c2b74e8f51258435ec833e8",
|
||||
"like_growth": {
|
||||
"seven_day_remaining": 3,
|
||||
"yearly": 30,
|
||||
"one_year_target": 61,
|
||||
"one_year_added": 0,
|
||||
"one_year_started_at": "2026-11-03 07:46:05"
|
||||
}
|
||||
},
|
||||
{
|
||||
"content_key": "clash-routing-modes",
|
||||
"article_id": 382,
|
||||
"revision_matches": true,
|
||||
"content_matches": true,
|
||||
"body_sha256": "75a05a230e9e4f62bb5daa5262f17001430977f523e7647dec2466158bbab305",
|
||||
"like_growth": {
|
||||
"seven_day_remaining": 0,
|
||||
"yearly": 50,
|
||||
"one_year_target": 241,
|
||||
"one_year_added": 2,
|
||||
"one_year_started_at": "2026-10-31 06:58:28"
|
||||
}
|
||||
}
|
||||
],
|
||||
"verification": {
|
||||
"checks": [
|
||||
{
|
||||
"path": "/a/clash-node-speed-test.html",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/a/clash-rule-global-direct.html",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/advanced",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/images/editorial/6e9192d1e25885928452c839407c3192cbedfa1f7ffe343f4a4b587be028fbc5.jpg",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/images/editorial/63809168da585b4e88c2cd9b24f70251b4967115b1ec4483d31d50946500027b.jpg",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/a/getting-started.html",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/a/proxy-clients.html",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/a/clash-rule-global-direct.html",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/a/system-proxy-vs-tun.html",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"path": "/a/free-nodes-explained.html",
|
||||
"status": 200
|
||||
}
|
||||
],
|
||||
"hero_unique": true,
|
||||
"images_hash_match": true,
|
||||
"links_and_anchors": true,
|
||||
"quiet_template": true,
|
||||
"head": "aa772e37664a27a48ddfdd378f55cc5d863034eb",
|
||||
"existing_source_hashes": {
|
||||
"docs/content/WRITING.md": "2ff8f8995e3e4de8e3d97779e36f04b011704bb0064039785beabffcbfd2033c",
|
||||
"docs/content/tutorials/clash-routing-modes.md": "5851d347ee897447c28b2dd07cd878d86fbfd016e536b6546b2c11ea47130a5f",
|
||||
"docs/content/tutorials/clash-routing-modes.html": "b1d0ed0a2854264b4163b7bf980c91722427081ee20715fb0747218c0478d4d8"
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"new_id": 377,
|
||||
"new_revision": 1,
|
||||
"related_id": 366,
|
||||
"related_revision": 2,
|
||||
"publication_id": "006ab05b-d7b3-462b-aae1-df0c073ba6ab",
|
||||
"visual_viewports": [
|
||||
"1137x1167",
|
||||
"390x844",
|
||||
"1340x844"
|
||||
],
|
||||
"visual_scope": "详情首屏/横幅与部分正文;列表3:2容器及配图引用通过HTML和模板核对。Safari后续截图出现空白和窗口切换,未据此声称全文逐屏验收。"
|
||||
},
|
||||
"sources": [
|
||||
"https://wiki.metacubex.one/config/proxy-groups/url-test/",
|
||||
"https://wiki.metacubex.one/config/proxy-groups/",
|
||||
"https://wiki.metacubex.one/config/proxy-providers/",
|
||||
"https://www.cloudflare.com/learning/performance/glossary/what-is-latency/",
|
||||
"https://raw.githubusercontent.com/MetaCubeX/mihomo/Meta/adapter/adapter.go",
|
||||
"https://raw.githubusercontent.com/MetaCubeX/mihomo/Meta/adapter/outboundgroup/urltest.go"
|
||||
],
|
||||
"slot": "2026-11-02-1",
|
||||
"display_published_at_utc": "2026-11-03 06:33:25",
|
||||
"display_offset_seconds": 4360,
|
||||
"git_archive": {
|
||||
"commit": "840bace83aa6da77555ba9119741a31db1cd69c9",
|
||||
"branch": "codex/editorial-node-performance-20261103",
|
||||
"pushed": true,
|
||||
"production_head_unchanged": true,
|
||||
"production_head": "aa772e37664a27a48ddfdd378f55cc5d863034eb",
|
||||
"files": [
|
||||
"docs/content/WRITING.md",
|
||||
"docs/content/tutorials/assets/node-performance/cover.jpg",
|
||||
"docs/content/tutorials/assets/node-performance/cover.png",
|
||||
"docs/content/tutorials/assets/node-performance/hero.jpg",
|
||||
"docs/content/tutorials/assets/node-performance/hero.png",
|
||||
"docs/content/tutorials/assets/node-performance/prompts.json",
|
||||
"docs/content/tutorials/clash-routing-modes.html",
|
||||
"docs/content/tutorials/clash-routing-modes.md",
|
||||
"docs/content/tutorials/node-performance.html",
|
||||
"docs/content/tutorials/node-performance.md",
|
||||
"docs/maintenance/NODE_PERFORMANCE_2026-11-03.json",
|
||||
"docs/maintenance/NODE_PERFORMANCE_2026-11-03.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
# 节点测速与选择教程:2026-11-03
|
||||
|
||||
状态:已在正式 cfn 的进阶教程 `/advanced` 发布。新文《节点延迟低,为什么还是慢?Clash 测速与选节点指南》,路径 `/a/clash-node-speed-test.html`,内容键 `clash-node-performance`。本地ID377/版本1;正式ID399/版本1。规则模式旧文仅在代理组说明后补一个 `#compare` 入口,本地ID366与正式ID382均升至版本2。
|
||||
|
||||
## 调度与回执
|
||||
|
||||
本次heartbeat先due,再claim槽位 `2026-11-02-1`。固定release `3165b364-89db-497a-9cca-4c14fdcac288`,发表UUID `fcd5fdb7-9174-41f7-9f0a-95b21566b666`;prepare、review、publish、status均经本机SSH→白色机→VPS-003,服务器进程内API操作,公网编辑API保持关闭。
|
||||
|
||||
真实发表时间为北京时间2026-11-03 15:46:05;展示时间14:33:25,随机提前4360秒。唯一周期台账按真实时间record,计本周第1篇。正式新文点赞冻结为i7like=3、i365like=30、一次性年度目标61,起点为真实发表时间;范围来自当前统一配置。旧文年度50、一次性241及原起点保留,未重抽。
|
||||
|
||||
缓存、Meilisearch、sitemap全部done;IndexNow由VPS-003提交新文、栏目和旧文三条URL,HTTP200/received,仅代表收到通知,不代表收录。phase=complete。脱敏机器回执见[JSON](NODE_PERFORMANCE_2026-11-03.json);私有源稿/签名预览与发布参数在`storage/app/private/weekly-tutorials/2026-11-02-1/`,不入Git。
|
||||
|
||||
## 内容与配图
|
||||
|
||||
区分延迟、吞吐量和稳定性;解释Mihomo URL健康检查与自动选择的边界,提供少量节点的同条件对比方法和按现象排错。示例表明确为假设记录,不编造测评。2026-11-03核对Mihomo官方代理组、url-test、proxy-provider文档及当前URLTest/组选择代码,概念参照Cloudflare原文;链接保留正文和JSON。未进行客户端/节点真机联网测试,本条只留维护记录。
|
||||
|
||||
独立构思纸艺物流场景:小快递与计时器表达等待响应,宽传送带表达持续吞吐量。列表封面1536×1024(3:2),横幅1942×809(约2.4:1),分别构图、不裁切不拉伸,两图含`clashfreenode.com`水印。原PNG、JPEG和完整提示词见[素材目录](../content/tutorials/assets/node-performance/)。JPEG两图通过API保存,cover使用列表图,show_cover=false,正文仅一处`figure.guide-figure.tutorial-hero`。正文另有两组既有HTML图解,不新增公共CSS。
|
||||
|
||||
文章源、渲染HTML和实际关系以[写作索引](../content/WRITING.md)为准。新文自然关联下载、新手指引、代理组、TUN排错和免费节点基础说明;只补一处相关旧文入口。
|
||||
|
||||
## 验收范围
|
||||
|
||||
- 内置浏览器三次返回不可用,沿用用户已明确批准的Safari仅本地页面检查。1137桌面和390手机详情首屏/横幅可见,水印、比例和标题可读;1340桌面部分正文可见。后续截图出现空白及窗口切换,未声称全文逐屏检查完成。列表的既有media-3x2容器与1536×1024配图比例一致,HTML确认使用列表图,详情不重复显示cover。
|
||||
- 本地公开新文、列表和旧文均200;图片引用、唯一hero、双向入口通过。草稿API校验正文引用和锚点。
|
||||
- 正式真实模板review核对标题、六节锚点、横幅尺寸/资产、旧文签名内链和点赞冻结值;生产暂避风头模式持续开启,模板不输出机场推荐及广告。本地仍关闭,不为验收改变模式。
|
||||
- 服务器侧10项HTTPS请求均200,新文/旧文/栏目、两图SHA和五个目标锚点通过;公开正文及版本与冻结稿一致。没有在本机打开线上HTML或访问线上网站。
|
||||
- 已完成服务器侧验收,未做线上页面验收。普通正文、图片走内容API,未部署程序或公共样式。
|
||||
|
||||
## 恢复
|
||||
|
||||
继续修订用当前内容键和版本建新草稿;不重用已冻结release改内容。规则模式旧文如需退回可基于版本1创建回退草稿;新文有入向链接,撤下前先处理入口。保留公开图片和共享资产,不直接SQL或整库回滚。Git只归档本次文章源、配图、索引差异和记录,不更新生产应用HEAD。
|
||||
|
||||
## Git留档
|
||||
|
||||
本次12项文章源、原图、提示词、关系索引和脱敏回执已提交并推送:`840bace83aa6da77555ba9119741a31db1cd69c9`,分支`codex/editorial-node-performance-20261103`。在正式仓库的隔离工作树归档,生产应用HEAD保持`aa772e37664a27a48ddfdd378f55cc5d863034eb`,未将文档归档当作程序部署。首次push因无认证未创建远程分支,核对原提交后按ACC-007统一字段的内存认证重试成功;凭据未落盘。
|
||||
@@ -1,10 +1,10 @@
|
||||
# 暂避风头模式
|
||||
|
||||
2026-11-07起,开启暂避风头模式只隐藏机场广告和推荐。免费节点的新发和覆盖更新沿正常接收流程执行,仍按原有规则校验节点结果。2026-11-03旧版行为及原发布记录见[六项发布记录](SIX_RELEASE_2026-11-03.md)。
|
||||
2026-11-03按用户要求新增统一开关:免费节点暂停更新,机场广告暂时下掉。已Git推送并部署正式cfn,按用户明确要求在生产开启;本地仍关闭。当前发布回执、验收和恢复点见[六项发布记录](SIX_RELEASE_2026-11-03.md)。以下本地测试记录保留当时范围。
|
||||
|
||||
## 操作
|
||||
|
||||
在本站项目目录,以 PHP 运行账号(cfn 为 nginx)执行:
|
||||
在本站项目目录运行:
|
||||
|
||||
```sh
|
||||
php artisan site:quiet on
|
||||
@@ -12,14 +12,36 @@ ## 操作
|
||||
php artisan site:quiet status
|
||||
```
|
||||
|
||||
- `on` 隐藏机场横幅、推荐表格、可识别的旧福云推广段和推荐跳转。
|
||||
- `off` 恢复各服务商的原广告与推荐配置。
|
||||
- `status` 查询当前状态。
|
||||
- on:阻止免费节点新发布和覆盖更新;隐藏机场随机横幅、推荐表格、已知旧福云推广段与自动推荐跳转。
|
||||
- off:恢复正常接收与原广告配置,各服务商单独开关/链接/价格/优惠码保持原值。
|
||||
- status:只读查询。没有给公众网页增加操作入口或状态横幅。
|
||||
|
||||
初始按 `SITE_QUIET_MODE` 配置(默认关闭)。运行命令后优先读取实例私有的 `storage/app/private/site-mode.json`,开启和关闭均原子保存为 0600 文件,并清理响应缓存。状态文件损坏或不可读时,广告继续隐藏。发布保留实例现有的状态文件及所有者。
|
||||
初始无运行状态文件时按 `SITE_QUIET_MODE` 配置,默认false。运行命令后以 `storage/app/private/site-mode.json` 内的布尔值为优先,包括false;不必重启PHP或重建配置缓存。CLI与网页使用同一实例目录,不共享其他实例状态。环境变量只作为不存在文件时的缺省值,不覆盖已有运行选择。
|
||||
|
||||
## 验收与回退
|
||||
状态文件原子替换、0600,私有目录不存在时0700创建,已确认Git忽略。**发布后须以PHP运行账号执行开关命令**,先核实该账号(已有cfn操作常用nginx),不要用root生成网页进程无法读取的0600文件。状态文件损坏/不可读取时保持暂停与隐藏,不能静默恢复;修复同一文件及所有者后运行off或on并分别核对CLI和页面。
|
||||
|
||||
`QuietModeTest` 验证状态切换、广告和推荐隐藏、节点接收进入正常校验,以及开启状态下节点新建和更新成功。
|
||||
开启/关闭会清理响应缓存;既有HTML响应缓存合同本已关闭。切换后新请求生效,已打开的旧页面需刷新。开关保存在项目运行目录,发布不能打包覆盖/删除它。
|
||||
|
||||
回退到 2026-11-03 旧版且模式开启时,节点发布会再次暂停。回退前按当前生产目标核对模式与节点发布行为,使用 Git 恢复点并保留运行状态文件。
|
||||
## 范围与实现
|
||||
|
||||
- `app/Services/SiteMode.php` 读取开关,暂停返回HTTP503,JSON `isDone=false / status=paused / code=FREE_NODE_UPDATES_PAUSED`,带 `Retry-After: 3600`。不上报发布成功,不消耗正常发布回执;恢复后由正常上游重试/后续发布执行,不自动重放或补造历史文章。
|
||||
- 两个免费节点接收方法在解析/Flow/配图调用之前阻断;通用接收在目标分类或原文章为freenode时阻断,不能通过换分类绕过。没有改上游任务/服务或服务器调度。
|
||||
- 文章Eloquent保存事件补充检查:涉及节点正文、标题、图片、分类、发布时间、资源状态等发布字段时拒绝写入;同样保留旧数据。点赞、浏览等指标允许正常保存。直接绕过模型的SQL/人工运维不属于应用发布开关的保护范围。
|
||||
- 仅暂停freenode,原文章和订阅仍可访问;小火箭ID、教程、资讯、资源列表和站点导航不停止。
|
||||
- 随机广告组件及保留的三个旧广告组件均检查开关,关闭时不输出广告模板、图片或noscript广告。
|
||||
- 推荐模块providers为空,隐藏共用推荐并清理匹配的已知旧推广及自动跳转。只处理明确的旧推广结构,不猜测删除普通正文,账号/订阅复制值与正文数据库不变。
|
||||
- 该模式不删除数据、不撤下已发布资源、不切换现有SEO规则、域名、证书、图片池、上游服务器或其他项目。
|
||||
|
||||
## 验收
|
||||
|
||||
- 专项 `QuietModeTest`:5项/51断言通过,覆盖命令双向切换、状态持久化/权限、异常状态、专用及通用入口阻断、换分类绕过、模型新建/更新保护、真实点赞字段保存、其他类型放行、广告/旧推广隐藏、复制值及原文保护、恢复。
|
||||
- 正常回归:QuietMode、ArticleRecommendations、SEO合同及苹果ID解析共32项/331断言通过;之后仅补充旧组件与真实点赞保存断言,再跑专项5项/51断言通过。测试基类隔离运行站点的开关,避免测试误继承本地暂时启用的状态;初轮未隔离的失败已修正。
|
||||
- 本地IAB开启实测:首页3个复制按钮保留,随机广告0、推荐表格0、旧推广0;教程正文可读,广告0、推荐0、自动推荐跳转0。截图 `output/quiet-mode-20261103/quiet-on.png`。
|
||||
- 关闭后同一首页恢复随机广告1、推荐模块1,3个订阅按钮保留。CLI回读明确关闭。未进行实际账号登录、上游真实发稿或线上访问。
|
||||
- PHP语法与本次diff检查通过,未进行生产构建。
|
||||
|
||||
## 发布与回退
|
||||
|
||||
本批已按用户明确授权完成Git发布,生产开启;后续变更仍按任务授权执行。相关文件包括SiteMode服务、QuietMode命令、配置、接收器入口、模型保存事件、推荐展示服务、四个广告组件、环境模板与测试/维护入口;不能漏发模型或展示服务。默认缺省关闭,不应随代码发布自动切换生产模式。
|
||||
|
||||
回退前关闭模式并核对正常状态,再增量撤销本批调用;不得整文件还原覆盖并行SEO、文章渲染或其他修改。运行状态文件须单独保留/按明确运维操作处理,不以Git回退等同模式切换。
|
||||
@@ -3,8 +3,8 @@
|
||||
['key' => 'dpl', 'file' => 'dpl-ad-compact-wordmark-20261031.png', 'width' => 2169, 'height' => 725, 'alt' => 'DP-LINK.NET:畅连全球网络。日常访问、远程办公、在线娱乐,查看套餐。'],
|
||||
['key' => 'hn', 'file' => 'hn-ad-compact-HardNerd-20261031.png', 'width' => 2020, 'height' => 778, 'alt' => 'HardNerd:硬核架构,品质专线,全球网络畅通无阻。'],
|
||||
['key' => 'fuc', 'file' => 'fuc-ad-compact-five-years-20261031.png', 'width' => 2141, 'height' => 734, 'alt' => '福云:全球网络加速。五年稳定运营。开始使用。'],
|
||||
])->map(fn ($ad) => [...$ad, 'url' => \App\Services\AirportDomains::link($ad['key'], 'banner')])->filter(fn ($ad) => ! \App\Services\SiteMode::quiet() && config('advertising.'.$ad['key'].'.enabled')
|
||||
&& $ad['url']
|
||||
])->filter(fn ($ad) => ! \App\Services\SiteMode::quiet() && config('advertising.'.$ad['key'].'.enabled')
|
||||
&& config('advertising.'.$ad['key'].'.url')
|
||||
&& is_file(public_path('images/ads/'.$ad['file'])))->values();
|
||||
@endphp
|
||||
@if ($adChoices->isNotEmpty())
|
||||
@@ -16,7 +16,7 @@
|
||||
<aside class="random-article-ad" data-random-article-ad aria-label="网络服务广告" hidden>
|
||||
@foreach ($adChoices as $ad)
|
||||
<template data-ad-choice="{{ $ad['key'] }}">
|
||||
<a href="{{ $ad['url'] }}" target="_blank" rel="sponsored noopener noreferrer" aria-label="广告:{{ $ad['alt'] }}(新窗口打开)">
|
||||
<a href="{{ config('advertising.'.$ad['key'].'.url') }}" target="_blank" rel="sponsored noopener noreferrer" aria-label="广告:{{ $ad['alt'] }}(新窗口打开)">
|
||||
<span class="random-article-ad__disclosure" aria-hidden="true">广告</span>
|
||||
<img src="/images/ads/{{ $ad['file'] }}?v={{ filemtime(public_path('images/ads/'.$ad['file'])) }}" alt="{{ $ad['alt'] }}" width="{{ $ad['width'] }}" height="{{ $ad['height'] }}" decoding="async">
|
||||
</a>
|
||||
@@ -26,7 +26,7 @@
|
||||
<noscript>
|
||||
@php($ad = $adChoices->first())
|
||||
<aside class="random-article-ad" aria-label="网络服务广告">
|
||||
<a href="{{ $ad['url'] }}" target="_blank" rel="sponsored noopener noreferrer">
|
||||
<a href="{{ config('advertising.'.$ad['key'].'.url') }}" target="_blank" rel="sponsored noopener noreferrer">
|
||||
<span class="random-article-ad__disclosure" aria-hidden="true">广告</span>
|
||||
<img src="/images/ads/{{ $ad['file'] }}?v={{ filemtime(public_path('images/ads/'.$ad['file'])) }}" alt="{{ $ad['alt'] }}" width="{{ $ad['width'] }}" height="{{ $ad['height'] }}">
|
||||
</a>
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
use App\Http\Controllers\RobotsController;
|
||||
use App\Http\Controllers\SitemapController;
|
||||
|
||||
Route::get('/go/airport/{provider}/{placement}', [\App\Services\AirportDomains::class, 'redirect'])
|
||||
->where('provider', 'fuc|dpl|hn')->where('placement', 'banner|recommendation');
|
||||
|
||||
Route::get('robots.txt', [RobotsController::class, 'index']);
|
||||
Route::get('sitemap.xml', [SitemapController::class, 'index']);
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\Feature;
|
||||
use App\Services\{AirportDomains,ArticleRecommendations};
|
||||
use App\Models\{Articles,Categories};
|
||||
use Tests\TestCase;
|
||||
final class AirportDomainsTest extends TestCase
|
||||
{
|
||||
private string $path;
|
||||
protected function setUp(): void { parent::setUp();$this->path=tempnam(sys_get_temp_dir(),'domainhub-test-');config(['app.key'=>'base64:'.base64_encode(str_repeat('t',32)),'domainhub.enabled'=>true,'domainhub.state_path'=>$this->path,'domainhub.environment'=>'production','site_mode.state_path'=>null,'site_mode.quiet'=>false,'advertising.fuc.enabled'=>true]);$this->snapshot(); }
|
||||
protected function tearDown(): void { @unlink($this->path);@unlink($this->path.'.watermark');parent::tearDown(); }
|
||||
private function snapshot(?array $selected=['url'=>'https://fu-nav3.com/','eligible'=>true,'access'=>'available','reason'=>null],int $age=0): void
|
||||
{
|
||||
file_put_contents($this->path,json_encode(['digest'=>str_repeat('a',64),'checked_at'=>time()-$age,'manifest'=>['schema'=>'domainhub.public.v1','project'=>'fna_v3','environment'=>'production','instance'=>'advertising','version'=>8,'providers'=>['fuc'=>['selected'=>$selected],'hn'=>['selected'=>null],'dpl'=>['selected'=>null]]]]));
|
||||
file_put_contents($this->path.'.watermark',json_encode(['version'=>8,'digest'=>str_repeat('a',64)]));
|
||||
}
|
||||
public function test_single_resolver_and_click_revocation_without_render_or_remote_requests(): void
|
||||
{
|
||||
$this->assertSame('/go/airport/fuc/recommendation',ArticleRecommendations::providers()['fuc']['url']);
|
||||
$this->assertSame('/go/airport/fuc/banner',AirportDomains::link('fuc','banner'));
|
||||
$this->get('/go/airport/fuc/recommendation')->assertStatus(302)->assertHeader('Location','https://fu-nav3.com/')->assertHeader('X-Robots-Tag','noindex, nofollow');
|
||||
$this->snapshot(null);
|
||||
$this->assertSame([],ArticleRecommendations::providers());
|
||||
$this->get('/go/airport/fuc/recommendation')->assertStatus(410)->assertHeader('Cache-Control','no-store, private');
|
||||
}
|
||||
public function test_expiry_quiet_and_independent_switches(): void
|
||||
{
|
||||
config(['advertising.fuc.enabled'=>false]);$this->assertNull(AirportDomains::link('fuc','banner'));
|
||||
$this->assertNotNull(AirportDomains::link('fuc','recommendation'));
|
||||
config(['site_mode.quiet'=>true]);$this->get('/go/airport/fuc/recommendation')->assertStatus(410);
|
||||
config(['site_mode.quiet'=>false]);$this->snapshot(age:86401);$this->assertNull(AirportDomains::target('fuc'));
|
||||
file_put_contents($this->path,'broken');$this->assertNull(AirportDomains::target('fuc'));
|
||||
}
|
||||
public function test_empty_pool_strips_legacy_promo_without_touching_subscription_payload(): void
|
||||
{
|
||||
$this->snapshot(null);$category=new Categories();$category->setRawAttributes(['sSlug'=>'freenode']);$category->setRelation('oParent',null);
|
||||
$tail='<h2>免费资源</h2><pre>vmess://keep-exact</pre>';
|
||||
$a=new Articles();$a->setRelation('oCategory',$category);$html='<h2>机场推荐 - 福云:</h2><p><a href="https://fuuu.cloud">机场官网:福云</a></p>'.$tail;$a->setRawAttributes(['sContent'=>$html]);
|
||||
$r=ArticleRecommendations::prepare($a);$this->assertFalse($r['enabled']);$this->assertSame($tail,$r['body']);$this->assertSame($html,$a->sContent);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
use App\Services\ArticleRecommendations;
|
||||
use App\Services\SiteMode;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -51,6 +51,16 @@ protected function tearDown(): void
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function paused(callable $action): void
|
||||
{
|
||||
try { $action(); $this->fail('Expected paused response.'); }
|
||||
catch (HttpResponseException $e) {
|
||||
$this->assertSame(503, $e->getResponse()->getStatusCode());
|
||||
$this->assertSame('3600', $e->getResponse()->headers->get('Retry-After'));
|
||||
$this->assertSame('FREE_NODE_UPDATES_PAUSED', json_decode($e->getResponse()->getContent(), true)['code']);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_command_switch_is_persistent_reversible_and_private(): void
|
||||
{
|
||||
$this->assertFalse(SiteMode::quiet());
|
||||
@@ -65,7 +75,7 @@ public function test_command_switch_is_persistent_reversible_and_private(): void
|
||||
$this->assertFalse(SiteMode::quiet());
|
||||
}
|
||||
|
||||
public function test_invalid_state_keeps_ads_hidden_and_environment_fallback_works(): void
|
||||
public function test_invalid_state_stays_paused_and_environment_fallback_works(): void
|
||||
{
|
||||
config(['site_mode.quiet'=>true]); $this->assertTrue(SiteMode::quiet());
|
||||
config(['site_mode.quiet'=>false]);
|
||||
@@ -73,28 +83,38 @@ public function test_invalid_state_keeps_ads_hidden_and_environment_fallback_wor
|
||||
file_put_contents($this->state, '{"quiet":"false"}'); $this->assertTrue(SiteMode::quiet());
|
||||
}
|
||||
|
||||
public function test_free_node_receiver_runs_normal_validation_with_ads_hidden(): void
|
||||
public function test_receivers_pause_before_images_flows_and_any_database_write(): void
|
||||
{
|
||||
config(['site_mode.quiet'=>true]);
|
||||
$this->expectException(HttpException::class);
|
||||
$this->expectExceptionMessage('Resource update has no usable result');
|
||||
(new ArticlesController())->receiveFreenode(new Request(['article'=>[
|
||||
'title'=>'Free nodes', 'title_sub'=>'', 'content'=>'A resource update',
|
||||
'tags'=>[], 'check_status'=>'failed',
|
||||
]]));
|
||||
$controller = new ArticlesController();
|
||||
$this->paused(fn () => $controller->receiveFreenode(new Request()));
|
||||
$this->paused(fn () => $controller->receiveFreenode_laji(new Request()));
|
||||
$this->paused(fn () => $controller->receive(new Request(['_raw'=>[
|
||||
'id'=>8, 'opt'=>json_encode(['sCategoryName'=>'免费节点']),
|
||||
]])));
|
||||
// Moving an existing node article to another category must not bypass the pause.
|
||||
$this->paused(fn () => $controller->receive(new Request(['_raw'=>[
|
||||
'id'=>7, 'opt'=>json_encode(['sCategoryName'=>'新手教程']),
|
||||
]])));
|
||||
$this->assertSame(1, DB::table('articles')->count());
|
||||
$this->assertSame('original', DB::table('articles')->where('id',7)->value('sContent'));
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_free_node_model_can_publish_and_update_with_ads_hidden(): void
|
||||
public function test_model_rejects_publication_changes_but_allows_metrics_and_other_types(): void
|
||||
{
|
||||
config(['site_mode.quiet'=>true]);
|
||||
$existing = Articles::find(7);
|
||||
$existing->sContent = 'replacement';
|
||||
$existing->save();
|
||||
$existing = Articles::find(7); $existing->sContent = 'replacement';
|
||||
$this->paused(fn () => $existing->save());
|
||||
$this->assertSame('original', DB::table('articles')->where('id',7)->value('sContent'));
|
||||
$new = new Articles(['iCategoryId'=>1,'sSlug'=>'fn-new','sContent'=>'new']);
|
||||
$new->save();
|
||||
|
||||
$this->assertSame('replacement', Articles::find(7)->sContent);
|
||||
$this->assertSame('new', Articles::where('sSlug', 'fn-new')->firstOrFail()->sContent);
|
||||
$this->paused(fn () => $new->save());
|
||||
$metrics = Articles::find(7); $metrics->iLikeCount = 10; $metrics->save();
|
||||
$this->assertSame(10, DB::table('articles')->where('id',7)->value('iLikeCount'));
|
||||
foreach ([2,3] as $id) SiteMode::guardArticle(new Articles(['iCategoryId'=>$id,'sContent'=>'unchanged scope']));
|
||||
SiteMode::assertUpdatesAllowed('shadowrocketids');
|
||||
$this->assertSame(1, DB::table('articles')->count());
|
||||
config(['site_mode.quiet'=>false]); SiteMode::assertUpdatesAllowed('freenode');
|
||||
}
|
||||
|
||||
public function test_promotions_disappear_without_mutating_original_body_or_copy_payload(): void
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Signed public-domain consumer. Run only on the owning project's server.
|
||||
Canonical source: ATOM integrations/domainhub/public_client.py; copies are versioned.
|
||||
"""
|
||||
import argparse
|
||||
import fcntl
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.request import Request, HTTPRedirectHandler, build_opener
|
||||
from urllib.error import HTTPError
|
||||
|
||||
MAX_AGE = 86400
|
||||
TERMINAL = {'sent', 'failed', 'uncertain', 'cancelled', 'rejected'}
|
||||
|
||||
class NoRedirect(HTTPRedirectHandler):
|
||||
def redirect_request(self, *_a, **_k): return None
|
||||
|
||||
def read(path, default=None):
|
||||
try: return json.loads(Path(path).read_text())
|
||||
except (OSError, ValueError): return default
|
||||
|
||||
def atomic(path, data):
|
||||
path=Path(path); path.parent.mkdir(parents=True, exist_ok=True)
|
||||
fd,name=tempfile.mkstemp(prefix='.'+path.name, dir=path.parent)
|
||||
try:
|
||||
with os.fdopen(fd,'w') as out:
|
||||
os.fchmod(out.fileno(),0o640)
|
||||
json.dump(data,out,ensure_ascii=False,separators=(',',':'))
|
||||
out.flush(); os.fsync(out.fileno())
|
||||
os.replace(name,path)
|
||||
directory=os.open(path.parent,os.O_RDONLY)
|
||||
try: os.fsync(directory)
|
||||
finally: os.close(directory)
|
||||
finally:
|
||||
if os.path.exists(name): os.unlink(name)
|
||||
|
||||
def request(url, key, data=None, extra=None):
|
||||
headers={'Authorization':'Bearer '+key,'Accept':'application/json',**(extra or {})}
|
||||
if data is not None: headers['Content-Type']='application/json'
|
||||
req=Request(url,data=json.dumps(data,ensure_ascii=False,separators=(',',':')).encode() if data is not None else None,headers=headers)
|
||||
with build_opener(NoRedirect()).open(req,timeout=12) as response:
|
||||
body=response.read(1048577)
|
||||
if len(body)>1048576: raise ValueError('response_too_large')
|
||||
return response.headers,body
|
||||
|
||||
def signed(config, path, transport=request, now=None):
|
||||
headers,body=transport(config['hub_url'].rstrip('/')+'/api/v1/domainhub/public/'+path,config['key'])
|
||||
stamp=headers.get('X-DomainHub-Timestamp',''); signature=headers.get('X-DomainHub-Signature','')
|
||||
now=time.time() if now is None else now
|
||||
if not stamp.isdigit() or abs(now-int(stamp))>120: raise ValueError('invalid_timestamp')
|
||||
expected=hmac.new(config['key'].encode(),stamp.encode()+b'.'+body,hashlib.sha256).hexdigest()
|
||||
if not hmac.compare_digest(expected,signature): raise ValueError('invalid_signature')
|
||||
data=json.loads(body)
|
||||
if any(data.get(k)!=config[k] for k in ['project','environment','instance']): raise ValueError('wrong_scope')
|
||||
if type(data.get('version')) is not int or data['version']<1: raise ValueError('invalid_version')
|
||||
return data,body,headers
|
||||
|
||||
def validate_manifest(manifest, config):
|
||||
if manifest.get('schema')!='domainhub.public.v1' or not isinstance(manifest.get('providers'),dict): raise ValueError('invalid_schema')
|
||||
if set(manifest['providers'])!=set(config['providers']): raise ValueError('wrong_providers')
|
||||
for provider in manifest['providers'].values():
|
||||
entries=provider.get('entries')
|
||||
if not isinstance(entries,list): raise ValueError('invalid_entries')
|
||||
codes=set()
|
||||
for entry in entries:
|
||||
u=urlsplit(entry.get('url',''))
|
||||
if u.scheme!='https' or not u.hostname or u.username or u.password or u.query or u.fragment or u.port not in (None,443) or any(c.isspace() for c in entry['url']): raise ValueError('invalid_public_url')
|
||||
if entry.get('role') not in {'primary','navigation','direct_access'} or type(entry.get('eligible')) is not bool or entry.get('code') in codes: raise ValueError('invalid_entry')
|
||||
codes.add(entry['code'])
|
||||
if entry['eligible'] and (entry.get('access')!='available' or entry.get('reason') is not None): raise ValueError('invalid_eligibility')
|
||||
selected=provider.get('selected')
|
||||
if selected is not None and (selected not in entries or not selected['eligible']): raise ValueError('invalid_selection')
|
||||
|
||||
def current(state, now=None):
|
||||
now=time.time() if now is None else now
|
||||
return isinstance(state,dict) and 0<=now-state.get('checked_at',0)<=MAX_AGE
|
||||
|
||||
def available(state, provider, now=None):
|
||||
if not current(state,now): return None
|
||||
selected=state['manifest']['providers'].get(provider,{}).get('selected')
|
||||
if not selected or not selected.get('eligible') or selected.get('access')!='available': return None
|
||||
until=selected.get('valid_until')
|
||||
if until:
|
||||
from datetime import datetime, timezone
|
||||
stamp=datetime.fromisoformat(until).replace(tzinfo=timezone.utc).timestamp()
|
||||
if stamp <= (time.time() if now is None else now): return None
|
||||
return selected
|
||||
|
||||
def runtime_check(config, version):
|
||||
result=subprocess.run(config['validate_command'],env={**os.environ,'DOMAINHUB_EXPECT_VERSION':str(version)},capture_output=True,timeout=20)
|
||||
if result.returncode: raise ValueError('runtime_verification_failed')
|
||||
return json.loads(result.stdout or b'{}')
|
||||
|
||||
def sync(config, force=False, transport=request, verify=runtime_check, now=None):
|
||||
now=int(time.time() if now is None else now)
|
||||
path=Path(config['state_path']); state=read(path,{})
|
||||
watermark=read(str(path)+'.watermark',{'version':0,'digest':''})
|
||||
meta,_,_=signed(config,'version',transport,now)
|
||||
if meta.get('schema')!='domainhub.public-version.v1' or not re.fullmatch('[a-f0-9]{64}',meta.get('digest','')): raise ValueError('invalid_version_response')
|
||||
if meta['version']<watermark['version'] or (meta['version']==watermark['version'] and watermark['digest']!=meta['digest']): raise ValueError('rollback_or_conflict')
|
||||
changed=state.get('digest')!=meta['digest'] or state.get('manifest',{}).get('version')!=meta['version']
|
||||
if changed or force:
|
||||
manifest,body,headers=signed(config,'snapshot',transport,now)
|
||||
digest=hashlib.sha256(body).hexdigest()
|
||||
if manifest['version']<meta['version'] or manifest['version']<watermark['version']: raise ValueError('stale_snapshot')
|
||||
if manifest['version']==meta['version'] and digest!=meta['digest']: raise ValueError('snapshot_digest_mismatch')
|
||||
validate_manifest(manifest,config)
|
||||
if manifest['version']==watermark['version'] and digest!=watermark['digest']: raise ValueError('same_version_conflict')
|
||||
state={'manifest':manifest,'digest':digest,'delivery':int(headers['X-DomainHub-Delivery']),'checked_at':now}
|
||||
else:
|
||||
validate_manifest(state['manifest'],config)
|
||||
state={**state,'checked_at':now,'delivery':meta['delivery']}
|
||||
atomic(str(path)+'.watermark',{'version':state['manifest']['version'],'digest':state['digest']})
|
||||
atomic(path,state)
|
||||
# ACK only after the consuming application's resolver reads the active file.
|
||||
if config.get('catalog_path'):
|
||||
provider=state['manifest']['providers'][config['catalog_provider']]
|
||||
records=[]
|
||||
candidates=sorted([e for e in provider['entries'] if e['eligible'] and e['role']!='navigation'], key=lambda e:(0 if e['role']=='direct_access' else 1,-e['priority'], -__import__('datetime').datetime.fromisoformat(e['activated_at']).timestamp(),e['code']))
|
||||
preferred=candidates[0]['code'] if candidates else None
|
||||
for e in provider['entries']:
|
||||
item={'domain':e['hostname'],'role':'direct' if e['role']=='direct_access' else e['role'],'domainhub':e['code'],'eligible':e['eligible'],'recommended':e['code']==preferred}
|
||||
if e['access']!='available': item['access']=e['access']
|
||||
records.append(item)
|
||||
atomic(config['catalog_path'],{'source':'domainhub.public.v1','version':state['manifest']['version'],'domains':records})
|
||||
context=verify(config,state['manifest']['version'])
|
||||
atomic(str(path)+'.runtime',context)
|
||||
_,body=transport(config['hub_url'].rstrip('/')+'/api/v1/domainhub/public/deliveries/'+str(state['delivery'])+'/ack',config['key'],{'version':state['manifest']['version'],'digest':state['digest'],'status':'applied'})
|
||||
if json.loads(body).get('status')!='applied': raise ValueError('invalid_ack')
|
||||
return {'version':state['manifest']['version'],'changed':changed,'status':'applied'}
|
||||
|
||||
def incidents(config, state, journal, now):
|
||||
active=journal.setdefault('active',{}); outbox=journal.setdefault('outbox',[])
|
||||
context=read(config['state_path']+'.runtime',{})
|
||||
for code in config['providers']:
|
||||
selection=available(state,code,now)
|
||||
if selection is None and code not in active:
|
||||
incident=str(uuid.uuid4()); active[code]=incident
|
||||
provider=(state or {}).get('manifest',{}).get('providers',{}).get(code,{})
|
||||
reasons=';'.join(e['hostname']+': '+str(e.get('reason') or '不可用') for e in provider.get('entries',[]))
|
||||
if not current(state,now): reasons='快照缺失或超过24小时未成功同步。'+reasons
|
||||
text=f"【{config['label']} - {code}无可用广告域名】\n该服务商已暂停自动引流。\n原因:{reasons}\n版本:{(state or {}).get('manifest',{}).get('version','无')}\n投放状态:{json.dumps(context,ensure_ascii=False)}\n请补充可用入口或核实后明确恢复域名。"
|
||||
outbox.append({'key':'domainhub.'+incident+'.critical','bot':'critical','text':text,'status':'pending','receipt':None,'retry_at':0,'attempts':0})
|
||||
elif selection is not None and code in active:
|
||||
incident=active.pop(code)
|
||||
outbox.append({'key':'domainhub.'+incident+'.recovery','bot':'notification','text':f"【{config['label']} - {code}广告域名恢复】\n当前选用:{selection['url']}\n版本:{state['manifest']['version']}\n仍遵守原投放开关和暂避风头模式。",'status':'pending','receipt':None,'retry_at':0,'attempts':0})
|
||||
|
||||
def alerts(config, now=None, transport=request):
|
||||
if not config.get('alerts_enabled'): return
|
||||
now=int(time.time() if now is None else now); path=config['state_path']+'.alerts'
|
||||
journal=read(path,{'active':{},'outbox':[]})
|
||||
incidents(config,read(config['state_path']),journal,now)
|
||||
atomic(path,journal)
|
||||
for message in [m for m in journal['outbox'] if m['status'] not in TERMINAL and m['retry_at']<=now][:5]:
|
||||
message['attempts']+=1; delay=min(21600,900*(2**min(message['attempts']-1,5)))
|
||||
try:
|
||||
endpoint=config['telehub_url'].rstrip('/')+'/api/v1/messages'
|
||||
if message['receipt']: _,body=transport(endpoint+'/'+message['receipt'],config['telehub_key'])
|
||||
else: _,body=transport(endpoint,config['telehub_key'],{'bot':message['bot'],'target':'base','text':message['text']},{'Idempotency-Key':message['key']})
|
||||
receipt=json.loads(body)['data']
|
||||
if (not re.fullmatch('[a-f0-9-]{36}',receipt.get('id','')) or receipt.get('status') not in TERMINAL|{'queued','sending'} or receipt.get('bot_code')!=message['bot'] or receipt.get('target_code')!='base' or (message['receipt'] and message['receipt']!=receipt['id'])): raise ValueError('invalid_receipt')
|
||||
message.update(receipt=receipt['id'],status=receipt['status'],error=None)
|
||||
except HTTPError as exc:
|
||||
message['error']='http_'+str(exc.code)
|
||||
if exc.code==429: delay=max(delay,int(exc.headers.get('Retry-After','0')) if exc.headers.get('Retry-After','0').isdigit() else 0)
|
||||
elif 400<=exc.code<500: message['status']='rejected'
|
||||
except (OSError,ValueError,KeyError,TimeoutError): message['error']='transport_or_receipt'
|
||||
message['retry_at']=now+delay; atomic(path,journal)
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser();parser.add_argument('--config',required=True);parser.add_argument('--full',action='store_true');args=parser.parse_args()
|
||||
config=read(args.config)
|
||||
if not config or config.get('environment')!='production' or not re.fullmatch('dhc_[a-f0-9]{64}',config.get('key','')): raise SystemExit('invalid_private_configuration')
|
||||
if urlsplit(config['hub_url']).scheme!='https': raise SystemExit('invalid_hub_url')
|
||||
path=Path(config['state_path']); path.parent.mkdir(parents=True,exist_ok=True)
|
||||
with open(str(path)+'.lock','a') as lock:
|
||||
try: fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
||||
except BlockingIOError: return
|
||||
try: print(json.dumps(sync(config,args.full)))
|
||||
except Exception as exc: print(json.dumps({'status':'sync_failed','error':type(exc).__name__}))
|
||||
alerts(config)
|
||||
|
||||
if __name__=='__main__': main()
|
||||
@@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=FNA daily full public domain reconciliation
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=nginx
|
||||
Group=nginx
|
||||
UMask=0027
|
||||
ExecStart=/usr/bin/python3 /www/wwwroot/clashfreenode-new.com/tools/domainhub/public_client.py --config /www/wwwroot/clashfreenode-new.com/storage/app/private/domainhub-public/config.json --full
|
||||
TimeoutStartSec=240
|
||||
NoNewPrivileges=true
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=/www/wwwroot/clashfreenode-new.com/storage /www/wwwroot/clashfreenode-new.com/bootstrap/cache
|
||||
ProtectHome=true
|
||||
PrivateTmp=true
|
||||
@@ -1,7 +0,0 @@
|
||||
[Unit]
|
||||
Description=FNA daily complete domain snapshot at 08:10 Shanghai
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 08:10:00 Asia/Shanghai
|
||||
Persistent=true
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=FNA signed public domain reconciliation
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=nginx
|
||||
Group=nginx
|
||||
UMask=0027
|
||||
ExecStart=/usr/bin/python3 /www/wwwroot/clashfreenode-new.com/tools/domainhub/public_client.py --config /www/wwwroot/clashfreenode-new.com/storage/app/private/domainhub-public/config.json
|
||||
TimeoutStartSec=240
|
||||
NoNewPrivileges=true
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=/www/wwwroot/clashfreenode-new.com/storage /www/wwwroot/clashfreenode-new.com/bootstrap/cache
|
||||
ProtectHome=true
|
||||
PrivateTmp=true
|
||||
@@ -1,8 +0,0 @@
|
||||
[Unit]
|
||||
Description=FNA public domain changes every four hours
|
||||
[Timer]
|
||||
OnBootSec=90
|
||||
OnUnitActiveSec=4h
|
||||
Persistent=true
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in new issue
Block a user