Skip to content

Fix: 规则缺少 TARGET 字段导致 proxy not found 错误#2028

Open
bazhuang wants to merge 1 commit into
chen08209:mainfrom
bazhuang:fix/rule-missing-target
Open

Fix: 规则缺少 TARGET 字段导致 proxy not found 错误#2028
bazhuang wants to merge 1 commit into
chen08209:mainfrom
bazhuang:fix/rule-missing-target

Conversation

@bazhuang

Copy link
Copy Markdown

Fix: 规则缺少 TARGET 字段导致 proxy not found 错误

  • 分支: fix/rule-missing-target
  • 日期: 2026-05-20

问题描述

部分订阅源 (如:shadowsocks) 生成的规则缺少 TARGET(代理目标)字段,例如:

IP-CIDR,192.133.76.0/22,no-resolve

mihomo 引擎按逗号分割后将 no-resolve 误认为代理名,报错:

rules[227] [IP-CIDR,192.133.76.0/22,no-resolve] error: proxy [no-resolve] not found

正确的规则格式应为:

IP-CIDR,192.133.76.0/22,DIRECT,no-resolve

修改文件

lib/common/task.dart

  1. 新增 _fixRules 函数(第 76-111 行)

    • 检测规则中非参数部分少于 3 段(TYPE, CONTENT, TARGET)的情况
    • 自动插入默认 TARGET 字段
    • 默认使用 DIRECT;若规则列表中存在 MATCH 规则,则使用其 TARGET
  2. _makeRealProfileTask 中调用 _fixRules(第 254 行)

    • 在原始 rules 写入 rawConfig 之前进行修复

影响范围

  • 仅影响从订阅配置读取的原始规则列表,不影响用户手动添加的规则
  • 对格式正确的规则无任何影响(3 段及以上的规则直接跳过)
  • MATCH 和 SUB-RULE 类型的规则不做处理

EyKettle added a commit to EyKettle/FlClash that referenced this pull request Jun 29, 2026
Cherry-pick 8 selected PRs fixing critical bugs and security issues:

  chen08209#2136  fix: new rule overwrites existing rule with duplicate id -1
  chen08209#2131  fix: window close blocked by back-blocked UI state
  chen08209#2103  fix: propagate UID from getConnectionOwnerUid through JNI
  chen08209#1996  fix: Android :remote process SIGABRT on VPN start
  chen08209#2018  fix: unsafe malloc() dereference in jni_helper.cpp
  chen08209#1938  fix: Zip Slip path traversal in backup restore
  chen08209#2132  fix: Android QR scanning difficulty

Additionally:
- Custom _fixRules patch for subscription rules missing TARGET field
  (upstream chen08209#2028 original approach, redesigned for minimal diff)
- Switch submodule URLs from SSH to HTTPS for CI compatibility
EyKettle added a commit to EyKettle/FlClash that referenced this pull request Jun 30, 2026
Cherry-pick 8 selected PRs fixing critical bugs and security issues:

  chen08209#2136  fix: new rule overwrites existing rule with duplicate id -1
  chen08209#2131  fix: window close blocked by back-blocked UI state
  chen08209#2103  fix: propagate UID from getConnectionOwnerUid through JNI
  chen08209#1996  fix: Android :remote process SIGABRT on VPN start
  chen08209#2018  fix: unsafe malloc() dereference in jni_helper.cpp
  chen08209#1938  fix: Zip Slip path traversal in backup restore
  chen08209#2132  fix: Android QR scanning difficulty

Additionally:
- Custom _fixRules patch for subscription rules missing TARGET field
  (upstream chen08209#2028 original approach, redesigned for minimal diff)
- Switch submodule URLs from SSH to HTTPS for CI compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant