# https://github.com/Dreamacro/clash/wiki/configuration

# Port of HTTP(S) proxy server on the local end
# port: 7890

# Port of SOCKS5 proxy server on the local end
# socks-port: 7891

# Transparent proxy server port for Linux and macOS (Redirect TCP and TProxy UDP)
# redir-port: 7892

# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP)
# tproxy-port: 7893

# HTTP(S) and SOCKS4(A)/SOCKS5 server on the same port
mixed-port: 7890

# authentication of local SOCKS5/HTTP(S) server
# authentication:
#  - "user1:pass1"
#  - "user2:pass2"

# Set to true to allow connections to the local-end server from
# other LAN IP addresses
allow-lan: false

# This is only applicable when `allow-lan` is `true`
# '*': bind all IP addresses
# 192.168.122.11: bind a single IPv4 address
# "[aaaa::a8aa:ff:fe09:57d8]": bind a single IPv6 address
# bind-address: '*'

# Clash router working mode
# rule: rule-based packet routing
# global: all packets will be forwarded to a single endpoint
# direct: directly forward the packets to the Internet
mode: rule

# Clash by default prints logs to STDOUT
# info / warning / error / debug / silent
log-level: info

# When set to false, resolver won't translate hostnames to IPv6 addresses
ipv6: true

# RESTful web API listening address
external-controller: 127.0.0.1:9090

dns:
  enable: true
  listen: 0.0.0.0:53
  ipv6: true
  default-nameserver:
    - 119.29.29.29
    - 1.1.1.1
  enhanced-mode: fake-ip # redir-host
  fake-ip-range: 198.18.0.1/16
  nameserver:
    - tls://1.12.12.12:853
    - tls://120.53.53.53:853
    - tls://1.1.1.1:853
    - tls://1.0.0.1:853

proxies:
  - name: "PC"
    type: socks5
    server: 172.20.48.130
    port: 2345

  - name: "ThinkPad"
    type: socks5
    server: 192.168.2.149
    port: 2345

proxy-providers:
  oxygen:
    type: http
    url: "https://raw.86705429.xyz/oxygenList.yaml"
    interval: 3600
    path: ./providers/proxies.yaml
    health-check:
      enable: true
      interval: 600
      # lazy: true
      url: http://www.gstatic.com/generate_204

  fallbacks:
    type: http
    url: "https://raw.86705429.xyz/fallbacks.yaml"
    interval: 3600
    path: ./providers/fallbacks.yaml
    health-check:
      enable: true
      interval: 600
      # lazy: true
      url: http://www.gstatic.com/generate_204

proxy-groups:
  # 代理节点选择
  - name: "PROXY"
    type: select
    proxies:
      - "fallback"
    use:
      - oxygen

  - name: "fallback"
    type: fallback
    use:
      - fallbacks
    url: 'http://www.gstatic.com/generate_204'
    interval: 300

  # Apple 服务代理
  - name: "Apple"
    type: select
    proxies:
      - "DIRECT"
      - "PROXY"

  # iCloud 服务代理
  - name: "iCloud"
    type: select
    proxies:
      - "DIRECT"
      - "PROXY"

  # 工作电脑代理
  - name: "PcSocks"
    type: select
    proxies:
      - "PC"
      - "ThinkPad"
      - "DIRECT"

rule-providers:
  icloud:
    type: http
    behavior: domain
    url: "https://raw.86705429.xyz/rulesets/icloud.txt"
    path: ./ruleset/icloud.yaml
    interval: 86400

  apple:
    type: http
    behavior: domain
    url: "https://raw.86705429.xyz/rulesets/apple.txt"
    path: ./ruleset/apple.yaml
    interval: 86400

  private:
    type: http
    behavior: domain
    url: "https://raw.86705429.xyz/rulesets/private.txt"
    path: ./ruleset/private.yaml
    interval: 86400

  direct:
    type: http
    behavior: domain
    url: "https://raw.86705429.xyz/rulesets/direct.txt"
    path: ./ruleset/direct.yaml
    interval: 86400

  cncidr:
    type: http
    behavior: ipcidr
    url: "https://raw.86705429.xyz/rulesets/cncidr.txt"
    path: ./ruleset/cncidr.yaml
    interval: 86400

  telegramcidr:
    type: http
    behavior: ipcidr
    url: "https://raw.86705429.xyz/rulesets/telegramcidr.txt"
    path: ./ruleset/telegramcidr.yaml
    interval: 86400

  applications:
    type: http
    behavior: classical
    url: "https://raw.86705429.xyz/rulesets/applications.txt"
    path: ./ruleset/applications.yaml
    interval: 86400

  proxy:
    type: http
    behavior: domain
    url: "https://raw.86705429.xyz/rulesets/proxy.txt"
    path: ./ruleset/proxy.yaml
    interval: 86400

  lancidr:
    type: http
    behavior: ipcidr
    url: "https://raw.86705429.xyz/rulesets/lancidr.txt"
    path: ./ruleset/lancidr.yaml
    interval: 86400

rules:
  - RULE-SET,applications,DIRECT
  - DOMAIN,clash.razord.top,DIRECT
  - DOMAIN,yacd.haishan.me,DIRECT
  - DOMAIN-SUFFIX,bing.com,PROXY
  # Doulingo
  - DOMAIN-SUFFIX,duolingo.com,PROXY
  - DOMAIN-SUFFIX,duolingo.cn,PROXY
  - DOMAIN-SUFFIX,onetrust.com,PROXY
  # Oracle
  - DOMAIN-SUFFIX,oracle.com,DIRECT
  - DOMAIN-SUFFIX,oraclecloud.com,DIRECT
  # CMCC
  - DOMAIN-SUFFIX,hq.cmcc,PcSocks
  - DOMAIN-SUFFIX,cmss.cmcc,PcSocks
  - DOMAIN-SUFFIX,cmss.com,PcSocks
  - DOMAIN-SUFFIX,uban360.com,PcSocks
  - IP-CIDR,10.10.10.2/32,DIRECT
  - IP-CIDR,10.0.0.0/8,PcSocks
  - IP-CIDR,100.64.0.0/10,PcSocks
  # THIRD-SOURCE
  - RULE-SET,private,DIRECT
  - RULE-SET,icloud,iCloud
  - RULE-SET,apple,Apple
  - RULE-SET,proxy,PROXY
  - RULE-SET,direct,DIRECT
  - RULE-SET,cncidr,DIRECT
  - RULE-SET,telegramcidr,PROXY
  - RULE-SET,lancidr,DIRECT
  - GEOIP,CN,DIRECT
  # OTHERS
  - MATCH,PROXY