port: 7890
socks-port: 7891
mixed-port: 7893
redir-port: 7892
tproxy-port: 7895

allow-lan: true
bind-address: "*"
# authentication:
#   - "username:password"
# skip-auth-prefixes:
#   - 127.0.0.1/8
#   - ::1/128
# lan-allowed-ips:
#   - 0.0.0.0/0
#   - ::/0
# lan-disallowed-ips:
#   - 192.168.0.3/32

#  find-process-mode has 3 values: always, strict, off
find-process-mode: strict

mode: rule

geodata-mode: true
geox-url:
  geoip: "https://testingcf.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat"
  geosite: "https://testingcf.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat"
  mmdb: "https://testingcf.jsdelivr.net/gh/alecthw/mmdb_china_ip_list@release/Country.mmdb"

geo-auto-update: true
geo-update-interval: 12

# Matcher implementation used by GeoSite, available implementations:
# - succinct (default, same as rule-set)
# - mph (from V2Ray, also `hybrid` in Xray)
# geosite-matcher: succinct

log-level: error

ipv6: false

# tls:
#   certificate: string
#   private-key: string
#   client-auth-type: ""
#   client-auth-cert: string
#   ech-key: |
#     -----BEGIN ECH KEYS-----
#     ACATwY30o/RKgD6hgeQxwrSiApLaCgU+HKh7B6SUrAHaDwBD/g0APwAAIAAgHjzK
#     madSJjYQIf9o1N5GXjkW4DEEeb17qMxHdwMdNnwADAABAAEAAQACAAEAAwAIdGVz
#     dC5jb20AAA==
#     -----END ECH KEYS-----
#   custom-certifactes:
#     - |
#       -----BEGIN CERTIFICATE-----
#       format/pem...
#       -----END CERTIFICATE-----

external-controller: 0.0.0.0:9093
# external-controller-tls: 0.0.0.0:9443
secret: password

# external-controller-cors:
#   allow-origins:
#     - "*"
#   allow-private-network: true

# external-controller-unix: mihomo.sock

# external-controller-pipe: \\.\pipe\mihomo

tcp-concurrent: true

external-ui: "./ui"
external-ui-name: xd
external-ui-url: "https://ghproxy.uufly.org/https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip"

# external-doh-server: /dns-query

# interface-name: eth0

disable-keep-alive: false
keep-alive-idle: 1800
keep-alive-interval: 1800

# routing-mark: 6666
# experimental:
#   quic-go-disable-gso: true

# hosts:
#   "*.mihomo.dev": 127.0.0.1
#   ".dev": 127.0.0.1
#   "alpha.mihomo.dev": "::1"
#   test.com: [1.1.1.1, 2.2.2.2]
#   home.lan: lan
#   baidu.com: google.com

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

# tun:
#   enable: false
#   stack: gvisor
#   dns-hijack:
#     - 0.0.0.0:53
#   auto-detect-interface: true
#   auto-route: true
#   mtu: 9000
#   gso: false
#   gso-max-size: 65536
#   auto-redirect: false
#   strict-route: true
#   disable-icmp-forwarding: true
#   route-address-set:
#     - ruleset-1
#     - ruleset-2
#   route-exclude-address-set:
#     - ruleset-3
#     - ruleset-4
#   route-address:
#     - 0.0.0.0/1
#     - 128.0.0.0/1
#     - "::/1"
#     - "8000::/1"
#   endpoint-independent-nat: false
#   include-interface:
#     - "lan0"
#   exclude-interface:
#     - "lan1"
#   include-uid:
#     - 0
#   include-uid-range:
#     - 1000:9999
#   exclude-uid:
#     - 1000
#   exclude-uid-range:
#     - 1000:9999
#   include-mac-address:
#     - 00:11:22:33:44:55
#   exclude-mac-address:
#     - 00:11:22:33:44:55
#   include-android-user:
#     - 0
#     - 10
#   include-package:
#     - com.android.chrome
#   exclude-package:
#     - com.android.captiveportallogin

sniffer:
  enable: true
  force-dns-mapping: true
  parse-pure-ip: true
  override-destination: true
  sniff:
    QUIC:
      ports:
        - 443
    TLS:
      ports:
        - 443
        - 8443
    HTTP:
      ports:
        - 80
        - 8080
        # - 8080-8880
      # override-destination: true
  force-domain:
    - "+.netflix.com"
    - "+.nflxvideo.net"
    - "+.amazonaws.com"
    - "+.media.dssott.com"
  skip-domain:
    - "+.apple.com"
    - "Mijia Cloud"
    - "dlg.io.mi.com"
    - "+.oray.com"
    - "+.sunlogin.net"
    - "+.push.apple.com"
  # skip-src-address:
  #   - 192.168.0.3/32
  # skip-dst-address:
  #   - 192.168.0.3/32

# tunnels:
#   - tcp/udp,127.0.0.1:6553,114.114.114.114:53,proxy
#   - tcp,127.0.0.1:6666,rds.mysql.com:3306,vpn
#   - network: [tcp, udp]
#     address: 127.0.0.1:7777
#     target: target.com
#     proxy: proxy

dns:
  cache-algorithm: arc
  enable: true
  prefer-h3: true
  listen: 0.0.0.0:7874
  ipv6: false
  # ipv6-timeout: 300
  default-nameserver:
    - 223.5.5.5
    - 114.114.114.114
    - system://
  enhanced-mode: redir-host
  fake-ip-range: 198.18.0.1/16
  # fake-ip-range6: fdfe:dcba:9876::1/64
  fake-ip-filter:
    - "+.plex.direct"
    - "+.plex.tv"
    - "+.sn.mynetname.net"
    - "+.jsdelivr.net"
    - "rawstatic.com"
    - "ghproxy.uufly.org"
  fake-ip-filter-mode: blacklist
  fake-ip-ttl: 1
  use-hosts: true
  respect-rules: true
  nameserver:
    - https://223.5.5.5/dns-query#DIRECT&skip-cert-verify=true
    - https://120.53.53.53/dns-query#DIRECT&skip-cert-verify=true
  fallback:
    - https://8.8.4.4/dns-query#Proxy&skip-cert-verify=true&disable-ipv6=true
    - https://9.9.9.9/dns-query#Proxy&skip-cert-verify=true&disable-ipv6=true
    - https://1.0.0.1/dns-query#Proxy&skip-cert-verify=true&disable-ipv6=true
    - https://208.67.222.222/dns-query#Proxy&skip-cert-verify=true&disable-ipv6=true
    - https://94.140.14.140/dns-query#Proxy&skip-cert-verify=true&disable-ipv6=true
  proxy-server-nameserver:
    - https://223.5.5.5/dns-query#DIRECT&skip-cert-verify=true
    - https://120.53.53.53/dns-query#DIRECT&skip-cert-verify=true
  direct-nameserver:
    - https://223.5.5.5/dns-query#DIRECT&skip-cert-verify=true
    - https://120.53.53.53/dns-query#DIRECT&skip-cert-verify=true
  direct-nameserver-follow-policy: false
  fallback-filter:
    geoip: true
    geoip-code: CN
    geosite:
      - geolocation-!cn
    # ipcidr:
    #   - 240.0.0.0/4
    domain:
      - "+.google.com"
      - "+.facebook.com"
      - "+.youtube.com"
  nameserver-policy:
    "geosite:category-ads-all": rcode://name_error
    "rule-set:Adblock4limbo": rcode://name_error
    "myip.ipip.net":
      - https://223.5.5.5/dns-query#DIRECT&skip-cert-verify=true&disable-ipv6=true
      - https://120.53.53.53/dns-query#DIRECT&skip-cert-verify=true&disable-ipv6=true

proxy-providers:
  SubStore:
    type: http
    url: https://subs.uufly.org/getsub/collection/ff2c3e13
    interval: 86400
    path: ./proxy_provider/SubStore.yaml
    proxy: DIRECT
    health-check:
      enable: true
      interval: 1800
      url: http://cp.cloudflare.com/generate_204
    override:
      skip-cert-verify: true
      udp: true

proxy-groups:
  - name: Proxy
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Rocket.png
    type: select
    proxies:
      - 🔙 Fallback
      - 🇭🇰 HK
      - 🇯🇵 JP
      - 🇸🇬 SG
      - 🇺🇸 US
      - 🇨🇳 TW
      - 🇰🇷 KR
      - 🇬🇧 UK
      - 🇮🇳 IN
      - 🌐 Special
      - DIRECT
  - name: AdBlock
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Advertising.png
    type: select
    proxies:
      - REJECT
      - REJECT-DROP
      - DIRECT
      - Proxy
      - PASS

  # AI
  - name: LLMApiGlobal
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/AI.png
    type: select
    proxies:
      - Proxy
      - DIRECT
      - 🇭🇰 HK
      - 🇯🇵 JP
      - 🇸🇬 SG
      - 🇺🇸 US
      - 🇨🇳 TW
      - 🇰🇷 KR
      - 🇬🇧 UK
      - 🇮🇳 IN
      - 🌐 Special

  # Final
  - name: Final
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Final.png
    type: select
    proxies:
      - Proxy
      - DIRECT

  # Fallback
  - name: 🔙 Fallback
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Auto.png
    type: fallback
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    proxies:
      - 🇭🇰 HK
      - 🇯🇵 JP
      - 🇸🇬 SG
      - 🇺🇸 US

  # Area
  - name: 🇭🇰 HK
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Hong_Kong.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(港|HK|Hong)

  - name: 🇯🇵 JP
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Japan.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)((\b日((?!用).)+)|日本|川日|东京|大阪|泉日|埼玉|沪日|深日|JP|Japan)

  - name: 🇸🇬 SG
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Singapore.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(新加坡|坡|狮城|SG|Singapore)

  - name: 🇺🇸 US
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/United_States.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(\b美|美国|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥|US|(United States))

  - name: 🇨🇳 TW
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Taiwan.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(台|新北|彰化|TW|Tai)

  - name: 🇰🇷 KR
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Korea.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(KR|Korea|KOR|首尔|韩|韓)

  - name: 🇬🇧 UK
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/United_Kingdom.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(英国|UK|伦敦|(United Kingdom)|GBR)

  - name: 🇮🇳 IN
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/India.png
    type: url-test
    url: http://cp.cloudflare.com/generate_204
    interval: 300
    tolerance: 30
    include-all-providers: true
    filter: (?i)(印度|孟买|新德里|班加罗尔|India)

  - name: 🌐 Special
    icon: https://ghproxy.uufly.org/https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Global.png
    type: select
    include-all-providers: true
    filter: ^(?i)(?!.*(港|HK|Hong|新加坡|坡|狮城|SG|Singapore|(\b日((?!用).)+)|日本|川日|东京|大阪|泉日|埼玉|沪日|深日|JP|Japan|\b美|美国|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥|US|(United States)|台|新北|彰化|TW|Tai|英国|UK|伦敦|(United Kingdom)|GBR|KR|Korea|KOR|首尔|韩|韓|印度|孟买|新德里|班加罗尔|India))

rules:
  # Block QUIC
  - AND,((NETWORK,udp),(DST-PORT,443/4483/9305)),REJECT

  # Custom force
  - RULE-SET,CustomDirect,DIRECT,no-resolve
  - RULE-SET,CustomProxy,Proxy,no-resolve
  - RULE-SET,CustomReject,AdBlock,no-resolve

  # Ban Ads
  - GEOSITE,category-ads-all,AdBlock
  - RULE-SET,Adblock4limbo,AdBlock,no-resolve

  # Apple
  - GEOSITE,apple,DIRECT

  # Download
  - GEOSITE,category-game-platforms-download,DIRECT
  - GEOSITE,category-pt,DIRECT
  - GEOSITE,category-public-tracker,DIRECT

  # AI
  - GEOSITE,category-ai-!cn,LLMApiGlobal

  # APP
  - GEOSITE,category-speedtest,DIRECT

  # Force proxy
  - GEOSITE,geolocation-!cn,Proxy

  # Force china direct, cn include *-cn, ex: category-media-cn,category-entertainment-cn
  - GEOSITE,cn,DIRECT

  # Private network
  - GEOSITE,private,DIRECT

  # IP rules below, domain should be resolve, so put it last

  # GlobalSSH
  - AND,((DST-PORT,22),(NOT,((GEOIP,CN)))),Proxy

  # APP IPs
  - GEOIP,telegram,Proxy
  - GEOIP,google,Proxy
  - GEOIP,netflix,Proxy

  # Local network
  - GEOIP,private,DIRECT

  # CN, should be resolve
  - GEOIP,CN,DIRECT

  # Final
  - MATCH,Final

rule-providers:
  # Adblock4limbo
  Adblock4limbo:
    type: http
    behavior: classical
    url: https://ghproxy.uufly.org/https://raw.githubusercontent.com/alecthw/chnlist/release/Providers/Custom/Adblock4limbo.yaml
    path: ./rule_provider/Adblock4limbo.yaml
    interval: 86400

  # Custom force
  CustomDirect:
    type: http
    behavior: classical
    url: https://ghproxy.uufly.org/https://raw.githubusercontent.com/alecthw/chnlist/release/Providers/Custom/CustomDirect.yaml
    path: ./rule_provider/CustomDirect.yaml
    interval: 86400
  CustomProxy:
    type: http
    behavior: classical
    url: https://ghproxy.uufly.org/https://raw.githubusercontent.com/alecthw/chnlist/release/Providers/Custom/CustomProxy.yaml
    path: ./rule_provider/CustomProxy.yaml
    interval: 86400
  CustomReject:
    type: http
    behavior: classical
    url: https://ghproxy.uufly.org/https://raw.githubusercontent.com/alecthw/chnlist/release/Providers/Custom/CustomReject.yaml
    path: ./rule_provider/CustomReject.yaml
    interval: 86400
