MetaCubeX / mihomo

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

[Bug] android下内核tun模式与Tailscale不兼容 #1600

Closed yqs112358 closed 1 month ago

yqs112358 commented 1 month ago

Verify steps

操作系统

Android

系统版本

HyperOS1.0.13.0 - Android14

Mihomo 版本

Mihomo Meta alpha-8fb0d48 android arm64 with go1.23.2 Sat Oct 19 05:01:17 UTC 2024 Use tags: with_gvisor

配置文件

mixed-port: 7890
allow-lan: false
bind-address: "*"
ipv6: false
mode: rule
log-level: debug
global-client-fingerprint: chrome
find-process-mode: always
keep-alive-interval: 360

external-controller: 127.0.0.1:9090
external-ui: ui

profile:
  store-selected: true
  store-fake-ip: true

dns:
  enable: true
  use-hosts: true
  use-system-hosts: true
  listen: 0.0.0.0:1053
  ipv6: false

  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.0/16
  fake-ip-filter:
    # mDNS
    - "*.lan"
    - "*.local"

  default-nameserver:
    - "223.5.5.5"
  proxy-server-nameserver:
    - "https://223.5.5.5/dns-query"
    - "https://1.12.12.12/dns-query"
  nameserver:
    - "223.5.5.5"
    - "180.76.76.76"
    - "119.29.29.29"
  fallback:
    - "tls://1.1.1.1#Proxy"
    - "tls://8.8.8.8#Proxy"
  fallback-filter:
    geoip: true
    geoip-code: CN
    ipcidr:
      - 240.0.0.0/4

tun:
  enable: true
  stack: system
  device: tun9
  dns-hijack:
    - "0.0.0.0:53"
    - "tcp://0.0.0.0:53"
  auto-detect-interface: true
  strict-route: true
  gso: true
  auto-route: true
  route-exclude-address:
    - "100.64.0.0/10"

# 机场订阅
proxy-providers:
  airport_air:
    type: http
    url: 机场订阅链接
    path: ./airport.yaml
    interval: 86400
    health-check:
      enable: false
      interval: 600
      url: https://www.gstatic.com/generate_204

proxy-groups:
  - name: Proxy
    type: select
    proxies:
      - "airport"
      - Direct

  - name: airport
    type: select
    use:
      - airport_air
    proxies:
      - Direct

  - name: "🛑 广告拦截"
    type: select
    proxies:
      - REJECT
      - Proxy
      - Direct

  - name: Direct
    type: select
    proxies:
      - DIRECT

  - name: "🐟 漏网之鱼"
    type: select
    proxies:
      - Proxy
      - Direct

rules:
  - PROCESS-NAME,mihomo.exe,REJECT
  - PROCESS-NAME,mihomo,REJECT

  # Private and LAN
  - GEOIP,private,DIRECT,no-resolve
  - GEOSITE,private,DIRECT,no-resolve
  - DOMAIN-SUFFIX,msftconnecttest.com,DIRECT,no-resolve

  # Tailscale
  - IP-CIDR,100.64.0.0/10,DIRECT,no-resolve

  # Anti AD
  - GEOSITE,category-ads-all,🛑 广告拦截

  # CN
  - GEOSITE,cn,Direct

  # PROXY
  - GEOSITE,google,Proxy
  - GEOIP,telegram,Proxy,no-resolve
  - GEOSITE,telegram,Proxy
  - GEOSITE,openai,Proxy
  - GEOSITE,onedrive,Proxy
  - GEOSITE,microsoft@cn,Direct
  - GEOSITE,microsoft,Proxy
  - GEOSITE,steam@cn,Direct
  - GEOSITE,steam,Proxy
  - GEOSITE,category-games@cn,Direct
  - GEOSITE,category-games,Proxy
  - GEOSITE,biliintl,Proxy
  - GEOSITE,f-droid,Proxy
  - GEOSITE,cloudflare,Proxy
  - GEOSITE,category-social-media-!cn,Proxy
  - GEOSITE,category-entertainment,Proxy
  - GEOSITE,category-communication,Proxy
  - GEOSITE,category-scholar-!cn,Proxy
  - GEOSITE,category-orgs,Proxy
  - GEOSITE,category-porn,Proxy
  - GEOSITE,category-android-app-download,Proxy
  - GEOSITE,category-forums,Proxy
  - GEOSITE,category-anticensorship,Proxy
  - GEOSITE,category-dev,Proxy
  - GEOSITE,gfw,Proxy

  - GEOIP,telegram,Proxy
  - GEOIP,CN,Direct

  - MATCH,🐟 漏网之鱼

描述

mihomo在安卓上直接用tun模式跑内核时,似乎与Tailscale App不兼容。Tailscale服务启动之后,所有需要代理的网站都无法访问,表现为无限加载,最后报错net::ERR_CONNECTION_TIMED_OUT。 只要停掉Tailscale App,网站访问就会立刻恢复正常。

尝试过设置tun: exclude-interface: tun0,或强制指定interface-name: wlan0,均无效

已经调试过Tailscale APP源码,其中addRouter使用的网段是100.64.0.0/10,且并未使用builder.addDnsServer添加自定义DNS服务器,理论上不应该与mihomo发生冲突

重现方式

  1. 用模块启动mihomo内核,使用tun模式
  2. 启动Tailscale APP并连接
  3. 打开浏览器访问www.google.com
  4. 无法访问

日志

time="2024-10-19T21:15:13.790226009+08:00" level=info msg="Start initial configuration in progress"
time="2024-10-19T21:15:13.790715801+08:00" level=info msg="Geodata Loader mode: memconservative"
time="2024-10-19T21:15:13.790768353+08:00" level=info msg="Geosite Matcher implementation: succinct"
time="2024-10-19T21:15:13.791201895+08:00" level=info msg="Load GeoSite rule: cn"
time="2024-10-19T21:15:14.163034707+08:00" level=info msg="Load GeoSite rule: private"
time="2024-10-19T21:15:14.169680697+08:00" level=info msg="Finished initial GeoSite rule private => DIRECT, records: 131"
time="2024-10-19T21:15:14.169891322+08:00" level=info msg="Load GeoSite rule: category-ads-all"
time="2024-10-19T21:15:14.179043457+08:00" level=info msg="Finished initial GeoSite rule category-ads-all => 🛑 广告拦截, records: 753"
time="2024-10-19T21:15:14.179242519+08:00" level=info msg="Finished initial GeoSite rule cn => Direct, records: 92276"
time="2024-10-19T21:15:14.179307624+08:00" level=info msg="Load GeoSite rule: google"
time="2024-10-19T21:15:14.199873769+08:00" level=info msg="Finished initial GeoSite rule google => Proxy, records: 1135"
time="2024-10-19T21:15:14.200286738+08:00" level=info msg="Load GeoSite rule: telegram"
time="2024-10-19T21:15:14.208102259+08:00" level=info msg="Finished initial GeoSite rule telegram => Proxy, records: 19"
time="2024-10-19T21:15:14.208372207+08:00" level=info msg="Load GeoSite rule: openai"
time="2024-10-19T21:15:14.220693821+08:00" level=info msg="Finished initial GeoSite rule openai => Proxy, records: 13"
time="2024-10-19T21:15:14.220933874+08:00" level=info msg="Load GeoSite rule: onedrive"
time="2024-10-19T21:15:14.230006217+08:00" level=info msg="Finished initial GeoSite rule onedrive => Proxy, records: 18"
time="2024-10-19T21:15:14.230246374+08:00" level=info msg="Load GeoSite rule: microsoft@cn"
time="2024-10-19T21:15:14.240654342+08:00" level=info msg="Finished initial GeoSite rule microsoft@cn => Direct, records: 144"
time="2024-10-19T21:15:14.240969499+08:00" level=info msg="Load GeoSite rule: microsoft"
time="2024-10-19T21:15:14.243222103+08:00" level=info msg="Finished initial GeoSite rule microsoft => Proxy, records: 632"
time="2024-10-19T21:15:14.243378769+08:00" level=info msg="Load GeoSite rule: steam@cn"
time="2024-10-19T21:15:14.255404238+08:00" level=info msg="Finished initial GeoSite rule steam@cn => Direct, records: 16"
time="2024-10-19T21:15:14.255675696+08:00" level=info msg="Load GeoSite rule: steam"
time="2024-10-19T21:15:14.255948249+08:00" level=info msg="Finished initial GeoSite rule steam => Proxy, records: 48"
time="2024-10-19T21:15:14.256042728+08:00" level=info msg="Load GeoSite rule: category-games@cn"
time="2024-10-19T21:15:14.268837571+08:00" level=info msg="Finished initial GeoSite rule category-games@cn => Direct, records: 154"
time="2024-10-19T21:15:14.269173561+08:00" level=info msg="Load GeoSite rule: category-games"
time="2024-10-19T21:15:14.271462884+08:00" level=info msg="Finished initial GeoSite rule category-games => Proxy, records: 696"
time="2024-10-19T21:15:14.27160179+08:00" level=info msg="Load GeoSite rule: biliintl"
time="2024-10-19T21:15:14.277446478+08:00" level=info msg="Finished initial GeoSite rule biliintl => Proxy, records: 11"
time="2024-10-19T21:15:14.277668561+08:00" level=info msg="Load GeoSite rule: f-droid"
time="2024-10-19T21:15:14.287275332+08:00" level=info msg="Finished initial GeoSite rule f-droid => Proxy, records: 4"
time="2024-10-19T21:15:14.287525957+08:00" level=info msg="Load GeoSite rule: cloudflare"
time="2024-10-19T21:15:14.301091426+08:00" level=info msg="Finished initial GeoSite rule cloudflare => Proxy, records: 55"
time="2024-10-19T21:15:14.301445488+08:00" level=info msg="Load GeoSite rule: category-social-media-!cn"
time="2024-10-19T21:15:14.310573301+08:00" level=info msg="Finished initial GeoSite rule category-social-media-!cn => Proxy, records: 528"
time="2024-10-19T21:15:14.310851634+08:00" level=info msg="Load GeoSite rule: category-entertainment"
time="2024-10-19T21:15:14.321534811+08:00" level=info msg="Finished initial GeoSite rule category-entertainment => Proxy, records: 1515"
time="2024-10-19T21:15:14.321763301+08:00" level=info msg="Load GeoSite rule: category-communication"
time="2024-10-19T21:15:14.330713144+08:00" level=info msg="Finished initial GeoSite rule category-communication => Proxy, records: 115"
time="2024-10-19T21:15:14.331009186+08:00" level=info msg="Load GeoSite rule: category-scholar-!cn"
time="2024-10-19T21:15:14.339259446+08:00" level=info msg="Finished initial GeoSite rule category-scholar-!cn => Proxy, records: 424"
time="2024-10-19T21:15:14.339490384+08:00" level=info msg="Load GeoSite rule: category-orgs"
time="2024-10-19T21:15:14.348476061+08:00" level=info msg="Finished initial GeoSite rule category-orgs => Proxy, records: 112"
time="2024-10-19T21:15:14.348678353+08:00" level=info msg="Load GeoSite rule: category-porn"
time="2024-10-19T21:15:14.373985384+08:00" level=info msg="Finished initial GeoSite rule category-porn => Proxy, records: 6445"
time="2024-10-19T21:15:14.374227363+08:00" level=info msg="Load GeoSite rule: category-android-app-download"
time="2024-10-19T21:15:14.385701634+08:00" level=info msg="Finished initial GeoSite rule category-android-app-download => Proxy, records: 7"
time="2024-10-19T21:15:14.385844655+08:00" level=info msg="Load GeoSite rule: category-forums"
time="2024-10-19T21:15:14.394653353+08:00" level=info msg="Finished initial GeoSite rule category-forums => Proxy, records: 71"
time="2024-10-19T21:15:14.394756374+08:00" level=info msg="Load GeoSite rule: category-anticensorship"
time="2024-10-19T21:15:14.399519499+08:00" level=info msg="Finished initial GeoSite rule category-anticensorship => Proxy, records: 87"
time="2024-10-19T21:15:14.399637363+08:00" level=info msg="Load GeoSite rule: category-dev"
time="2024-10-19T21:15:14.40878653+08:00" level=info msg="Finished initial GeoSite rule category-dev => Proxy, records: 498"
time="2024-10-19T21:15:14.409178405+08:00" level=info msg="Load GeoSite rule: gfw"
time="2024-10-19T21:15:14.443346009+08:00" level=info msg="Finished initial GeoSite rule gfw => Proxy, records: 6116"
time="2024-10-19T21:15:14.444016634+08:00" level=info msg="Initial configuration complete, total time: 653ms"
time="2024-10-19T21:15:14.44772179+08:00" level=info msg="RESTful API listening at: 127.0.0.1:9090"
time="2024-10-19T21:15:14.516322832+08:00" level=info msg="Sniffer is closed"
time="2024-10-19T21:15:14.517386946+08:00" level=info msg="DNS server listening at: [::]:1053"
time="2024-10-19T21:15:14.517731373+08:00" level=info msg="Mixed(http+socks) proxy listening at: 127.0.0.1:7890"
time="2024-10-19T21:15:14.519629238+08:00" level=warning msg="[TUN] default interface changed by monitor,  => tun0"
time="2024-10-19T21:15:14.585467832+08:00" level=info msg="[TUN] Tun adapter listening at: tun9([198.18.0.0/30],[]), mtu: 9000, auto route: true, auto redir: false, ip stack: System"
time="2024-10-19T21:15:14.585741738+08:00" level=debug msg="batch write packet: invalid offset"
time="2024-10-19T21:15:14.585801321+08:00" level=info msg="Start initial provider airport_air"
time="2024-10-19T21:15:14.67553278+08:00" level=info msg="Start initial Compatible provider Direct"
time="2024-10-19T21:15:14.675637571+08:00" level=info msg="Start initial Compatible provider airport"
time="2024-10-19T21:15:14.675715748+08:00" level=info msg="Start initial Compatible provider Proxy"
time="2024-10-19T21:15:14.675736686+08:00" level=info msg="Start initial Compatible provider 🐟 漏网之鱼"
time="2024-10-19T21:15:14.67576528+08:00" level=info msg="Start initial Compatible provider 🛑 广告拦截"
time="2024-10-19T21:15:14.675780071+08:00" level=info msg="Start initial Compatible provider default"
time="2024-10-19T21:15:14.675954134+08:00" level=info msg="UI already exists, skip downloading"
time="2024-10-19T21:15:15.69302554+08:00" level=debug msg="[DNS] hijack udp:112.4.1.36:53 from 198.18.0.0:28190"
time="2024-10-19T21:15:25.711437515+08:00" level=debug msg="[DNS] hijack udp:112.4.1.36:53 from 198.18.0.0:36545"
time="2024-10-19T21:15:35.781285949+08:00" level=debug msg="[DNS] hijack udp:112.4.1.36:53 from 198.18.0.0:35769"
time="2024-10-19T21:15:56.082334899+08:00" level=warning msg="Mihomo shutting down"
yqs112358 commented 1 month ago

用termux测试的时候观察到一个现象,启动Tailscale后,fake-ip似乎会因为未知原因失效

启动前: image

启动后:curl拿到了真实的google服务器IP地址,而不是fake-ip,并且无法连接到服务器 image

后面有尝试过换用redir-host和nameserver-policy指定geosite:google使用tls://8.8.8.8#Proxy解析,仍然是无法连接

xishang0128 commented 1 month ago

https://github.com/MetaCubeX/mihomo/issues/1571#issuecomment-2397947492

yqs112358 commented 1 month ago

6😄