MetaCubeX / mihomo

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

处理国内IP地址出现奇怪的IP间隔 #1158

Closed SnowCore8 closed 7 months ago

SnowCore8 commented 7 months ago

Verify steps

Mihomo version

1.18.3

What OS are you seeing the problem on?

Linux

Mihomo config

global-ua: clash.meta # 自定义外部资源下载时使用的的UA,默认为 clash.meta
# port: 7890 # HTTP(S) 代理服务器端口
# socks-port: 7891 # SOCKS5 代理端口
mixed-port: 7890 # HTTP(S) 和 SOCKS 代理混合端口
# redir-port: 7892 # 透明代理端口,用于 Linux 和 MacOS
# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP)
# tproxy-port: 7893
allow-lan: true # 允许局域网连接
bind-address: "*" # 绑定 IP 地址,仅作用于 allow-lan 为 true,"*"表示所有地址
#  find-process-mode has 3 values:always, strict, off
#  - always, 开启,强制匹配所有进程
#  - strict, 默认,由 mihomo 判断是否开启
#  - off, 不匹配进程,推荐在路由器上使用此模式
find-process-mode: strict
mode: rule
# 全局 TLS 指纹,优先低于 proxy 内的 client-fingerprint
# 可选: "chrome","firefox","safari","ios","random","none" options.
# Utls is currently support TLS transport in TCP/grpc/WS/HTTP for VLESS/Vmess and trojan.
global-client-fingerprint: chrome
log-level: debug # 日志等级 silent/error/warning/info/debug
ipv6: false # 开启 IPv6 总开关,关闭阻断所有 IPv6 链接和屏蔽 DNS 请求 AAAA 记录
external-controller: ":980" # HTTP API 监听地址
external-controller-tls: ":9443" # HTTPS API 监听地址
tls:
  certificate: "key/server.crt" # 证书 PEM 格式,或者 证书的路径
  private-key: "key/server.key" # 证书对应的私钥 PEM 格式,或者私钥路径
# secret: "123456" # `Authorization:Bearer ${secret}`
geodata-mode: true # 更改geoip使用文件,mmdb或者dat,可选 true/false,true为dat,此项有默认值 false
geodata-loader: standard # standard:标准加载器,memconservative:专为内存受限(小内存)设备优化的加载器(默认值)
geo-auto-update: true # 是否自动更新 geodata
geo-update-interval: 1 # 更新间隔,单位:小时
# 自定义 geodata url
geox-url:
  geoip: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat"
  geosite: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat"
  mmdb: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb"
tcp-concurrent: false # TCP 并发连接所有 IP, 将使用最快握手的 TCP
unified-delay: false # 更换延迟计算方式,去除握手等额外延迟,可选值 true/false
# 配置 WEB UI 目录,使用 http://{{external-controller}}/ui 访问
external-ui: ui/yacd-meta
external-ui-url: "https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip"
# external-ui-url: "https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip"
# interface-name: wlan0 # 设置出口网卡
keep-alive-interval: 3 # TCP 检测链接失效间隔秒
routing-mark: 6666 # 配置 fwmark 仅用于 Linux
# 类似于 /etc/hosts, 仅支持配置单个 IP
hosts:
  "localhost": 127.0.0.1
profile:
  # 存储 select 选择记录
  store-selected: true
  # 持久化 fake-ip
  store-fake-ip: false
#################################################
ntp:
  enable: false
  write-to-system: true
  server: ntp.aliyun.com
  port: 123
  interval: 30
#################################################
dns:
  cache-algorithm: arc
  enable: true # 关闭将使用系统 DNS
  prefer-h3: true # 可选值 true/false,是否开启 DOH 的 http/3
  use-hosts: true # 查询 hosts
  listen: ":520" # 开启 DNS 服务器监听
  ipv6: false # true 将返回 AAAA 的空结果
  ipv6-timeout: 300 # 单位:ms,内部双栈并发时,向上游查询 AAAA 时,等待 AAAA 的时间
  enhanced-mode: fake-ip # fake-ip or redir-host
  # fake-ip-range: "192.0.0.1/8" # fake-ip 池设置
  # 配置不使用fake-ip的域名
  fake-ip-filter:
    - "*"
    - "+.lan"
    - "+.local"
  # 用于解析 nameserver,fallback 以及其他DNS服务器配置的,DNS 服务域名
  # 不能使用域名地址,可使用加密 DNS
  default-nameserver:
    - tls://223.5.5.5 # 阿里 DNS
    # - tls://1.12.12.12 # 腾讯 DNS
    # - system # 从系统配置中附加 DNS 服务器。如果没有找到,它将打印错误日志并跳过。
  # DNS主要域名配置
  # 支持 UDP,TCP,DoT,DoH,DoQ
  # 这部分为主要 DNS 配置,影响所有直连,确保使用对国内解析精准的 DNS
  nameserver:
    # - tls://223.5.5.5 # 阿里 DNS
    # - tls://1.12.12.12 # 腾讯 DNS
    - https://223.5.5.5/dns-query # 阿里 DNS
    # - https://1.12.12.12/dns-query # 腾讯 DNS
    # - "https://1.12.12.12/dns-query#h3=true" # 强制开启 DOH 的 http/3
  # 专用于节点域名解析的 DNS 服务器,非必要配置项
  # 配置服务器若查询失败将使用 nameserver,非并发查询
  # proxy-server-nameserver:
    # - https://223.5.5.5/dns-query # 阿里 DNS
  # 配置查询域名使用的 DNS 服务器
  nameserver-policy:
    "rule-set:private_domain":
      - https://223.5.5.5/dns-query # 阿里 DNS
    "geosite:cn,private":
      - https://223.5.5.5/dns-query # 阿里 DNS
    # "geosite:geolocation-!cn":
      # - https://1.0.0.1/dns-query # Cloudflare DNS
  fallback: # 后备域名解析服务器,一般情况下使用境外 DNS, 保证结果可信,配置 fallback后默认启用 fallback-filter,geoip-code为 cn
    # - tls://8.8.8.8 # 谷歌 DNS
    # - tls://1.1.1.1 # Cloudflare DNS
    # - tls://9.140.14.14 # Adguard DNS
    # - https://8.8.8.8/dns-query # 谷歌 DNS
    # - https://1.1.1.1/dns-query # Cloudflare DNS
    - https://9.140.14.14/dns-query # Adguard DNS
  # fallback-filter: # 后备域名解析服务器筛选,满足条件的将使用 fallback结果或只使用 fallback解析
    # geoip: true # 可选值为 true/false,是否启用 fallback filter
    # geoip-code: CN # 可选值为 国家缩写,默认值为 CN,除了 geoip-code 配置的国家 IP, 其他的 IP 结果会被视为污染,geoip-code 配置的国家的结果会直接采用,否则将采用 fallback结果
    # geosite: # 配置强制 fallback,优先于 IP 判断,具体分类自行查看 geosite 库
      # - gfw
    # ipcidr: # 书写内容为 IP/掩码,这些网段的结果会被视为污染,nameserver解析出这些结果时将会采用 fallback的解析结果
      # - 240.0.0.0/4
    # domain: # 这些域名被视为已污染,匹配到这些域名,会直接使用 fallback解析,不去使用 nameserver
      # - "+.google.com"
      # - "+.facebook.com"
      # - "+.youtube.com"
#################################################
sniffer:
  enable: true
  # 对 redir-host 类型识别的流量进行强制嗅探
  # 如:Tun、Redir 和 TProxy 并 DNS 为 redir-host 皆属于
  force-dns-mapping: true
  # 对所有未获取到域名的流量进行强制嗅探
  parse-pure-ip: true
  # 是否使用嗅探结果作为实际访问,默认 true
  # 全局配置,优先级低于 sniffer.sniff 实际配置
  override-destination: false
  sniff: # TLS 和 QUIC 默认如果不配置 ports 默认嗅探 443
    QUIC:
      ports: [443, 8443]
    TLS:
      ports: [443, 8443]
    HTTP: # 需要嗅探的端口
      ports: [80, 443, 8000-9000]
      # 全局配置,优先级低高于 sniffer 实际配置
      override-destination: true
  force-domain: # 需要强制嗅探的域名(默认情况下只对IP进行嗅探)
    # - "+" # 强制全局嗅探"
    - "+.v2ex.com"
  # 对嗅探结果进行跳过
  skip-domain:
    - "+.apple.com" # 苹果站点
    - "Mijia Cloud" # 米家sni
#################################################
tun:
  enable: true
  device: utun0
  mtu: 1500 # 最大传输单元
  stack: system # gvisor/system/mixed
  dns-hijack:
    - any:53 # 需要劫持的 DNS
    - tcp://any:53
    - udp://any:53
  auto-route: true # 配置路由表
  auto-detect-interface: true # 自动识别出口网卡
  strict-route: true # 将所有连接路由到tun来防止泄漏,但你的设备将无法其他设备被访问
  inet4-route-address: # 启用自定义路由而不是默认路由 需要开启 auto-route
    - "0.0.0.0/1"
    - "128.0.0.0/1"
  inet6-route-address: # 启用自定义路由而不是默认路由 需要开启 auto-route
    - "::/1"
    - "8000::/1"
  udp-timeout: 300 # UDP NAT过期时间,以秒为单位,默认300(5分钟)
  endpoint-independent-nat: false # 启用独立于端点的NAT
#################################################

######### 锚点 start #######
#这里是订阅更新和延迟测试相关的
p: &p {type: http, interval: 86400, health-check: {enable: true, url: "https://www.gstatic.com/generate_204", interval: 300, tolerance: 10}}
# 策略组相关
pr: &pr {type: select, proxies: [🚀节点选择, 🛡直连, 🇭🇰香港🤖自动选择, 🇨🇳台湾🤖自动选择, 🇯🇵日本🤖自动选择, 🇸🇬新加坡🤖自动选择, 🇺🇸美国🤖自动选择, ❓其它地区🤖自动选择]}
######### 锚点 end #######
# url 里填写自己的订阅,名称不能重复
proxy-providers:
  iKuuu: {<<: *p, url: ""}
  空气糖果🍬: {<<: *p, url: ""}
proxies:
  - {name: 🛡直连, type: direct, udp: true, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Direct.png"}
  - {name: ❌拦截, type: reject, udp: false, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Reject.png"}
proxy-groups:
  - {name: 🚀节点选择, type: select, proxies: [🤖自动选择, 🛡直连, 🇭🇰香港🤖自动选择, 🇨🇳台湾🤖自动选择, 🇯🇵日本🤖自动选择, 🇸🇬新加坡🤖自动选择, 🇺🇸美国🤖自动选择, ❓其它地区🤖自动选择, ⭕全部节点], icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Proxy.png"}
  - {name: 🇨🇳国内, type: select, proxies: [🛡直连, 🚀节点选择], icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/China_Map.png"}
  - {name: ⚠未知, type: select, proxies: [🛡直连, 🚀节点选择], icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Final.png"}
  - {name: 🤖自动选择, type: url-test, proxies: [🇭🇰香港🤖自动选择, 🇨🇳台湾🤖自动选择, 🇯🇵日本🤖自动选择, 🇸🇬新加坡🤖自动选择, 🇺🇸美国🤖自动选择, ❓其它地区🤖自动选择], icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Auto.png"}
  #分隔,下面是策略组选择
  - {name: Google, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Google.png"}
  - {name: Telegram, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Telegram.png"}
  - {name: Twitter, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Twitter.png"}
  - {name: ehentai, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Panda.png"}
  - {name: 哔哩哔哩, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/bilibili.png"}
  - {name: 哔哩东南亚, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/bilibili.png"}
  - {name: 巴哈姆特, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Bahamut.png"}
  - {name: YouTube, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/YouTube.png"}
  - {name: NETFLIX, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Netflix.png"}
  - {name: Spotify, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Spotify.png"}
  - {name: Pixiv, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Pixiv.png"}
  - {name: Github, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Github.png"}
  - {name: OpenAI, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Github.png"}
  - {name: TikTok, <<: *pr, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Github.png"}
  #分隔,下面是自动选择
  - {name: 🇭🇰香港🤖自动选择, type: url-test, include-all-providers: true, filter: "(?i)港|hk|hongkong|hong kong", icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/HK.png"}
  - {name: 🇨🇳台湾🤖自动选择, type: url-test, include-all-providers: true, filter: "(?i)台|tw|taiwan", icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/TW.png"}
  - {name: 🇯🇵日本🤖自动选择, type: url-test, include-all-providers: true, filter: "(?i)日|jp|japan", icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/JP.png"}
  - {name: 🇺🇸美国🤖自动选择, type: url-test, include-all-providers: true, filter: "(?i)美|us|unitedstates|united states", icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/US.png"}
  - {name: 🇸🇬新加坡🤖自动选择, type: url-test, include-all-providers: true, filter: "(?i)(新|sg|singapore)", icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/SG.png"}
  - {name: ❓其它地区🤖自动选择, type: url-test, include-all-providers: true, filter: "(?i)^(?!.*(?:🇭🇰|🇯🇵|🇺🇸|🇸🇬|🇨🇳|港|hk|hongkong|台|tw|taiwan|日|jp|japan|新|sg|singapore|美|us|unitedstates)).*", icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Available.png"}
  #分隔,统计所有节点
  - {name: ⭕全部节点, type: select, include-all-providers: true, icon: "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/mini/Global.png"}
rules: # 规则表 (纯IP规则可使用no-resolve)
  # 自定义规则集
  - DOMAIN,zf1sy.no-mad-world.club,🚀节点选择
  - DOMAIN,lucynakushinada.de,🚀节点选择
  - RULE-SET,applications,🇨🇳国内
  # - RULE-SET,direct_domain,🇨🇳国内
  # - RULE-SET,reject_domain,❌拦截
  - RULE-SET,lan_ip,🇨🇳国内,no-resolve
  # GeoSite.dat 域名规则
  - GEOSITE,private,🇨🇳国内
  - GEOSITE,microsoft@cn,🇨🇳国内
  - GEOSITE,apple-cn,🇨🇳国内
  - GEOSITE,steam@cn,🇨🇳国内
  - GEOSITE,tiktok,TikTok
  - GEOSITE,biliintl,哔哩东南亚
  - GEOSITE,ehentai,ehentai
  - GEOSITE,github,Github
  - GEOSITE,twitter,Twitter
  - GEOSITE,youtube,YouTube
  - GEOSITE,google,Google
  - GEOSITE,telegram,Telegram
  - GEOSITE,netflix,NETFLIX
  - GEOSITE,bilibili,哔哩哔哩
  - GEOSITE,bahamut,巴哈姆特
  - GEOSITE,spotify,Spotify
  - GEOSITE,pixiv,Pixiv
  - GEOSITE,openai,OpenAI
  - GEOSITE,CN,🇨🇳国内
  - GEOSITE,geolocation-!cn,🚀节点选择
  # GeoIP.dat IP规则
  - GEOIP,LAN,🇨🇳国内,no-resolve
  - GEOIP,private,🇨🇳国内
  - GEOIP,google,Google
  - GEOIP,netflix,NETFLIX
  - GEOIP,telegram,Telegram
  - GEOIP,twitter,Twitter
  - GEOIP,CN,🇨🇳国内
  # 未命中规则
  - MATCH,⚠未知

rule-anchor:
  classical: &classical {type: http, interval: 86400, behavior: classical, format: yaml} # 进程识别
  domain: &domain {type: http, interval: 86400, behavior: domain, format: yaml} # 域名识别
  ipcidir: &ipcidir {type: http, interval: 86400, behavior: ipcidr, format: yaml} # IP识别
rule-providers: 
  applications: {<<: *classical, url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/applications.txt"}
  private_domain: {<<: *domain, url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/private.yaml"}
  direct_domain: {<<: *domain, url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt"}
  reject_domain: {<<: *domain, url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt"}
  lan_ip: {<<: *ipcidir, url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt"}

Mihomo log

[TCP] dial 🇨🇳国内 (match GeoIP/cn) 192.168.100.7:50585 --> 183.209.  85.243:7680 error: connect failed: dial tcp 183.209.85.243:7680: connect: connection refused
WARN[2024-04-02T08:30:02.199718655Z] [TCP] dial 🇨🇳国内 (match GeoIP/cn) 192.168.100.7:50571 --> 120.209.  223.65:7680 error: connect failed: dial tcp 120.209.223.65:7680: i/o timeout

Description

我不清楚这是否是核心处理ip地址的时候多塞了几个空格还是什么问题,因为在网上查不到相关的问题,麻烦看一下这是否是我的配置有误

SnowCore8 commented 7 months ago

这是我的软路由配置 image

xishang0128 commented 7 months ago

贴出log的上下文,仅一条日志不足以判断

SnowCore8 commented 7 months ago

贴出log的上下文,仅一条日志不足以判断

问题找到了,是win控制台和对应putty的输出有问题,在linux上面输出的log没有发现异常空格