# -------------------------------------------------------------------
# Mihomo (Clash Meta) 极简订阅模板
# 使用方法：搜索 "请在此处填入订阅链接" 并替换
# -------------------------------------------------------------------

# 基础配置
mixed-port: 7890
allow-left-side: true
log-level: info
ipv6: false
external-controller: 127.0.0.1:9090
unified-delay: true
tcp-concurrent: true

# 嗅探配置 (用于识别 HTTPS 流量域名)
sniffer:
  enable: true
  sniff:
    TLS:
      ports: [443, 8443]
    HTTP:
      ports: [80, 8080-8880]
      override-destination: true

# TUN 模式配置 (接管全站流量)
tun:
  enable: true
  stack: system # 或 gvisor
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - "any:53"

# DNS 配置
dns:
  enable: true
  listen: 0.0.0.0:1053
  ipv6: false
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  default-nameserver:
    - 223.5.5.5
    - 119.29.29.29
  nameserver:
    - https://dns.alidns.com/dns-query
    - https://doh.pub/dns-query
  fallback:
    - https://8.8.8.8/dns-query
    - https://1.1.1.1/dns-query
    - tls://8.8.4.4

# 代理集合 (订阅管理)
proxy-providers:
  my_subscription:
    type: http
    # === 请在此处填入你的订阅链接 ===
    url: "你的订阅链接地址"
    interval: 3600
    path: ./proxies/sub1.yaml
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204

# 策略组
proxy-groups:
  # 节点选择
  - name: 🚀 节点选择
    type: select
    proxies:
      - 🏎️ 香港延迟
      - ⚡ 自动选择
      - 🔮 全部节点
      - DIRECT

  # 自动选择延迟最低的节点
  - name: ⚡ 自动选择
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 50
    use:
      - my_subscription

  # 筛选香港节点 (利用正则)
  - name: 🏎️ 香港延迟
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 300
    use:
      - my_subscription
    filter: "(?i)香港|HK|Hong Kong"

  # 流媒体专用
  - name: 🎬 国际媒体
    type: select
    proxies:
      - 🚀 节点选择
      - 🏎️ 香港延迟
      - DIRECT

  # 漏网之鱼
  - name: 🐟 漏网之鱼
    type: select
    proxies:
      - 🚀 节点选择
      - DIRECT

  # 展示所有节点
  - name: 🔮 全部节点
    type: select
    use:
      - my_subscription

# 规则集合 (Rule Providers)
rule-providers:
  ads:
    type: http
    behavior: domain
    url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/category-ads-all.yaml"
    path: ./rules/ads.yaml
    interval: 86400

  google:
    type: http
    behavior: domain
    url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/google.yaml"
    path: ./rules/google.yaml
    interval: 86400

  netflix:
    type: http
    behavior: domain
    url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/netflix.yaml"
    path: ./rules/netflix.yaml
    interval: 86400

  telegram:
    type: http
    behavior: ipcidr
    url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/telegram.yaml"
    path: ./rules/telegram.yaml
    interval: 86400

# 规则 (决定流量去向)
rules:
  - RULE-SET,ads,REJECT
  - RULE-SET,google,🚀 节点选择
  - RULE-SET,netflix,🎬 国际媒体
  - RULE-SET,telegram,🚀 节点选择
  - GEOIP,lan,DIRECT
  - GEOIP,cn,DIRECT
  - MATCH,🐟 漏网之鱼
