mode: rule
log-level: warning
unified-delay: true
tcp-concurrent: true

geodata-mode: true
geo-auto-update: true
geo-update-interval: 24
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"

tun:
  enable: true
  stack: mixed
  auto-route: true
  auto-detect-interface: true
  strict-route: true
  dns-hijack:
    - any:53
    - tcp://any:53
  # endpoint-independent-nat: true
  exclude-package:
    - com.android.captiveportallogin

dns:
  enable: true
  cache-algorithm: arc
  prefer-h3: false # true
  use-hosts: true
  use-system-hosts: true
  listen: :53
  ipv6: false
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  default-nameserver:
    - 1.1.1.1
    - 1.0.0.1
    - 8.8.8.8
    - 8.8.4.4
  nameserver:
    - https://dns10.quad9.net/dns-query
    - https://dns.aa.net.uk/dns-query
  proxy-server-nameserver:
    - 1.1.1.1
    - 8.8.8.8
  # direct-nameserver:
  fake-ip-filter-mode: blacklist
  fake-ip-filter:
    - '+.lan'
    - '+.local'
    - '+.pool.ntp.org'
    - 'time.windows.com'
    - 'time.apple.com'
    - '+.msftconnecttest.com'
    - '+.msftncsi.com'
    - '+.push.apple.com'
    - '+.apple.com'
    - '+.i8m3x.icu'

find-process-mode: always
global-client-fingerprint: chrome

keep-alive-idle: 120
keep-alive-interval: 30

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

sniffer:
  enable: true
  sniff:
    HTTP:
      ports: [80, 8080-8880]
      override-destination: true
    TLS:
      ports: [443, 8443]
    QUIC:
      ports: [443, 8443]
  skip-domain:
    - '+.lan'
    - '+.local'
    - '+.pool.ntp.org'
    - 'time.windows.com'
    - 'time.apple.com'
    - '+.msftconnecttest.com'
    - '+.msftncsi.com'
    - '+.push.apple.com'
    - '+.apple.com'
    - '+.i8m3x.icu'

proxy-providers:
  remnawave:
    type: http
    url: ""
    path: ./providers/remnawave.yaml
    interval: 86400
    proxy: DIRECT
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 30
      timeout: 3000
      lazy: false
      expected-status: 204
    override:
      udp: true
      udp-over-tcp: true

proxy-groups:
  - name: Fastest
    icon: https://cdn.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Auto.png
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 30
    timeout: 3000
    tolerance: 50
    hidden: true
    use:
      - remnawave

  - name: PROXY
    icon: https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Proxy.png
    type: select
    url: http://www.gstatic.com/generate_204
    proxies:
      - Fastest
      - DIRECT
    use:
      - remnawave

  - name: Youtube
    icon: https://cdn.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/YouTube.png
    type: select
    url: http://www.gstatic.com/generate_204
    proxies:
      - PROXY
      - DIRECT

  - name: Discord
    icon: https://cdn.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Discord.png
    type: select
    url: http://www.gstatic.com/generate_204
    proxies:
      - PROXY
      - DIRECT

  - name: RU-Banned
    icon: https://cdn.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Russia.png
    type: select
    proxies:
      - PROXY
      - DIRECT

  - name: Реклама
    icon: https://cdn.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Advertising.png
    type: select
    proxies:
      - REJECT
      - DIRECT

rule-providers:
  oisd-big:
    type: http
    behavior: domain
    format: mrs
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/oisd/big.mrs
    interval: 86400
    path: ./rules/oisd/big.mrs

  # bld-agregator:
  #   type: http
  #   behavior: domain
  #   format: mrs
  #   url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/other/bld-agregator.mrs
  #   interval: 86400
  #   path: ./rules/oisd/bld-agregator.mrs

  refilter_domains:
    type: http
    behavior: domain
    format: mrs
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/re-filter/domain-rule.mrs
    interval: 86400
    path: ./re-filter/domain-rule.mrs

  refilter_ipsum:
    type: http
    behavior: ipcidr
    format: mrs
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/re-filter/ip-rule.mrs
    interval: 86400
    path: ./re-filter/ip-rule.mrs

  antifilter-ip:
    type: http
    behavior: classical
    url: https://antifilter.i8m3x.icu/antifilter-ip.yaml
    interval: 86400
    path: ./rules/custom/antifilter-ip.yaml

  antifilter-community-domain:
    type: http
    behavior: classical
    url: https://antifilter.i8m3x.icu/antifilter-community-domain.yaml
    interval: 86400
    path: ./rules/custom/antifilter-community-domain.yaml

  antifilter-community-ip:
    type: http
    behavior: classical
    url: https://antifilter.i8m3x.icu/antifilter-community-ip.yaml
    interval: 86400
    path: ./rules/custom/antifilter-community-ip.yaml

  # proxy-domain:
  #   type: http
  #   behavior: classical
  #   url: https://antifilter.i8m3x.icu/proxy-domain.yaml
  #   interval: 86400
  #   path: ./rules/custom/proxy-domain.yaml

  android-app-list:
    type: http
    behavior: classical
    format: yaml
    url: https://git.i8m3x.icu/admin/122/raw/branch/master/clash/rules/android-apps.yaml
    interval: 86400
    path: ./rules/custom/android-app-list.yaml

  cloudflare:
    type: http
    behavior: ipcidr
    format: mrs
    url: https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geoip/cloudflare.mrs
    interval: 86400
    path: ./rules/geoip/cloudflare.mrs

  youtube:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/YouTube/YouTube.yaml
    interval: 86400
    path: ./rules/services/youtube.yaml

  discord-domain:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/fildunsky/clash_discord/main/discord-domain.yaml
    interval: 86400
    path: ./rules/services/discord.yaml

  discord-ip:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/fildunsky/clash_discord/refs/heads/main/discord-ip.yaml
    interval: 86400
    path: ./rules/services/discord-ip.yaml

  telegram:
    type: http
    behavior: classical
    url: https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Telegram/Telegram.yaml
    interval: 86400
    path: ./rules/services/telegram.yaml

  telegram-ip:
    type: http
    behavior: ipcidr
    format: text
    url: https://core.telegram.org/resources/cidr.txt
    interval: 86400
    path: ./rules/services/telegram-ip.txt

  games-direct:
    type: http
    behavior: classical
    format: yaml
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/other/games-direct.yaml
    interval: 86400
    path: ./rules/services/games-direct.yaml

  itdoginfo-domains:
    type: http
    behavior: domain
    format: mrs
    url: https://github.com/itdoginfo/allow-domains/releases/latest/download/russia_inside_domain.mrs
    interval: 86400
    path: ./rules/ru-bundle/russia_inside_domain.mrs

  ru-app-list:
    type: http
    behavior: classical
    format: yaml
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/other/ru-app-list.yaml
    interval: 86400
    path: ./rules/ru-bundle/ru-app-list.yaml

  no-russia-hosts:
    type: http
    behavior: domain
    format: mrs
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/ru-bundle/no-russia-hosts.mrs
    interval: 86400
    path: ./rules/ru-bundle/no-russia-hosts.mrs

  rknasnblock:
    type: http
    behavior: ipcidr
    format: mrs
    url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/ru-bundle/rknasnblock.mrs
    interval: 86400
    path: ./rules/ru-bundle/rknasnblock.mrs

  apps_ipcheck:
    type: inline
    behavior: classical
    payload:
      - DOMAIN,ipwho.is
      - DOMAIN,ipapi.is
      - DOMAIN,ipapi.co
      - DOMAIN,api.ip.sb
      # - DOMAIN,ipinfo.io
      - DOMAIN,ip-api.com

rules:
  - RULE-SET,apps_ipcheck,PROXY

  # === REJECT ===
  - RULE-SET,oisd-big,Реклама
  # - RULE-SET,bld-agregator,REJECT

  # === DIRECT (priority) ===
  - RULE-SET,games-direct,DIRECT
  - RULE-SET,ru-app-list,DIRECT

  # === PROXY ===
  - PROCESS-NAME,RobloxPlayerBeta.exe,PROXY
  - PROCESS-NAME,RobloxCrashHandler.exe,PROXY
  - PROCESS-NAME,RobloxPlayerInstaller.exe,PROXY
  - PROCESS-NAME,discord.exe,Discord
  - RULE-SET,discord-domain,Discord
  - RULE-SET,discord-ip,Discord,no-resolve
  - RULE-SET,telegram-ip,PROXY,no-resolve
  - RULE-SET,telegram,PROXY
  - RULE-SET,youtube,Youtube

  - RULE-SET,cloudflare,PROXY
  - RULE-SET,refilter_ipsum,PROXY,no-resolve
  - RULE-SET,refilter_domains,PROXY
  - RULE-SET,antifilter-ip,PROXY,no-resolve
  - RULE-SET,antifilter-community-ip,PROXY,no-resolve
  - RULE-SET,antifilter-community-domain,PROXY
  # - RULE-SET,proxy-domain,PROXY
  - RULE-SET,android-app-list,PROXY

  - RULE-SET,itdoginfo-domains,RU-Banned
  - RULE-SET,no-russia-hosts,RU-Banned
  - RULE-SET,rknasnblock,RU-Banned,no-resolve

  # === DIRECT ===
  - MATCH,DIRECT
