MetaCubeX / mihomo

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

[Bug] udp类型的dns无法走hy2代理 #1544

Closed GeorgeRudd closed 1 month ago

GeorgeRudd commented 2 months ago

Verify steps

操作系统

Windows

系统版本

Windows 11 专业版 23H2 22631.4169

Mihomo 版本

Mihomo Meta alpha-2b3bd6e windows amd64 with go1.23.1 Tue Sep 24 13:45:33 UTC 2024 Use tags: with_gvisor

配置文件

port: 7899 # HTTP(S) 代理服务器端口
socks-port: 7898 # SOCKS5 代理端口
mixed-port: 7897 # HTTP(S) 和 SOCKS 代理混合端口
inbound-tfo: true
mode: rule
ipv6: true
log-level: debug
find-process-mode: always
allow-lan: false
geodata-mode: true
tcp-concurrent: true

dns:
  enable: true
  enhanced-mode: fake-ip
  use-hosts: true
  nameserver-policy:
    'rule-set:cn': 
         - system
    'rule-set:private': 
         - system     
    'www.msftconnecttest.com': 
         - system 
  nameserver:
    - '8.8.8.8#节点选择'
  proxy-server-nameserver:
     - system 
  fake-ip-filter:
    - rule-set:fakeip-filter
    - rule-set:cn

rule-providers:
  fakeip-filter:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/fakeip-filter.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: domain
    format: mrs

  ads:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/ads.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: domain
    format: mrs

  private:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/private.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: domain
    format: mrs

  proxy:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/proxy.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: domain
    format: mrs

  cn:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/cn.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: domain
    format: mrs

  privateip:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/privateip.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: ipcidr
    format: mrs

  cnip:
    type: http
    url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/cnip.mrs"
    interval: 86400
    proxy: 节点选择
    behavior: ipcidr
    format: mrs

rules:
  - AND,((NETWORK,UDP),(DST-PORT,443)),REJECT
  - DOMAIN,services.googleapis.cn,节点选择
  - DOMAIN,metacubex.github.io,节点选择
  - RULE-SET,private,direct
  - RULE-SET,cn,direct
  - DOMAIN,www.msftconnecttest.com,direct
  - RULE-SET,proxy,节点选择

  - RULE-SET,privateip,direct
  - RULE-SET,cnip,direct

  - MATCH,REJECT

#http服务路径,可以放静态web网页,如yacd的控制面板,可通过`http://{{external-controller}}/ui`直接使用,添加完后需要右键退出再重启才能生效
external-controller: 127.0.0.1:9097   #控制器监听地址
secret: "123" #控制器登录密码

# interface-name: WLAN

tun:
  enable: true
  stack: system
  dns-hijack:
    - 'any:53'
    - 'tcp://any:53'
  auto-route: true
  auto-detect-interface: true
  strict-route: true 

proxy-groups:

  - name: 节点选择
    type: select
    proxies:  
      - hysteria2

proxies:
   # direct
  - name: "direct"
    type: direct
    udp: true
    tfo: true
    ip-version: ipv4-prefer
    # ip-version: ipv4

  #hysteria2
  - name: "hysteria2"
    type: hysteria2
    server: ip
    # port: 50000
    ports: 10001-11111
    hop-interval: 5
    #  up 和 down 均不写或为 0 则使用 BBR 流控
    # up: "30 Mbps" # 若不写单位,默认为 Mbps
    # down: "200 Mbps" # 若不写单位,默认为 Mbps
    password: 1
    # obfs: salamander # 默认为空,如果填写则开启 obfs,目前仅支持 salamander
    # obfs-password: yourpassword
    sni: sni
    skip-cert-verify: false
    # fingerprint: xxxx
    alpn:
      - h3
    # ca: "./my.ca"
    # ca-str: "xyz"

profile:
  # 存储 select 选择记录
  store-selected: false

  # 持久化 fake-ip
  store-fake-ip: false

描述

vpsgo.com的ip属于cn,应该走direct,如果这样设置

nameserver:
    - '8.8.8.8#节点选择'

提示resolve vpsgo.com error: couldn't find ip,最后走了兜底的规则REJECT

改成这样就正常

nameserver:
    - 'tcp://8.8.8.8#节点选择'

32 | [info] | [TCP] 198.18.0.1:56111(brave.exe) --> www.vpsgo.com:443 match RuleSet(cnip) using direct
31 | [debug] | [DNS] cache hit www.vpsgo.com --> [] AAAA, expire at 2024-09-25 10:31:07
30 | [debug] | [DNS] cache hit www.vpsgo.com --> [101.35.89.75] A, expire at 2024-09-25 10:16:37
29 | [debug] | [DNS] www.vpsgo.com --> 101.35.89.75
28 | [debug] | [DNS] www.vpsgo.com --> [101.35.89.75] A from tcp://8.8.8.8:53
27 | [debug] | [DNS] www.vpsgo.com --> [] AAAA from tcp://8.8.8.8:53
23 | [debug] | [DNS] resolve www.vpsgo.com AAAA from tcp://8.8.8.8:53
22 | [debug] | [DNS] resolve www.vpsgo.com A from tcp://8.8.8.8:53
20 | [info] | [TCP] 198.18.0.1:56109(brave.exe) --> vpsgo.com:443 match RuleSet(cnip) using direct
19 | [debug] | [DNS] cache hit vpsgo.com --> [] AAAA, expire at 2024-09-25 10:41:35
18 | [debug] | [DNS] cache hit vpsgo.com --> [101.35.89.75] A, expire at 2024-09-25 10:16:35
17 | [debug] | [DNS] vpsgo.com --> 101.35.89.75
16 | [debug] | [DNS] vpsgo.com --> [101.35.89.75] A from tcp://8.8.8.8:53
15 | [debug] | [DNS] vpsgo.com --> [] AAAA from tcp://8.8.8.8:53
12 | [debug] | [DNS] resolve vpsgo.com AAAA from tcp://8.8.8.8:53
11 | [debug] | [DNS] resolve vpsgo.com A from tcp://8.8.8.8:53

重现方式

日志

74  [info]  [TCP] 198.18.0.1:52802(brave.exe) --> www.vpsgo.com:443 match RuleSet(cnip) using direct
73  [info]  [TCP] 198.18.0.1:52802(brave.exe) --> www.vpsgo.com:443 match RuleSet(cnip) using direct
72  [debug] [DNS] cache hit www.vpsgo.com --> [101.35.89.75] A, expire at 2024-09-25 10:12:38
71  [debug] [DNS] www.vpsgo.com --> 101.35.89.75
70  [debug] [DNS] www.vpsgo.com --> [101.35.89.75] A from udp://8.8.8.8:53
67  [debug] [DNS] resolve www.vpsgo.com AAAA from udp://8.8.8.8:53
66  [debug] [DNS] resolve www.vpsgo.com A from udp://8.8.8.8:53
64  [info]  [TCP] 198.18.0.1:52800(brave.exe) --> vpsgo.com:80 match RuleSet(cnip) using direct
63  [debug] [DNS] cache hit vpsgo.com --> [] AAAA, expire at 2024-09-25 10:37:28
62  [debug] [DNS] cache hit vpsgo.com --> [101.35.89.75] A, expire at 2024-09-25 10:12:33
61  [debug] [DNS] vpsgo.com --> 101.35.89.75
60  [debug] [DNS] cache hit vpsgo.com --> [] AAAA, expire at 2024-09-25 10:37:28
59  [debug] [DNS] cache hit vpsgo.com --> [101.35.89.75] A, expire at 2024-09-25 10:12:33
54  [debug] [DNS] vpsgo.com --> [101.35.89.75] A from udp://8.8.8.8:53
53  [info]  [TCP] 198.18.0.1:52796(brave.exe) --> vpsgo.com:80 match Match using REJECT
51  [info]  [TCP] 198.18.0.1:52794(brave.exe) --> vpsgo.com:443 match Match using REJECT
50  [debug] [DNS] resolve vpsgo.com A from udp://8.8.8.8:53
49  [debug] [DNS] resolve vpsgo.com error: couldn't find ip
48  [debug] [DNS] resolve vpsgo.com error: couldn't find ip
44  [debug] [DNS] cache hit vpsgo.com --> [] AAAA, expire at 2024-09-25 10:37:28
42  [debug] [DNS] vpsgo.com --> [] AAAA from udp://8.8.8.8:53
38  [debug] [DNS] resolve vpsgo.com A from udp://8.8.8.8:53
36  [info]  [TCP] 198.18.0.1:52781(brave.exe) --> vpsgo.com:443 match Match using REJECT
34  [info]  [TCP] 198.18.0.1:52784(brave.exe) --> vpsgo.com:443 match Match using REJECT
33  [info]  [TCP] 198.18.0.1:52792(brave.exe) --> vpsgo.com:80 match Match using REJECT
32  [debug] [DNS] resolve vpsgo.com AAAA from udp://8.8.8.8:53
31  [debug] [DNS] resolve vpsgo.com error: couldn't find ip
30  [debug] [DNS] resolve vpsgo.com error: couldn't find ip
29  [debug] [DNS] resolve vpsgo.com error: couldn't find ip
3   [debug] [DNS] resolve vpsgo.com AAAA from udp://8.8.8.8:53
2   [debug] [DNS] resolve vpsgo.com A from udp://8.8.8.8:53
xishang0128 commented 1 month ago

测试正常,请确保不是远端阻止了53端口 image image