Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 让 SUB-RULE 支持 MATCH #1787

Open
3 tasks done
Hubedge opened this issue Jan 11, 2025 · 2 comments
Open
3 tasks done

[Feature] 让 SUB-RULE 支持 MATCH #1787

Hubedge opened this issue Jan 11, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@Hubedge
Copy link

Hubedge commented Jan 11, 2025

验证步骤

  • 我已经阅读了 文档,确认了该功能没有实现
  • 我已在 Issue Tracker 中寻找过我要提出的功能请求,并且没有找到
  • 我是中文用户,而非其他语言用户

描述

增加对以下语法之一的支持,即无条件按some-sub-rule进一步匹配。之所以不把some-sub-rule的内容直接贴到rules末尾,是因为还有其他多处使用some-sub-rule

rules:
  - SUB-RULE,(MATCH),some-sub-rule
  - SUB-RULE,(MATCH,),some-sub-rule

目前的临时解决方案是

rules:
  - SUB-RULE,(DST-PORT,0-65535),some-sub-rule
@Hubedge Hubedge added the enhancement New feature or request label Jan 11, 2025
@cresky-github
Copy link

此功能,无必要。
MATCH,就穷尽所有已知之后的终极规则。
子规则,就是没有穷尽,逻辑上错误。

@Hubedge
Copy link
Author

Hubedge commented Jan 19, 2025

此功能,无必要。 MATCH,就穷尽所有已知之后的终极规则。 子规则,就是没有穷尽,逻辑上错误。

我把我的用例说得再明白些。auto-proxy是一个sub-rule,用来自动选择出口(走proxy1还是proxy2)。所有应走代理的目标地址都由auto-proxy来分流。由于rules本身的复杂性,auto-proxy不适合被拆分打散后放进rules

auto-proxy 中的最后一条规则是 MATCH,有穷尽,不存在你说的逻辑错误。

rules:
  # 实际用例比下面的更复杂,穿插大量auto-proxy、DIRECT,且顺序重要
  - GEOSITE,category-ads-all,REJECT
  - DOMAIN,cdn.gotraffic.net,auto-proxy
  - GEOSITE,youtube,auto-proxy
  - DOMAIN-SUFFIX,dev,auto-proxy
  - DOMAIN-SUFFIX,steamstatic.com,DIRECT
  - DOMAIN-SUFFIX,steamcontent.com,DIRECT
  - DOMAIN-SUFFIX,steamserver.com,DIRECT
  - DOMAIN-SUFFIX,steamserver.net,DIRECT
  - SUB-RULE,(GEOSITE,geolocation-!cn),auto-proxy
  - GEOSITE,CN,DIRECT
  - SUB-RULE,(DST-PORT,0-65535),auto-proxy


sub-rules:
  auto-proxy:
    # 如有 IP,先匹配 IP
    - IP-ASN,13335,proxy1,no-resolve
    - IP-ASN,209242,proxy1,no-resolve

    # 减少 DNS 查询
    - GEOSITE,cloudflare,proxy1
    - GEOSITE,poe,proxy1
    - GEOSITE,sci-hub,proxy1
    - GEOSITE,google,proxy2
    - GEOSITE,wikimedia,proxy2
    - GEOSITE,youtube,proxy2
    - GEOSITE,dropbox,proxy2
    - GEOSITE,microsoft,proxy2
    - GEOSITE,github,proxy2
    - GEOSITE,amazon,proxy2
    - GEOSITE,akamai,proxy2
    - GEOSITE,reddit,proxy2
    - GEOSITE,apple,proxy2
    - GEOSITE,facebook,proxy2
    - DOMAIN,cdn.jsdelivr.net,proxy2

    # 有 DNS 查询
    - IP-ASN,13335,proxy1
    - IP-ASN,209242,proxy1
    - IP-ASN,399566,proxy1

    - MATCH,proxy2
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants