# Clash Meta for Android 完整配置
# 适用于：Clash Meta for Android (CMFA) / Clash.Meta / Flora

port: 7890
socks-port: 7891
redir-port: 7892
allow-lan: false
mode: Rule
log-level: info
external-controller: 127.0.0.1:9090

# =====================
# 代理节点
# =====================
proxies:
  - name: "HK-Hysteria2"
    type: hysteria2
    server: hk.sercypress.cn
    port: 8443
    password: xQ4Zhj4FMghsIGHi1b8EOfxj
    sni: hk.sercypress.cn
    skip-cert-verify: false

# =====================
# 代理组
# =====================
proxy-groups:
  # 手动选择出口
  - name: "🚀 代理出口"
    type: select
    proxies:
      - HK-Hysteria2
      - "♻️ 自动选择"
      - DIRECT

  # 自动测速选择最快的
  - name: "♻️ 自动选择"
    type: url-test
    proxies:
      - HK-Hysteria2
    url: "https://www.gstatic.com/generate_204"
    interval: 300

  # 国外流媒体
  - name: "🎬 国外媒体"
    type: select
    proxies:
      - HK-Hysteria2
      - "🚀 代理出口"
      - DIRECT

  # Apple 服务
  - name: "🍎 Apple"
    type: select
    proxies:
      - HK-Hysteria2
      - "🚀 代理出口"
      - DIRECT

  # Google 服务
  - name: "📱 Google"
    type: select
    proxies:
      - HK-Hysteria2
      - "🚀 代理出口"
      - DIRECT

  # 国内流量
  - name: "🇨🇳 国内流量"
    type: select
    proxies:
      - DIRECT
      - HK-Hysteria2
      - "🚀 代理出口"

# =====================
# 规则集（自动更新）
# =====================
rule-providers:
  reject:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt"
    path: ./ruleset/reject.yaml
    interval: 86400

  icloud:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt"
    path: ./ruleset/icloud.yaml
    interval: 86400

  apple:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt"
    path: ./ruleset/apple.yaml
    interval: 86400

  google:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt"
    path: ./ruleset/google.yaml
    interval: 86400

  proxy:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt"
    path: ./ruleset/proxy.yaml
    interval: 86400

  direct:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt"
    path: ./ruleset/direct.yaml
    interval: 86400

  private:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/private.txt"
    path: ./ruleset/private.yaml
    interval: 86400

  gfw:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/gfw.txt"
    path: ./ruleset/gfw.yaml
    interval: 86400

  greatfire:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/greatfire.txt"
    path: ./ruleset/greatfire.yaml
    interval: 86400

  tld-not-cn:
    type: http
    behavior: domain
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/tld-not-cn.txt"
    path: ./ruleset/tld-not-cn.yaml
    interval: 86400

  telegramcidr:
    type: http
    behavior: ipcidr
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt"
    path: ./ruleset/telegramcidr.yaml
    interval: 86400

  cncidr:
    type: http
    behavior: ipcidr
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt"
    path: ./ruleset/cncidr.yaml
    interval: 86400

  lancidr:
    type: http
    behavior: ipcidr
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt"
    path: ./ruleset/lancidr.yaml
    interval: 86400

  applications:
    type: http
    behavior: classical
    url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/applications.txt"
    path: ./ruleset/applications.yaml
    interval: 86400

# =====================
# 规则匹配（从上到下，匹配即停）
# =====================
rules:
  # 广告/诈骗/恶意网站 — 直接拒绝
  - RULE-SET,reject,REJECT

  # 私有 IP / 局域网
  - RULE-SET,lancidr,DIRECT
  - RULE-SET,private,DIRECT

  # BitTorrent 等 P2P 下载 — 直连（不走代理浪费流量）
  - RULE-SET,applications,DIRECT

  # Apple 服务（iCloud 走直连，其他 Apple 可选）
  - RULE-SET,icloud,DIRECT
  - RULE-SET,apple,🍎 Apple

  # Google 服务
  - RULE-SET,google,📱 Google

  # Telegram — 走代理（IP CIDR 匹配）
  - RULE-SET,telegramcidr,🚀 代理出口

  # GFW 名单 / 被墙域名 — 走代理
  - RULE-SET,gfw,🚀 代理出口
  - RULE-SET,greatfire,🚀 代理出口
  - RULE-SET,proxy,🚀 代理出口

  # 常见国外顶级域名（.com/.org/.net 等非 .cn 域名）
  - RULE-SET,tld-not-cn,🚀 代理出口

  # 国内域名 — 直连
  - RULE-SET,direct,DIRECT

  # 中国 IP — 直连
  - GEOIP,CN,DIRECT

  # 兜底：未匹配的流量走代理
  - MATCH,🚀 代理出口
