#---------------------------------------------------#
## 配置文件需要放置在 $HOME/.config/clash/*.yaml

## 这份文件是clashX的基础配置文件，请尽量新建配置文件进行修改。
## ！！！只有这份文件的端口设置会随ClashX启动生效

## 如果您不知道如何操作，请参阅 官方Github文档 https://github.com/Dreamacro/clash/blob/dev/README.md
#---------------------------------------------------#

# (HTTP and SOCKS5 in one port)
mixed-port: 7890
# ipv6: true

# dns:
#   enable: true # set true to enable dns (default is false)
#   ipv6: true # default is false
#   listen: 0.0.0.0:53
#   # default-nameserver: # resolve dns nameserver host, should fill pure IP
#   #   - 114.114.114.114
#   #   - 8.8.8.8
#   enhanced-mode: redir-host # or fake-ip
#   # fake-ip-range: 198.18.0.1/16 # if you don't know what it is, don't change it
#   fake-ip-filter: # fake ip white domain list
#     - '*.lan'
#     - localhost.ptlogin2.qq.com
#   nameserver:
#     - 114.114.114.114
#     - tls://dns.rubyfish.cn:853 # dns over tls
#     - https://1.1.1.1/dns-query # dns over https
#   fallback: # concurrent request with nameserver, fallback used when GEOIP country isn't CN
#     - tcp://1.1.1.1
#   fallback-filter:
#     geoip: true # default
#     ipcidr: # ips in these subnets will be considered polluted
#       - 240.0.0.0/4

# RESTful API for clash
external-controller: 127.0.0.1:9090
allow-lan: false
mode: rule
log-level: error
proxies:

proxy-groups:
  - name: PROXY
    type: select
    proxies:
      - 延迟最低
      - 失败切换
      - 手动选择
      - 负载均衡
  - name: 手动选择
    type: select
    use:
      - provider_remote
  - name: 延迟最低
    type: url-test
    use:
      - provider_remote
    url: 'http://www.gstatic.com/generate_204'
    interval: 300
  
  - name: Chatgpt_node
    type: select
    use:
      - aiboboxx_public_nodes
      - baip0_nodes
    url: 'http://www.gstatic.com/generate_204'
    interval: 300

  - name: 负载均衡
    type: select
    proxies:
      - 负载均衡-联通
      - 负载均衡-移动
      
  - name: 负载均衡-联通
    type: load-balance
    # strategy: consistent-hashing
    strategy: round-robin
    interval: 300
    use:
      - china_unicom_provider_load_balance
    url: 'http://www.gstatic.com/generate_204'

  - name: 负载均衡-移动
    type: load-balance
    # strategy: consistent-hashing
    strategy: round-robin
    interval: 300
    use:
      - china_mobile_provider_load_balance
    url: 'http://www.gstatic.com/generate_204'
  - name: 失败切换
    type: fallback
    use:
      - provider_remote
    url: 'http://www.gstatic.com/generate_204'
    interval: 300
  # - name: 更新地址 https://www.vipiu.net/archives/2018/02/18/306.html
  #   type: select
  #   proxies:
  #     - DIRECT
  # - name: 欢迎访问 https://www.vipiu.net/
  #   type: select
  #   proxies:
  #     - DIRECT


# proxy-providers:
#   provider:
#     type: file
#     # url: "https://free886.herokuapp.com/clash/proxies"
#     interval: 30
#     path: ./provider.yaml
#     health-check:
#       enable: true
#       interval: 600
#       url: http://www.gstatic.com/generate_204

proxy-providers:
  provider_remote:
    type: http
    url: "https://file.dogex.ga/clash/clash_proxy_provider.yaml"
    interval: 3600
    path: ./provider_remote.yaml
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204
  # provider_local:
  #   type: file
  #   path: ./provider_local.yaml
  #   health-check:
  #     enable: true
  #     interval: 600
  #     url: http://www.gstatic.com/generate_204
  provider_load_balance:
    type: http
    url: "https://file.dogex.ga/clash/provider_load_balance.yaml"
    path: ./provider_load_balance.yaml
    interval: 3600
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204
  
  china_unicom_provider_load_balance:
    type: http
    url: "https://file.dogex.ga/clash/china_unicom_provider_load_balance.yaml"
    path: ./china_unicom_provider_load_balance.yaml
    interval: 3600
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204

  china_mobile_provider_load_balance:
    type: http
    url: "https://file.dogex.ga/clash/china_mobile_provider_load_balance.yaml"
    path: ./china_mobile_provider_load_balance.yaml
    interval: 3600
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204

  baip0_nodes:
    type: http
    url: "https://sub.dogex.ga/sub?target=clash&url=https%3A%2F%2Fraw.githubusercontent.com%2Fbaip01%2Fyhkj%2Fmain%2Fv2ray&list=true&emoji=true"
    path: ./baip0_nodes.yaml
    interval: 3600
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204
  
  aiboboxx_public_nodes:
    type: http
    url: "https://sub.dogex.ga/sub?target=clash&url=https%3A%2F%2Fraw.githubusercontent.com%2Faiboboxx%2Fv2rayfree%2Fmain%2Fv2&list=true&emoji=true"
    path: ./aiboboxx_public_nodes.yaml
    interval: 3600
    health-check:
      enable: true
      interval: 600
      url: http://www.gstatic.com/generate_204
    

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,applications,DIRECT
  - DOMAIN,clash.razord.top,DIRECT
  - DOMAIN,yacd.haishan.me,DIRECT
  - DOMAIN-SUFFIX,openai.com,Chatgpt_node
  - RULE-SET,private,DIRECT
  - RULE-SET,reject,REJECT
  - RULE-SET,icloud,DIRECT
  - RULE-SET,apple,DIRECT
  - RULE-SET,google,DIRECT
  - RULE-SET,proxy,PROXY
  - RULE-SET,direct,DIRECT
  - RULE-SET,lancidr,DIRECT
  - RULE-SET,cncidr,DIRECT
  - RULE-SET,telegramcidr,PROXY
  - GEOIP,LAN,DIRECT
  - GEOIP,CN,DIRECT
  - MATCH,PROXY