MetaCubeX / mihomo

A simple Python Pydantic model for Honkai: Star Rail parsed data from the Mihomo API.
https://wiki.metacubex.one
MIT License
16.49k stars 2.65k forks source link

[Bug] 规则集中的某些 IPv6 匹配不到 #631

Open letsky192 opened 1 year ago

letsky192 commented 1 year ago

Verify steps

Clash version

Clash Meta v1.14.5 windows amd64 with go1.20.4 Sat Jun 3 10:10:51 UTC 2023

What OS are you seeing the problem on?

Windows

Clash config

mixed-port: 7890
allow-lan: false
mode: Rule
log-level: info
external-controller: 127.0.0.1:9090
dns:
  enable: true
  ipv6: true
  use-hosts: false
  nameserver:
    - tls://1.12.12.12:853
    - tls://223.5.5.5:853
proxies:
  - name: 🇰🇷 D32 韩国
    server: ***********
    port: ***********
    type: ssr
    ***********
    udp: true
proxy-groups:
  - name: 手动选择
    type: select
    proxies:

  - name: OpenAI
    type: select
    proxies:

  - name: 微软
    type: select
    proxies:

rules:
  - DOMAIN,clash.razord.top,DIRECT
  - DOMAIN,yacd.haishan.me,DIRECT
  - RULE-SET,openai,OpenAI
  - RULE-SET,Microsoft,微软
  - RULE-SET,ChinaDomain,DIRECT
  - RULE-SET,google,DIRECT
  - RULE-SET,direct,DIRECT
  - RULE-SET,gfw,手动选择
  - RULE-SET,tld-not-cn,手动选择
  - RULE-SET,BanAD,REJECT
  - GEOIP,LAN,DIRECT,no-resolve
  - RULE-SET,telegramcidr,手动选择,no-resolve
  - RULE-SET,cnv4,DIRECT
  - RULE-SET,cnv6,DIRECT
  - MATCH,手动选择
proxy-providers: {}
rule-providers:
  cnv4:
    type: http
    behavior: ipcidr
    url: https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt
    path: ./providers/rule/f38f39582268e9bd2853e38b1ce1b573.yaml
    interval: 14400
    format: text
  cnv6:
    type: http
    behavior: ipcidr
    url: https://raw.githubusercontent.com/carrnot/china-ip-list/release/ipv6.txt
    path: ./providers/rule/9c60f46718d383f5c22efa993c3efe9e.yaml
    interval: 14400
    format: text
  ChinaDomain:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaDomain.list
    path: ./providers/rule/ef34e934adab8d378ac0708c7daa815f.yaml
    interval: 14400
    format: text
  Microsoft:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Microsoft.list
    path: ./providers/rule/464c59f3d07810901cf5ff6978049350.yaml
    interval: 14400
    format: text
  direct:
    type: http
    behavior: domain
    url: https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/direct.txt
    path: ./providers/rule/d0c14b6e78b7fdf6b5e052bba12f3c23.yaml
    interval: 14400
    format: yaml
  google:
    type: http
    behavior: domain
    url: https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/google.txt
    path: ./providers/rule/5d00ae2bb8bed874f1bf570a5e03c96d.yaml
    interval: 14400
    format: yaml
  gfw:
    type: http
    behavior: domain
    url: https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/gfw.txt
    path: ./providers/rule/ee6791ce50b77608a6ea7150a4a7bb06.yaml
    interval: 14400
    format: yaml
  tld-not-cn:
    type: http
    behavior: domain
    url: https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/tld-not-cn.txt
    path: ./providers/rule/1d6696a4cfc9586c72e6d20b5f338820.yaml
    interval: 14400
    format: yaml
  telegramcidr:
    type: http
    behavior: ipcidr
    url: https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/telegramcidr.txt
    path: ./providers/rule/efa90433479cee1d3f966131b367a760.yaml
    interval: 14400
    format: yaml
  BanAD:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanAD.list
    path: ./providers/rule/6c03dd852974e81b6b19e0e281769d4a.yaml
    interval: 14400
    format: text
  openai:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/letiensky/chatgpt-openclash/patched/chatgpt.list
    path: ./providers/rule/ffb613e686101b9b5b0083ea09805116.yaml
    interval: 14400
    format: text

Clash log

time="2023-06-21T15:37:45.9239659+08:00" level=info msg="Start initial configuration in progress"
time="2023-06-21T15:37:45.9239659+08:00" level=info msg="Geodata Loader mode: memconservative"
time="2023-06-21T15:37:45.9379512+08:00" level=info msg="Initial configuration complete, total time: 13ms"
time="2023-06-21T15:37:45.9379512+08:00" level=info msg="Sniffer is closed"
time="2023-06-21T15:37:45.9389868+08:00" level=info msg="RESTful API listening at: 127.0.0.1:1588"
time="2023-06-21T15:37:45.9395197+08:00" level=info msg="Mixed(http+socks) proxy listening at: [::]:7890"
time="2023-06-21T15:37:45.9395197+08:00" level=info msg="Start initial compatible provider default"
time="2023-06-21T15:37:46.8845942+08:00" level=info msg="Start initial configuration in progress"
time="2023-06-21T15:37:46.887963+08:00" level=info msg="Geodata Loader mode: memconservative"
time="2023-06-21T15:37:46.8991774+08:00" level=info msg="Initial configuration complete, total time: 14ms"
time="2023-06-21T15:37:46.8991774+08:00" level=info msg="Sniffer is closed"
time="2023-06-21T15:37:46.8991774+08:00" level=info msg="Start initial compatible provider 手动选择"
time="2023-06-21T15:37:46.8991774+08:00" level=info msg="Start initial compatible provider default"
time="2023-06-21T15:37:46.8991774+08:00" level=info msg="Start initial compatible provider OpenAI"
time="2023-06-21T15:37:46.8991774+08:00" level=info msg="Start initial compatible provider 微软"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider cnv6"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider direct"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider Microsoft"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider google"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider gfw"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider tld-not-cn"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider BanAD"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider ChinaCompanyIp"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider cnv4"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider openai"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider telegramcidr"
time="2023-06-21T15:37:46.8997144+08:00" level=info msg="Start initial provider ChinaDomain"
time="2023-06-21T15:38:12.3426594+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:12.3435058+08:00" level=debug msg="[DNS] resolve safebrowsing.googleapis.com from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.3435058+08:00" level=debug msg="[DNS] resolve safebrowsing.googleapis.com from tls://1.12.12.12:853"
time="2023-06-21T15:38:12.3440142+08:00" level=debug msg="[DNS] resolve safebrowsing.googleapis.com from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.3440142+08:00" level=debug msg="[DNS] resolve safebrowsing.googleapis.com from tls://1.12.12.12:853"
time="2023-06-21T15:38:12.3440142+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:12.3450226+08:00" level=debug msg="[DNS] resolve *********** from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.3450226+08:00" level=debug msg="[DNS] resolve *********** from tls://1.12.12.12:853"
time="2023-06-21T15:38:12.3450226+08:00" level=debug msg="[DNS] resolve *********** from tls://1.12.12.12:853"
time="2023-06-21T15:38:12.3450226+08:00" level=debug msg="[DNS] resolve *********** from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.3440142+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:12.5425427+08:00" level=debug msg="[DNS] safebrowsing.googleapis.com --> [], from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.5439774+08:00" level=debug msg="[DNS] safebrowsing.googleapis.com --> [120.253.250.225], from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.5439774+08:00" level=debug msg="[DNS] *********** --> [***********], from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.5445726+08:00" level=debug msg="[DNS] *********** --> [], from tls://223.5.5.5:853"
time="2023-06-21T15:38:12.5602944+08:00" level=info msg="[TCP] 127.0.0.1:1715 --> safebrowsing.googleapis.com:443 match RuleSet(google) using DIRECT"
time="2023-06-21T15:38:12.5620298+08:00" level=info msg="[TCP] 127.0.0.1:1716 --> cdn.jsdelivr.net:443 match RuleSet(gfw) using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:12.56435+08:00" level=info msg="[TCP] 127.0.0.1:1717 --> cdn.jsdelivr.net:443 match RuleSet(gfw) using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:13.1213782+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:13.1218865+08:00" level=debug msg="[DNS] resolve *********** from tls://223.5.5.5:853"
time="2023-06-21T15:38:13.1218865+08:00" level=debug msg="[DNS] resolve *********** from tls://1.12.12.12:853"
time="2023-06-21T15:38:13.1218865+08:00" level=debug msg="[DNS] resolve *********** from tls://223.5.5.5:853"
time="2023-06-21T15:38:13.1224226+08:00" level=debug msg="[DNS] resolve *********** from tls://1.12.12.12:853"
time="2023-06-21T15:38:13.141175+08:00" level=info msg="[TCP] 127.0.0.1:1729 --> [2409:8087:7000:20:1000::22]:6060 match Match using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:13.1917403+08:00" level=debug msg="[DNS] *********** --> [], from tls://223.5.5.5:853"
time="2023-06-21T15:38:13.2006006+08:00" level=debug msg="[DNS] *********** --> [***********], from tls://223.5.5.5:853"
time="2023-06-21T15:38:13.7056664+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:13.7248378+08:00" level=info msg="[TCP] 127.0.0.1:1739 --> [2409:8087:7001:20:1000::84]:6410 match Match using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:14.2574822+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:14.2574822+08:00" level=debug msg="[DNS] resolve *********** from tls://223.5.5.5:853"
time="2023-06-21T15:38:14.2574822+08:00" level=debug msg="[DNS] resolve *********** from tls://1.12.12.12:853"
time="2023-06-21T15:38:14.2574822+08:00" level=debug msg="[DNS] resolve *********** from tls://223.5.5.5:853"
time="2023-06-21T15:38:14.2574822+08:00" level=debug msg="[DNS] resolve *********** from tls://1.12.12.12:853"
time="2023-06-21T15:38:14.2749712+08:00" level=info msg="[TCP] 127.0.0.1:1746 --> [2409:8087:7001:20:1000::87]:6610 match Match using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:14.3217345+08:00" level=debug msg="[DNS] *********** --> [***********], from tls://223.5.5.5:853"
time="2023-06-21T15:38:14.3317543+08:00" level=debug msg="[DNS] *********** --> [], from tls://223.5.5.5:853"
time="2023-06-21T15:38:14.852234+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:14.8705998+08:00" level=info msg="[TCP] 127.0.0.1:1752 --> [2409:8087:7001:20:1000::87]:6610 match Match using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:14.9488732+08:00" level=debug msg="[Rule] use default rules"
time="2023-06-21T15:38:14.9678837+08:00" level=info msg="[TCP] 127.0.0.1:1757 --> [2409:8087:7001:20:1000::87]:6610 match Match using 手动选择[🇰🇷 D32 韩国]"
time="2023-06-21T15:38:23.0032226+08:00" level=debug msg="[Rule] use default rules"

Description

如日志所见,cnv6 中的 2409:8000::/20 没匹配到。 但如果去掉前面的域名规则,只留最后的 IP 规则,能匹配到如 6.ipw.cnhttp://[2001:da8:201:1512::a269:83a0]/ 等一些 v6 地址,也就是规则集应该是生效了。 另外,如果用 lancidr 这个规则集,在浏览器访问路由器的局域网地址 http://[fdb0:735d:3bda:6a00:b273:5dff:fe3b:da6a]/ 也不能匹配到其中的 fc00::/7。

coolAning commented 1 year ago

好像是如果dns返回v4和v6地址 那么v4优先 不会去匹配v6的规则 纯ipv6没问题

xishang0128 commented 1 year ago

正常行为,ip只会取一个

letsky192 commented 1 year ago

好像是如果dns返回v4和v6地址 那么v4优先 不会去匹配v6的规则 纯ipv6没问题

我是用地址访问的,应该没有 DNS 这步,也不涉及 v4