MetaCubeX / mihomo

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

[Bug] 指定 ipv4 之后仍然会解析 ipv6 地址 #1188

Closed kierankihn closed 7 months ago

kierankihn commented 7 months ago

Verify steps

Mihomo version

1.18.3

What OS are you seeing the problem on?

Windows

Mihomo config

mode: rule
mixed-port: 7890
socks-port: 7891
port: 7892
allow-lan: true
log-level: debug
secret: 'example'
external-controller: 127.0.0.1:9097
country-auto-select-config:
  type: url-test
  use:
  - ✈️Example
  url: https://www.gstatic.com/generate_204
  interval: 300
  lazy: true
  timeout: 5000
bind-address: '*'
tun:
  stack: gvisor
  device: Meta
  auto-route: true
  strict-route: false
  auto-detect-interface: true
  dns-hijack:
  - any:53
  mtu: 9000
  enable: true
experimental:
  ignore-resolve-fail: true
geo-auto-update: true
geox-url:
  geoip: https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat
  geosite: https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat
dns:
  enable: true
  ipv6: false
  prefer-h3: true
  listen: 0.0.0.0:53
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  nameserver:
  - https://223.5.5.5/dns-query
  - https://1.12.12.12/dns-query
  fallback:
  - https://8.8.8.8/dns-query
  - https://1.1.1.1/dns-query
  fallback-filter:
    geoip: true
    ipcidr:
    - 240.0.0.0/4
  fake-ip-filter:
  - dns.msftncsi.com
  - www.msftncsi.com
  - www.msftconnecttest.com
all-proxy-groups:
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
geo-update-interval: 24
proxy-providers:
  ✈️Example:
    type: http
    url: https://example.com/
    interval: 86400
    path: ./Example.yaml
    health-check:
      enable: true
      interval: 600
      url: https://www.gstatic.com/generate_204
    override:
      udp: true
      ip-version: ipv4
proxy-groups:
- name: ✈️国外流量
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: Apple
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: 巴哈姆特
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: Bilibili
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: Games
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: Imgur
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: OneDrive
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: 自建服务
  type: select
  proxies:
  - 🚀直接连接
  - 🚫拒绝连接
  - 🇯🇵日本
  - 🇸🇬新加坡
  - 🇹🇼台湾
  - 🇺🇸美国
  use:
  - ✈️Example
- name: 🇯🇵日本
  filter: (?i)日本|japan|jp
  type: url-test
  use:
  - ✈️Example
  url: https://www.gstatic.com/generate_204
  interval: 300
  lazy: true
  timeout: 5000
- name: 🇸🇬新加坡
  filter: (?i)新加坡|singapore|sg
  type: url-test
  use:
  - ✈️Example
  url: https://www.gstatic.com/generate_204
  interval: 300
  lazy: true
  timeout: 5000
- name: 🇹🇼台湾
  filter: (?i)台湾|taiwan|tw
  type: url-test
  use:
  - ✈️Example
  url: https://www.gstatic.com/generate_204
  interval: 300
  lazy: true
  timeout: 5000
- name: 🇺🇸美国
  timeout: 5000
  filter: (?i)美国|united states|us
  type: url-test
  use:
  - ✈️Example
  url: https://www.gstatic.com/generate_204
  interval: 300
  lazy: true
- name: 🚀直接连接
  type: select
  proxies:
  - DIRECT
- name: 🚫拒绝连接
  type: select
  proxies:
  - REJECT
rules:
- GEOSITE,private,🚀直接连接
- GEOSITE,apple,Apple
- GEOSITE,bahamut,巴哈姆特
- GEOSITE,bilibili,Bilibili
- GEOSITE,category-games@cn,Games
- GEOSITE,imgur,Imgur
- GEOSITE,onedrive,OneDrive
- DOMAIN-SUFFIX,example.com,自建服务
- GEOSITE,cn,🚀直接连接
- GEOIP,private,🚀直接连接,no-resolve
- GEOIP,telegram,✈️国外流量,no-resolve
- MATCH,✈️国外流量

Mihomo log

2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1395625+08:00" level=debug msg="[DNS] resolve loj.ac from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1395625+08:00" level=debug msg="[DNS] resolve loj.ac from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1395625+08:00" level=debug msg="[DNS] resolve loj.ac from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1395625+08:00" level=debug msg="[DNS] resolve loj.ac from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1411177+08:00" level=debug msg="[DNS] resolve bootstrap.loj.ac.cn from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1411177+08:00" level=debug msg="[DNS] resolve bootstrap.loj.ac.cn from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1411177+08:00" level=debug msg="[DNS] resolve bootstrap.loj.ac.cn from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1411177+08:00" level=debug msg="[DNS] resolve bootstrap.loj.ac.cn from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.1985709+08:00" level=debug msg="[DNS] loj.ac --> [] AAAA from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.2060668+08:00" level=debug msg="[DNS] loj.ac --> [13.107.213.49] A from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.2227689+08:00" level=debug msg="[DNS] bootstrap.loj.ac.cn --> [123.6.118.252] A from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.2278606+08:00" level=debug msg="[DNS] bootstrap.loj.ac.cn --> [2408:8720:800:385:3::3fb] AAAA from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.3239666+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.3239666+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.3245915+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.3245915+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.6580479+08:00" level=debug msg="[DNS] api.loj.ac --> [2606:4700:3037::6815:52b7 2606:4700:3036::ac43:a172] AAAA from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.6628403+08:00" level=debug msg="[DNS] api.loj.ac --> [104.21.82.183 172.67.161.114] A from https://1.12.12.12:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9192004+08:00" level=debug msg="[DNS] resolve loj.ac from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9192004+08:00" level=debug msg="[DNS] resolve loj.ac from https://8.8.8.8:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9192004+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9192004+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://8.8.8.8:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9203802+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9204516+08:00" level=debug msg="[DNS] resolve api.loj.ac from https://8.8.8.8:443/dns-query"
2024-04-13 14:52:14 INFO - [clash]: time="2024-04-13T14:52:14.9254647+08:00" level=info msg="[TCP] 127.0.0.1:57519 --> bootstrap.loj.ac.cn:443 match GeoSite(cn) using 🚀直接连接[DIRECT]"
2024-04-13 14:52:15 INFO - [clash]: time="2024-04-13T14:52:15.6594793+08:00" level=debug msg="[DNS] api.loj.ac --> [104.21.82.183 172.67.161.114] A from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:15 INFO - [clash]: time="2024-04-13T14:52:15.7426337+08:00" level=debug msg="[DNS] loj.ac --> [104.21.82.183 172.67.161.114] A from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:15 INFO - [clash]: time="2024-04-13T14:52:15.9906176+08:00" level=debug msg="[DNS] loj.ac --> [2606:4700:3037::6815:52b7 2606:4700:3036::ac43:a172] AAAA from https://223.5.5.5:443/dns-query"
2024-04-13 14:52:15 INFO - [clash]: time="2024-04-13T14:52:15.9906176+08:00" level=debug msg="[DNS] resolve loj.ac from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:15 INFO - [clash]: time="2024-04-13T14:52:15.9906176+08:00" level=debug msg="[DNS] resolve loj.ac from https://8.8.8.8:443/dns-query"
2024-04-13 14:52:16 INFO - [clash]: time="2024-04-13T14:52:16.0787987+08:00" level=debug msg="[DNS] api.loj.ac --> [2606:4700:3036::ac43:a172 2606:4700:3037::6815:52b7] AAAA from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:16 INFO - [clash]: time="2024-04-13T14:52:16.0815755+08:00" level=debug msg="[DNS] cache hit for loj.ac., expire at 2024-04-13 15:02:15"
2024-04-13 14:52:16 INFO - [clash]: time="2024-04-13T14:52:16.5580937+08:00" level=debug msg="[DNS] loj.ac --> [2606:4700:3037::6815:52b7 2606:4700:3036::ac43:a172] AAAA from https://1.1.1.1:443/dns-query"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.1398946+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57518 --> loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.1405482+08:00" level=debug msg="[DNS] cache hit for loj.ac., expire at 2024-04-13 15:02:16"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.1405482+08:00" level=debug msg="[DNS] cache hit for loj.ac., expire at 2024-04-13 15:02:15"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.3250547+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57520 --> api.loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.3250547+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57521 --> api.loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.3261163+08:00" level=debug msg="[DNS] cache hit for api.loj.ac., expire at 2024-04-13 14:57:15"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.3261163+08:00" level=debug msg="[DNS] cache hit for api.loj.ac., expire at 2024-04-13 14:57:16"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.3266288+08:00" level=debug msg="[DNS] cache hit for api.loj.ac., expire at 2024-04-13 14:57:15"
2024-04-13 14:52:19 INFO - [clash]: time="2024-04-13T14:52:19.3266288+08:00" level=debug msg="[DNS] cache hit for api.loj.ac., expire at 2024-04-13 14:57:16"
2024-04-13 14:52:21 INFO - [clash]: time="2024-04-13T14:52:21.082493+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57543 --> loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout"
2024-04-13 14:52:21 INFO - [clash]: time="2024-04-13T14:52:21.0835765+08:00" level=debug msg="[DNS] cache hit for loj.ac., expire at 2024-04-13 15:02:15"
2024-04-13 14:52:21 INFO - [clash]: time="2024-04-13T14:52:21.0835765+08:00" level=debug msg="[DNS] cache hit for loj.ac., expire at 2024-04-13 15:02:16"
2024-04-13 14:52:24 INFO - [clash]: time="2024-04-13T14:52:24.1406744+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57548 --> loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout\nconnect failed: dial tcp [2606:4700:3037::6815:52b7]:443: connectex: The requested address is not valid in its context.\ndial tcp [2606:4700:3036::ac43:a172]:443: connectex: The requested address is not valid in its context."
2024-04-13 14:52:24 INFO - [clash]: time="2024-04-13T14:52:24.3328167+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57553 --> api.loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout\nconnect failed: dial tcp [2606:4700:3036::ac43:a172]:443: connectex: The requested address is not valid in its context.\ndial tcp [2606:4700:3037::6815:52b7]:443: connectex: The requested address is not valid in its context."
2024-04-13 14:52:24 INFO - [clash]: time="2024-04-13T14:52:24.3328167+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57552 --> api.loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout\nconnect failed: dial tcp [2606:4700:3036::ac43:a172]:443: connectex: The requested address is not valid in its context.\ndial tcp [2606:4700:3037::6815:52b7]:443: connectex: The requested address is not valid in its context."
2024-04-13 14:52:26 INFO - [clash]: time="2024-04-13T14:52:26.0942318+08:00" level=warning msg="[TCP] dial 🚀直接连接 (match GeoSite/cn) 127.0.0.1:57562 --> loj.ac:443 error: connect failed: dial tcp 104.21.82.183:443: i/o timeout\ndial tcp 172.67.161.114:443: i/o timeout\nconnect failed: dial tcp [2606:4700:3037::6815:52b7]:443: connectex: The requested address is not valid in its context.\ndial tcp [2606:4700:3036::ac43:a172]:443: connectex: The requested address is not valid in its context."

Description

在 dns 配置中配置了 ipv6: false 之后仍然解析 ipv6 并且使用 ipv6 访问

然而我本地网络并不支持 ipv6,所以无法成功连接

xishang0128 commented 7 months ago

从日志来看,并没有向ipv6地址发起的连接,而是ipv4 timeout

twiehpooh commented 4 months ago
mode: rule
mixed-port: 7897
allow-lan: true
log-level: debug
ipv6: true
external-controller: 127.0.0.1:9097
secret: ''
global-client-fingerprint: edge
geox-url:
  geoip: https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat
  geosite: https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat
  mmdb: https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country.mmdb
profile:
  store-selected: true
  store-fake-ip: true
tun:
  enable: true
  stack: mixed
  dns-hijack:
  - any:53
  auto-route: true
  device: Mihomo
  auto-detect-interface: true
  strict-route: false
  mtu: 1500
c:
  type: http
  behavior: classical
  interval: 86400
dns:
  enable: true
  prefer-h3: false
  listen: 0.0.0.0:53
  ipv6: false
  default-nameserver:
  - 127.0.0.1:6553
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:
  - '*.lan'
  - localhost.ptlogin2.qq.com
  - +.stun.*.*
  - +.stun.*.*.*
  - +.stun.*.*.*.*
  - +.stun.*.*.*.*.*
  - '*.n.n.srv.nintendo.net'
  - +.stun.playstation.net
  - xbox.*.*.microsoft.com
  - '*.*.xboxlive.com'
  - WORKGROUP
  - '*.wecheat.cn'
  - '*.msftncsi.com'
  - '*.msftconnecttest.com'
  nameserver:
  - https://8.8.8.8/dns-query#DNS&h3=false
  - https://1.1.1.1/dns-query#DNS&h3=false
  - https://94.140.14.140/dns-query#DNS&h3=false
  nameserver-policy:
    '*.msftncsi.com,*.msftconnecttest.com':
    - https://8.8.8.8/dns-query#DNS&h3=false
    - https://1.1.1.1/dns-query#DNS&h3=false
    - https://94.140.14.140/dns-query#DNS&h3=false
    geosite:private,apple-cn,google-cn,cn,category-games@cn:
    - tls://1.12.12.12:853#h3=false
    - https://223.5.5.5/dns-query#h3=false
    - tls://120.53.53.53#h3=false
  use-hosts: true
  fallback: []
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[DNS] resolve api.bilibili.com from tls://120.53.53.53:853"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[DNS] resolve api.bilibili.com from tls://1.12.12.12:853"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[DNS] resolve api.bilibili.com from tls://1.12.12.12:853"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[DNS] resolve api.bilibili.com from tls://120.53.53.53:853"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[DNS] resolve api.bilibili.com from https://223.5.5.5:443/dns-query"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="creating a new http client"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[https://223.5.5.5:443/dns-query] using HTTP/2 for this upstream: <nil>"
time="2024-07-07T15:14:17.7059739Z" level=debug msg="[DNS] resolve api.bilibili.com from https://223.5.5.5:443/dns-query"
time="2024-07-07T15:14:17.7687813Z" level=debug msg="[DNS] api.bilibili.com --> [110.40.30.34 119.84.174.67 110.40.30.33 110.40.30.32 119.84.174.68 119.84.174.66] A from https://223.5.5.5:443/dns-query"
time="2024-07-07T15:14:17.7687813Z" level=debug msg="[DNS] api.bilibili.com --> [240e:bf:b800:4300:1::15 240e:d9:a600:834::12 240e:bf:b800:4300:1::14 240e:930:c200:209::34 240e:bf:b800:4300:1::13 240e:d9:a600:834::14 240e:bf:b800:4300:1::12 240e:d9:a600:834::13] AAAA from https://223.5.5.5:443/dns-query"
time="2024-07-07T15:14:17.775413Z" level=info msg="[TCP] [fdfe:dcba:9876::1]:4891 --> api.bilibili.com:443 match GeoSite(cn) using 🎯 全球直连[DIRECT]"

image

在 openclash 中我也出现了这种情况,我使用 smartdns 设置禁止返回AAAA记录来避免这种情况。