Skip to content

⚙️ 订阅检查 (sub-check)

sub-checkmihomo-iptest 集成工作流中的重要验证组件,专门负责代理配置的验证、测试和筛选工作。

🎯 功能概述

sub-check 是一个强大的全自动订阅处理引擎,具备以下能力:

  • 🔄 批量处理: 同时处理多个订阅链接
  • 🧹 智能去重: 自动识别并移除重复节点
  • ⚡ 性能测试: 全面测试延迟、速度和可用性
  • 🎬 流媒体检测: 检查 Netflix、YouTube 等平台解锁能力
  • 💾 多格式输出: 支持 Clash、V2Ray、Shadowsocks 等格式
  • ☁️ 云端保存: 支持多种云存储和Git仓库

🔄 工作流程

sub-check 按以下步骤自动处理您的订阅:

mermaid
graph TD
    A[获取订阅链接] --> B[解析节点配置]
    B --> C[去重过滤]
    C --> D[可用性测试]
    D --> E[速度测试]
    E --> F[流媒体检测]
    F --> G[生成结果文件]
    G --> H[云端保存]

详细处理步骤

  1. 📥 下载节点: 从所有配置的链接中获取节点列表
  2. 🔍 过滤去重: 移除重复、无效和不符合条件的节点
  3. ⚡ 性能测试: 对剩余节点进行延迟和速度测试
  4. 🎬 流媒体检测: 检查节点对各大流媒体平台的解锁能力
  5. 📄 格式转换: 将优质节点转换为各种客户端格式
  6. ☁️ 云端保存: 自动上传到指定的云存储或Git仓库

🚀 快速开始

第一步:创建配置文件

首次运行 sub-check 时,程序会自动创建配置文件:

bash
ed sub-check -f config/config.yaml

如果配置文件不存在,程序会创建一个包含示例配置的模板文件。

第二步:编辑配置

使用您喜欢的文本编辑器打开 config/config.yaml

yaml
# 基本订阅配置
subscriptions:
  urls:
    - "https://example.com/subscription1"
    - "https://example.com/subscription2"
    - "https://example.com/subscription3"

# 测试配置
testing:
  concurrent: 200          # 并发测试数量
  timeout: 5              # 连接超时(秒)
  min_speed: 5            # 最低速度要求(MB/s)
  enable_speed_test: true # 是否进行速度测试
  
# 流媒体检测
media_check:
  enabled: true
  platforms:
    - netflix
    - youtube
    - disney_plus
    - hbo_max

# 输出配置
output:
  formats:
    - clash
    - v2ray
    - shadowsocks
  filename_template: "nodes_{date}"

第三步:运行检查

配置完成后,运行订阅检查:

bash
ed sub-check -f config/config.yaml

第四步:查看结果

程序完成后,您可以在 results 文件夹中找到生成的文件:

results/
├── all.yaml              # Clash 格式的所有节点
├── premium.yaml          # 高速节点(速度 > 50MB/s)
├── netflix.yaml          # 支持 Netflix 的节点
├── v2ray_config.json     # V2Ray 格式配置
└── shadowsocks.txt       # Shadowsocks 链接列表

🛠️ 详细配置

订阅源配置

基本订阅链接

yaml
subscriptions:
  urls:
    - "https://example.com/clash-subscription"
    - "https://example.com/v2ray-subscription"
    - "https://example.com/ss-subscription"

带认证的订阅

yaml
subscriptions:
  urls:
    - url: "https://example.com/private-subscription"
      headers:
        Authorization: "Bearer your-token"
        User-Agent: "clash-verge"

本地文件订阅

yaml
subscriptions:
  urls:
    - "file:///path/to/local/config.yaml"
    - "file://./relative/path/config.yaml"

过滤规则

地区过滤

yaml
filters:
  include_regions:
    - "香港"
    - "新加坡" 
    - "日本"
    - "美国"
  exclude_regions:
    - "印度"
    - "俄罗斯"

协议过滤

yaml
filters:
  include_protocols:
    - vmess
    - vless
    - trojan
  exclude_protocols:
    - shadowsocks

关键词过滤

yaml
filters:
  include_keywords:
    - "Premium"
    - "IPLC"
    - "IEPL"
  exclude_keywords:
    - "测试"
    - "到期"
    - "Traffic"

测试配置

性能测试设置

yaml
testing:
  # 并发连接数(建议 100-500)
  concurrent: 200
  
  # 连接超时时间(秒)
  timeout: 5
  
  # 最低延迟要求(毫秒)
  max_latency: 500
  
  # 最低速度要求(MB/s)
  min_speed: 5
  
  # 是否进行速度测试
  enable_speed_test: true
  
  # 速度测试超时(秒)
  speed_test_timeout: 10

流媒体检测配置

yaml
media_check:
  enabled: true
  timeout: 10
  platforms:
    netflix:
      enabled: true
      regions: ["US", "JP", "KR"]
    youtube:
      enabled: true
    disney_plus:
      enabled: true
    hbo_max:
      enabled: false
    prime_video:
      enabled: true
    hulu:
      enabled: false

输出配置

文件格式设置

yaml
output:
  # 输出格式
  formats:
    - clash
    - v2ray
    - shadowsocks
    - quantumult_x
  
  # 文件名模板
  filename_template: "nodes_{date}_{region}"
  
  # 输出目录
  output_dir: "./results"
  
  # 是否按地区分组
  group_by_region: true
  
  # 是否按速度排序
  sort_by_speed: true

云端保存配置

GitHub Gist
yaml
save_config:
  github_gist:
    enabled: true
    token: "ghp_your_github_token"
    gist_id: "your_gist_id"
    filename: "subscription.yaml"
AWS S3
yaml
save_config:
  s3:
    enabled: true
    bucket: "your-bucket-name"
    region: "us-west-2"
    access_key: "YOUR_ACCESS_KEY"
    secret_key: "YOUR_SECRET_KEY"
    path: "subscriptions/"
MinIO
yaml
save_config:
  minio:
    enabled: true
    endpoint: "https://minio.example.com"
    bucket: "subscriptions"
    access_key: "minio_access_key"
    secret_key: "minio_secret_key"
WebDAV
yaml
save_config:
  webdav:
    enabled: true
    url: "https://dav.example.com/remote.php/dav/files/username/"
    username: "your_username"
    password: "your_password"
    path: "subscriptions/"

📊 结果分析

生成的文件说明

Clash 格式 (*.yaml)

标准的 Clash 配置文件,可直接导入 Clash 系列客户端:

yaml
# all.yaml - 所有通过测试的节点
proxies:
  - name: "🇭🇰 香港-01"
    type: vmess
    server: 1.2.3.4
    port: 443
    # ... 其他配置
    
proxy-groups:
  - name: "🚀 手动切换"
    type: select
    proxies: ["🇭🇰 香港-01", ...]

V2Ray 格式 (*.json)

标准的 V2Ray 配置文件:

json
{
  "outbounds": [
    {
      "tag": "HK-01",
      "protocol": "vmess",
      "settings": {
        "vnext": [{
          "address": "1.2.3.4",
          "port": 443,
          "users": [...]
        }]
      }
    }
  ]
}

Shadowsocks 格式 (*.txt)

Shadowsocks 链接列表:

ss://base64encoded@server:port#HK-01
ss://base64encoded@server:port#SG-02
ss://base64encoded@server:port#JP-03

统计报告

程序会生成详细的统计报告:

订阅检查完成!

📊 处理统计:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• 订阅源数量: 3 个
• 原始节点: 1,245 个
• 去重后节点: 892 个
• 可用节点: 456 个
• 高速节点 (>50MB/s): 89 个

🌍 地区分布:
• 🇭🇰 香港: 156 个 (平均延迟: 25ms, 平均速度: 85MB/s)
• 🇸🇬 新加坡: 124 个 (平均延迟: 35ms, 平均速度: 78MB/s)
• 🇯🇵 日本: 98 个 (平均延迟: 45ms, 平均速度: 92MB/s)
• 🇺🇸 美国: 78 个 (平均延迟: 120ms, 平均速度: 156MB/s)

🎬 流媒体解锁:
• Netflix: 234 个节点
• YouTube Premium: 445 个节点
• Disney+: 156 个节点
• HBO Max: 89 个节点

📁 生成文件:
• results/all.yaml (456 个节点)
• results/premium.yaml (89 个节点)
• results/netflix.yaml (234 个节点)
• results/hk_nodes.yaml (156 个节点)

⚡ 高级用法

批处理脚本

创建批处理脚本来定期更新订阅:

bash
#!/bin/bash
# update_subscriptions.sh

echo "开始更新订阅..."

# 更新主要订阅
ed sub-check -f config/main.yaml

# 更新备用订阅
ed sub-check -f config/backup.yaml

# 合并结果
cat results/main_*.yaml results/backup_*.yaml > results/combined.yaml

echo "订阅更新完成!"

定时任务

使用 cron 设置定时更新:

bash
# 编辑 crontab
crontab -e

# 每天凌晨 2 点更新订阅
0 2 * * * cd /home/user/ed-subscriptions && ./update_subscriptions.sh

# 每 6 小时检查一次
0 */6 * * * cd /home/user/ed-subscriptions && ed sub-check -f config/hourly.yaml

多环境配置

为不同用途创建不同的配置文件:

bash
# 游戏优化配置(注重延迟)
ed sub-check -f config/gaming.yaml

# 流媒体配置(注重解锁能力)  
ed sub-check -f config/streaming.yaml

# 下载配置(注重速度)
ed sub-check -f config/download.yaml

gaming.yaml 示例

yaml
subscriptions:
  urls: [...]

testing:
  max_latency: 80      # 严格的延迟要求
  min_speed: 10        # 相对较低的速度要求
  concurrent: 500      # 更高的并发数

filters:
  include_regions:
    - "香港"
    - "新加坡"
    - "日本"

output:
  sort_by: "latency"   # 按延迟排序
  filename_template: "gaming_{date}"

streaming.yaml 示例

yaml
subscriptions:
  urls: [...]

media_check:
  enabled: true
  platforms:
    netflix: 
      enabled: true
      regions: ["US", "JP", "KR", "UK"]
    disney_plus:
      enabled: true
    hbo_max:
      enabled: true

filters:
  include_regions:
    - "美国"
    - "日本"
    - "韩国"
    - "英国"

output:
  group_by_platform: true
  filename_template: "streaming_{platform}_{date}"

结果过滤和处理

按性能筛选

bash
# 仅保留高速节点
ed sub-check -f config.yaml --min-speed 50

# 仅保留低延迟节点
ed sub-check -f config.yaml --max-latency 50

# 组合条件
ed sub-check -f config.yaml --min-speed 30 --max-latency 80

按地区筛选

bash
# 仅测试亚洲节点
ed sub-check -f config.yaml --regions "香港,新加坡,日本,韩国"

# 排除某些地区
ed sub-check -f config.yaml --exclude-regions "印度,俄罗斯"

🔧 故障排除

常见问题

订阅链接无法访问

症状: 提示 "Failed to fetch subscription"

解决方案:

  1. 检查网络连接
  2. 验证订阅链接有效性
  3. 检查是否需要代理访问
  4. 确认订阅链接未过期
yaml
# 为订阅链接配置代理
subscriptions:
  proxy: "http://127.0.0.1:7890"
  urls: [...]

节点测试失败率高

症状: 大部分节点测试失败

解决方案:

  1. 调整并发数和超时设置
  2. 检查本地网络环境
  3. 尝试不同的测试时间
yaml
testing:
  concurrent: 50        # 降低并发数
  timeout: 10          # 增加超时时间
  retry_count: 3       # 增加重试次数

流媒体检测不准确

症状: 明明能解锁的节点显示不支持

解决方案:

  1. 增加检测超时时间
  2. 更新检测规则
  3. 检查检测服务可用性
yaml
media_check:
  timeout: 15          # 增加超时时间
  retry_count: 2       # 增加重试
  use_backup_api: true # 使用备用检测接口

性能优化

提升检测速度

yaml
testing:
  concurrent: 500      # 增加并发数(注意系统限制)
  batch_size: 100      # 批处理大小
  enable_cache: true   # 启用结果缓存
  cache_ttl: 3600     # 缓存有效期(秒)

减少资源消耗

yaml
testing:
  concurrent: 50       # 降低并发数
  enable_speed_test: false  # 禁用速度测试
  quick_mode: true     # 快速模式(仅基础检测)

🎯 最佳实践

1. 订阅源管理

  • 多样化: 使用多个不同提供商的订阅源
  • 备份: 定期备份优质的订阅链接
  • 更新: 及时移除失效的订阅源

2. 测试策略

  • 分时段: 避开网络高峰期进行测试
  • 分批次: 大量节点分批测试,避免网络拥堵
  • 差异化: 针对不同用途使用不同的测试标准

3. 结果管理

  • 版本控制: 使用 Git 管理配置文件和结果
  • 云端同步: 利用云存储实现多设备同步
  • 定期清理: 清理过期的测试结果和缓存

准备好了解完整的工作流了吗?查看 Mihomo集成 了解如何使用完整的IP测试+代理生成工作流,或查看 MCP 服务器模式 了解如何将 ed 集成到 AI 工作流中!

Released under the MIT License.