# ================= 通用与 DNS 设置 =================
log-level: debug
mode: rule
ipv6: true
mixed-port: 7890
allow-lan: true
bind-address: "*"
lan-allowed-ips:
  - 0.0.0.0/0
  - ::/0
find-process-mode: strict
external-controller: 0.0.0.0:9090

geox-url:
  geoip: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat"
  geosite: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat"
  mmdb: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.metadb"
geo-auto-update: true
geo-update-interval: 24

external-controller-cors:
  allow-private-network: true

global-client-fingerprint: chrome

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

sniffer:
  enable: true
  override-destination: false
  sniff:
    QUIC:
      ports: [ 443 ]
    TLS:
      ports: [ 443 ]
    HTTP:
      ports: [80]

dns:
  enable: true
  prefer-h3: false
  listen: 0.0.0.0:1053
  ipv6: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:
    - '*.lan'
    - '*.local'
    - 'dns.google'
    - "localhost.ptlogin2.qq.com"
  use-hosts: true
  nameserver:
    - https://1.1.1.1/dns-query
    - https://8.8.8.8/dns-query
    - 1.1.1.1
    - 8.8.8.8
  proxy-server-nameserver:
    - https://223.5.5.5/dns-query
    - https://1.12.12.12/dns-query
  nameserver-policy:
    "geosite:cn,private":
      - https://doh.pub/dns-query
      - https://dns.alidns.com/dns-query

# 声明空节点数组，防止报错
proxies: []

# ================= 1. 动态双订阅源 =================
proxy-providers:
  ikuuu_provider:
    type: http
    url: "https://b7k1r.no-mad-world.club/link/gEwRIYIFIPwYWwUi?clash=3&extend=1"
    interval: 3600 # 1小时刷新免费节点
    path: ./proxies/ikuuu.yaml
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  virmach_provider:
    type: http
    # 重点：使用了 /clashMeta/ 纯节点链接
    url: "https://stone.changeip.com:14767/s/clashMeta/c7fbc148b46475f1c8f70a1c74595f14"
    interval: 86400 # 24小时刷新自建节点
    path: ./proxies/virmach.yaml
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

# ================= 2. 高可用与自定义策略组 =================
proxy-groups:
  # --- 核心高可用引擎 ---
  - name: 🚀 ikuuu-最优
    type: url-test
    use:
      - ikuuu_provider
    url: "http://www.gstatic.com/generate_204"
    interval: 300
    tolerance: 50

  - name: 🇺🇸 Virmach-最优
    type: url-test
    use:
      - virmach_provider
    url: "http://www.gstatic.com/generate_204"
    interval: 300
    tolerance: 50

  - name: 🎯 高可用自动切换
    type: fallback
    proxies:
      - 🚀 ikuuu-最优
      - 🇺🇸 Virmach-最优
    url: "http://www.gstatic.com/generate_204"
    interval: 150

  # --- 应用分流组 ---
  - name: 手动切换
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 🚀 ikuuu-最优
      - 🇺🇸 Virmach-最优
      - DIRECT

  - name: 全球代理
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
      - 🚀 ikuuu-最优
      - 🇺🇸 Virmach-最优

  - name: 流媒体
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
      - DIRECT
  - name: DNS_Proxy
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
      - DIRECT
  - name: Telegram
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
  - name: Google
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
      - DIRECT
  - name: YouTube
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
  - name: Netflix
    type: select
    proxies:
      - 流媒体
      - 🎯 高可用自动切换
      - 手动切换
  - name: Spotify
    type: select
    proxies:
      - 流媒体
      - 🎯 高可用自动切换
      - 手动切换
      - DIRECT
  - name: HBO
    type: select
    proxies:
      - 流媒体
      - 🎯 高可用自动切换
      - 手动切换
  - name: Bing
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
  - name: OpenAI
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
  - name: ClaudeAI
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
  - name: Disney
    type: select
    proxies:
      - 流媒体
      - 🎯 高可用自动切换
      - 手动切换
  - name: GitHub
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
      - DIRECT
  - name: 国内媒体
    type: select
    proxies:
      - DIRECT
  - name: 本地直连
    type: select
    proxies:
      - DIRECT
      - 🎯 高可用自动切换
  - name: 漏网之鱼
    type: select
    proxies:
      - 🎯 高可用自动切换
      - 手动切换
      - DIRECT

# ================= 3. 外部规则库 =================
rule-providers:
  lan:
    type: http
    behavior: classical
    interval: 86400
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Lan/Lan.yaml
    path: ./Rules/lan.yaml
  reject:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/reject.txt
    path: ./ruleset/reject.yaml
    interval: 86400
  proxy:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/proxy.txt
    path: ./ruleset/proxy.yaml
    interval: 86400
  direct:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/direct.txt
    path: ./ruleset/direct.yaml
    interval: 86400
  private:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/private.txt
    path: ./ruleset/private.yaml
    interval: 86400
  gfw:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/gfw.txt
    path: ./ruleset/gfw.yaml
    interval: 86400
  greatfire:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/greatfire.txt
    path: ./ruleset/greatfire.yaml
    interval: 86400
  tld-not-cn:
    type: http
    behavior: domain
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/tld-not-cn.txt
    path: ./ruleset/tld-not-cn.yaml
    interval: 86400
  telegramcidr:
    type: http
    behavior: ipcidr
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/telegramcidr.txt
    path: ./ruleset/telegramcidr.yaml
    interval: 86400
  applications:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/applications.txt
    path: ./ruleset/applications.yaml
    interval: 86400
  Disney:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Disney/Disney.yaml
    path: ./ruleset/disney.yaml
    interval: 86400
  Netflix:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Netflix/Netflix.yaml
    path: ./ruleset/netflix.yaml
    interval: 86400
  YouTube:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/YouTube/YouTube.yaml
    path: ./ruleset/youtube.yaml
    interval: 86400
  HBO:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/HBO/HBO.yaml
    path: ./ruleset/hbo.yaml
    interval: 86400
  OpenAI:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/OpenAI/OpenAI.yaml
    path: ./ruleset/openai.yaml
    interval: 86400
  ClaudeAI:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Claude/Claude.yaml
    path: ./ruleset/claudeai.yaml
    interval: 86400
  Bing:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Bing/Bing.yaml
    path: ./ruleset/bing.yaml
    interval: 86400
  Google:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Google/Google.yaml
    path: ./ruleset/google.yaml
    interval: 86400
  GitHub:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/GitHub/GitHub.yaml
    path: ./ruleset/github.yaml
    interval: 86400
  Spotify:
    type: http
    behavior: classical
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Spotify/Spotify.yaml
    path: ./ruleset/spotify.yaml
    interval: 86400
  ChinaMaxDomain:
    type: http
    behavior: domain
    interval: 86400
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_Domain.yaml
    path: ./Rules/ChinaMaxDomain.yaml
  ChinaMaxIPNoIPv6:
    type: http
    behavior: ipcidr
    interval: 86400
    url: https://gh-proxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_IP_No_IPv6.yaml
    path: ./Rules/ChinaMaxIPNoIPv6.yaml

# ================= 4. 分流规则匹配 =================
rules:
  - RULE-SET,YouTube,YouTube,no-resolve
  - RULE-SET,Google,Google,no-resolve
  - RULE-SET,GitHub,GitHub
  - RULE-SET,telegramcidr,Telegram,no-resolve
  - RULE-SET,Spotify,Spotify,no-resolve
  - RULE-SET,Netflix,Netflix
  - RULE-SET,HBO,HBO
  - RULE-SET,Bing,Bing
  - RULE-SET,OpenAI,OpenAI
  - RULE-SET,ClaudeAI,ClaudeAI
  - RULE-SET,Disney,Disney
  - RULE-SET,proxy,全球代理
  - RULE-SET,gfw,全球代理
  - RULE-SET,applications,本地直连
  - RULE-SET,ChinaMaxDomain,本地直连
  - RULE-SET,ChinaMaxIPNoIPv6,本地直连,no-resolve
  - RULE-SET,lan,本地直连,no-resolve
  - GEOIP,CN,本地直连
  - MATCH,漏网之鱼
