# HTTP 端口
mixed-port: 7890

# Linux 及 macOS 的 redir 端口
# redir-port: 7892

allow-lan: false

# 仅适用于设置 allow-lan 为 true 时
# "*": 绑定所有 IP 地址
# 192.168.122.11: 绑定单个 IPv4 地址
# "[aaaa::a8aa:ff:fe09:57d8]": 绑定单个 IPv6 地址
# bind-address: "*"

# Rule / Global / Direct (默认为 Rule 模式)
mode: Rule

# 设置输出日志的等级 (默认为 info)
# info / warning / error / debug / silent
log-level: info

# RESTful API for clash
external-controller: 127.0.0.1:9090

dns:
  enable: true
  ipv6: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter-mode: blacklist
  fake-ip-filter:
    - "*.lan"
    - "*.test"
    - "*.home.arpa"
  nameserver:
    - 192.168.11.100
  fallback:
    - tls://8.8.4.4
    - tls://1.1.1.1

proxy-providers:
  AirportShandianProAll:
    type: http
    path: ./providers/proxy/AirportShandianProAll.yaml
    url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    interval: 1800
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  AirportShandianProForegin:
    type: http
    path: ./providers/proxy/AirportShandianProForegin.yaml
    url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    interval: 1800
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  AirportShandianProAmerica:
    type: http
    path: ./providers/proxy/AirportShandianProAmerica.yaml
    url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    interval: 1800
    filter: "美国"
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  AirportShandianProJapan:
    type: http
    path: ./providers/proxy/AirportShandianProJapan.yaml
    url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    interval: 1800
    filter: "日本"
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  AirportShandianProTaiwan:
    type: http
    path: ./providers/proxy/AirportShandianProJapan.yaml
    # url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    url: "https://hproxy.likezgq.top/api/convert?url=https://b88c32b7-e6db-4dc8-b44f-a13e5160f674.shandiannginx.com/api/v1/client/subscribe?token=a629ecf09cd5408c12610a8171085d7c"
    interval: 1800
    filter: "台湾"
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  AirportShandianProSingapore:
    type: http
    path: ./providers/proxy/AirportShandianProSingapore.yaml
    url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    interval: 1800
    filter: "新加坡"
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

  AirportShandianProHongkong:
    type: http
    path: ./providers/proxy/AirportShandianProHongkong.yaml
    url: "https://hproxy.likezgq.top/api/convert?url=https://times1732002366.subxiandan.top:9604/v2b/shandian/api/v1/client/subscribe?token=fdee6024ef338b23b9012eb748030d1c"
    interval: 1800
    filter: "香港"
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300

proxies:
  - name: "router_local_reality"
    type: socks5
    server: 192.168.11.13
    port: 7891
  - name: "local_reality"
    type: socks5
    server: 127.0.0.1
    port: 10000

  ## VMess
  - name: "vmess_cfws_likezgq"
    type: vmess
    # server: 104.27.80.65
    server: 172.64.93.84
    port: 8080
    uuid: e3a45881-f11b-42da-b0d0-4f1f57c5d57b
    alterId: 0
    cipher: none
    #udp: true
    #tls: true
    skip-cert-verify: true
    network: ws
    #tls-hostname: v2.zgqqq.top # for TLS SNI
    # ws-path: /pe7MCcsa7
    # ws-headers: #这一行后面不要写东西
    #   Host: v5.zhenvip.wang # 填写伪装域名
    ws-opts:
      headers:
        Host: cfws.likezgq.top
      path: /ws

  ## VMess
  - name: "vmess_cfws_tls_likezgq"
    type: vmess
    # server: 141.101.115.236
    server: 104.16.29.191
    # server: 172.64.93.84
    port: 2053
    uuid: a226be6c-2b1c-49c3-ad6b-f5857704f003
    alterId: 0
    cipher: none
    #udp: true
    tls: true
    skip-cert-verify: true
    network: ws
    tls-hostname: cftls.likezgq.top # for TLS SNI
    # ws-path: /pe7MCcsa7
    # ws-headers: #这一行后面不要写东西
    #   Host: v5.zhenvip.wang # 填写伪装域名
    ws-opts:
      headers:
        Host: cftls.likezgq.top
      path: /tls

proxy-groups:
  - name: SB_LOWEST_DELAY1
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 150
    tolerance: 30 #延迟相差 30ms 以内就不⽤切换
    proxies:
      - "vmess_cfws_likezgq"
      - "vmess_cfws_tls_likezgq"
      - "local_reality"
      - "router_local_reality"

  - name: SB_SELECTED
    # type: url-test
    # url: http://www.gstatic.com/generate_204
    # interval: 300
    type: select
    proxies:
      - SB_LOWEST_DELAY1
      - "vmess_cfws_tls_likezgq"
      - "vmess_cfws_likezgq"
      - "local_reality"
      - "router_local_reality"

  - name: GPT_LOWEST_DELAY1
    type: url-test
    # url: http://www.gstatic.com/generate_204
    url: https://github.com
    interval: 150
    tolerance: 30 #延迟相差 30ms 以内就不⽤切换
    use:
      - AirportShandianProTaiwan
      - AirportShandianProSingapore
      # - AirportShandianProJapan

  - name: GPT_SELECTED
    type: select
    proxies:
      # - "v2ray-yxcft2-likezgq"
      - GPT_LOWEST_DELAY1
      - SB_SELECTED
      - PG_AMERICA

  - name: GOOGLE_SELECTED
    type: select
    proxies:
      # - "v2ray-yxcft2-likezgq"
      - GPT_LOWEST_DELAY1
      - SB_SELECTED
      - PG_AMERICA

  - name: NO_MATCH_SELECTED
    type: select
    proxies:
      # - "v2ray-yxcft2-likezgq"
      - GPT_SELECTED
      - PROXY
      - DIRECT

  - name: REDDIT_SELECTED
    type: select
    proxies:
      # - "v2ray-yxcft2-likezgq"
      - PROXY
      - SB_SELECTED
      - PG_JAPAN
      - PG_AMERICA
      - PG_TAIWAN

  - name: YOUTUBE_SELECTED
    type: select
    proxies:
      # - "v2ray-yxcft2-likezgq"
      - LOWEST_DELAY1
      - SB_LOWEST_DELAY1
      - SB_SELECTED

  - name: LOWEST_DELAY1
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 150
    tolerance: 50 #延迟相差 50ms 以内就不⽤切换
    use:
      - AirportShandianProHongkong
    proxies:
      # - "v2ray-yxcft2-likezgq"
      # - "vmess_cfws_tls_likezgq"
      # - DIRECT

  - name: LOWEST_DELAY2
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 250
    tolerance: 30 #延迟相差 30ms 以内就不⽤切换
    use:
      # - AirportPaopaoDogAll
      # - AirportShandianProAll
      - AirportShandianProHongkong
    proxies:
      # - "v2ray-yxcft2-likezgq"
      # - "vmess_cfws_tls_likezgq"
      # - DIRECT

  - name: LOWEST_LOAD_BALANCE
    type: load-balance
    strategy: consistent-hashing
    url: "http://www.google.com/generate_204"
    interval: 180
    proxies:
      - LOWEST_DELAY1
      - LOWEST_DELAY2

  - name: PROXY_DELAY
    type: url-test
    # type: fallback
    url: http://www.gstatic.com/generate_204
    interval: 150
    proxies:
      - LOWEST_LOAD_BALANCE
      - SB_SELECTED

  - name: PROXY
    type: select
    proxies:
      - PROXY_DELAY
      - LOWEST_LOAD_BALANCE
      - GPT_SELECTED
      - SB_SELECTED

  - name: PG_AMERICA
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 300
    use:
      - AirportShandianProAmerica
    proxies:
      - SB_SELECTED
    #   # - "v2ray-yxcft2-likezgq"
    #   - "vmess_cfws_tls_likezgq"

  - name: PG_JAPAN_DELAY
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 300
    use:
      - AirportShandianProJapan

  - name: PG_JAPAN
    type: select
    proxies:
      - PG_JAPAN_DELAY
      - SB_SELECTED

  - name: PG_TAIWAN
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 300
    use:
      - AirportShandianProTaiwan

  - name: PG_SINGLEAPORE
    type: url-test
    url: http://www.gstatic.com/generate_204
    interval: 300
    use:
      - AirportShandianProSingapore

rule-providers:
  reject:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt"
    path: ./ruleset/reject.yaml
    interval: 86400

  icloud:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt"
    path: ./ruleset/icloud.yaml
    interval: 86400

  apple:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt"
    path: ./ruleset/apple.yaml
    interval: 86400

  google:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt"
    path: ./ruleset/google.yaml
    interval: 86400

  proxy:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt"
    path: ./ruleset/proxy.yaml
    interval: 86400

  direct:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt"
    path: ./ruleset/direct.yaml
    interval: 86400

  private:
    type: http
    behavior: domain
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/private.txt"
    path: ./ruleset/private.yaml
    interval: 86400

  tld-not-cn:
    type: http
    behavior: domain
    url: "https://fastly.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://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt"
    path: ./ruleset/telegramcidr.yaml
    interval: 86400

  cncidr:
    type: http
    behavior: ipcidr
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt"
    path: ./ruleset/cncidr.yaml
    interval: 86400

  lancidr:
    type: http
    behavior: ipcidr
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt"
    path: ./ruleset/lancidr.yaml
    interval: 86400

  applications:
    type: http
    behavior: classical
    url: "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/applications.txt"
    path: ./ruleset/applications.yaml
    interval: 86400

  # pornhub:
  #   type: http
  #   behavior: domain
  #   url: "https://raw.gitmirror.com/ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/Pornhub.yaml"
  #   path: ./ruleset/pornhub.yaml
  #   interval: 86400

  # openai:
  #   type: http
  #   behavior: domain
  #   url: "https://raw.gitmirror.com/ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/OpenAi.yaml"
  #   path: ./ruleset/openai.yaml
  #   interval: 86400

  github:
    type: http
    behavior: domain
    url: "https://raw.gitmirror.com/ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/Github.yaml"
    path: ./ruleset/github.yaml
    interval: 86400

  tiktok:
    type: http
    behavior: domain
    url: "https://raw.gitmirror.com/ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/TikTok.yaml"
    path: ./ruleset/tiktok.yaml
    interval: 86400

rules:
  - DST-PORT,22,SB_SELECTED
  # UDP手机会报错，所以注释掉
  - AND,((NETWORK,UDP),(DST-PORT,443)),REJECT 
  # - DOMAIN-SUFFIX,claude.ai,PG_AMERICA
  # - DOMAIN-SUFFIX,openai.com,SB_SELECTED
  - DOMAIN,huggingface.co,SB_SELECTED
  # - DOMAIN-SUFFIX,openai.com,PG_SINGLEAPORE
  # - DOMAIN-SUFFIX,chatgpt.com,PG_SINGLEAPORE
  - DOMAIN-SUFFIX,openai.com,GPT_SELECTED
  - DOMAIN-KEYWORD,openai,GPT_SELECTED
  - DOMAIN-KEYWORD,chatgpt,GPT_SELECTED
  - DOMAIN-KEYWORD,claude,GPT_SELECTED
  - DOMAIN-SUFFIX,servd-anthropic-website.b-cdn.net,GPT_SELECTED
  - DOMAIN-SUFFIX,anthropic.com,GPT_SELECTED
  - DOMAIN-SUFFIX,claude.ai,GPT_SELECTED
  - DOMAIN-SUFFIX,intercomcdn.com,GPT_SELECTED
  - DOMAIN-SUFFIX,cdn.usefathom.com,GPT_SELECTED
  - DOMAIN-SUFFIX,stripe.com,GPT_SELECTED
  - DOMAIN-KEYWORD,sora.com,GPT_SELECTED
  - DOMAIN-KEYWORD,grok,GPT_SELECTED
  - DOMAIN-KEYWORD,aistudio,GPT_SELECTED
  - RULE-SET,github,GPT_SELECTED
  # - DOMAIN-SUFFIX,github.com:22,GPT_SELECTED
  # - DOMAIN-KEYWORD,github,GPT_SELECTED
  - DOMAIN-KEYWORD,youtube,YOUTUBE_SELECTED
  # - DOMAIN-SUFFIX,v2ex.com,GPT_SELECTED
  - DOMAIN-KEYWORD,google,GOOGLE_SELECTED
  - DOMAIN-KEYWORD,gemini,GOOGLE_SELECTED
  - DOMAIN-KEYWORD,discord,PG_AMERICA
  - DOMAIN-KEYWORD,us-api,PG_AMERICA
  # - DOMAIN,google.com,GPT_SELECTED
  - DOMAIN-KEYWORD,paypal,PG_AMERICA
  - DOMAIN-KEYWORD,paypa1,PG_AMERICA
  - DOMAIN-KEYWORD,reddit.com,REDDIT_SELECTED
  - DOMAIN-KEYWORD,avgle,PG_JAPAN
  - DOMAIN-KEYWORD,porn,PG_JAPAN
  - DOMAIN-KEYWORD,xvideo,PG_JAPAN
  - DOMAIN-KEYWORD,xhamster,PG_JAPAN
  - RULE-SET,tiktok,PG_AMERICA
  # - DOMAIN-KEYWORD,pikpak,GPT_SELECTED
  - DOMAIN-SUFFIX,ycombinator.com,PROXY
  - DOMAIN-SUFFIX,distrowatch.com,PROXY
  # pip
  - DOMAIN-SUFFIX,pypi.org,PROXY
  - DOMAIN-SUFFIX,pythonhosted.org,PROXY
  # nvidia
  - DOMAIN-SUFFIX,nvidia.com,PROXY
  - DOMAIN-SUFFIX,tailscale.com,PROXY
  # - DOMAIN-SUFFIX,sgsnssdk.com,PROXY
  # - DOMAIN-SUFFIX,vungle.com,PROXY
  # - DOMAIN,aka.ms,PROXY
  - RULE-SET,telegramcidr,PROXY,no-resolve
  - DOMAIN-KEYWORD,time.windows.com,DIRECT
  - DOMAIN-SUFFIX,likezgq.top,DIRECT
  - DOMAIN-KEYWORD,ra2web.com,DIRECT
  - DOMAIN-KEYWORD,bun.sh.cn,DIRECT
  - DOMAIN-SUFFIX,kgithub.com,DIRECT
  - DOMAIN-KEYWORD,chronodivide.com,DIRECT
  - DOMAIN,clash.razord.top,DIRECT
  - DOMAIN,yacd.haishan.me,DIRECT
  - DOMAIN-SUFFIX,likezgq.pub,DIRECT
  - DOMAIN-SUFFIX,home.pub,DIRECT
  - DOMAIN-SUFFIX,lan,DIRECT
  - RULE-SET,proxy,GPT_SELECTED
  # 自定义规则
  # cloudflare cdn
  - IP-CIDR,104.27.80.65/32,DIRECT
  - IP-CIDR,104.16.29.191/32,DIRECT
  - IP-CIDR,141.101.115.236/32,DIRECT
  - IP-CIDR,172.64.93.84/32,DIRECT
  - IP-CIDR,142.171.94.73/32,DIRECT
  # tailscale ip
  - IP-CIDR,100.64.0.0/10,DIRECT
  # Windows Tailscale processes
  - PROCESS-NAME,Tailscale.exe,DIRECT
  - PROCESS-NAME,Tailscale Service.exe,DIRECT
  - PROCESS-NAME,tailscaled.exe,DIRECT
  - PROCESS-NAME,tailscale-ipn.exe,DIRECT
  # macOS Tailscale processes
  - PROCESS-NAME,tailscaled,DIRECT
  - PROCESS-NAME,Tailscale,DIRECT
  # - RULE-SET,openai,PG_JAPAN
  - RULE-SET,applications,DIRECT
  - RULE-SET,private,DIRECT
  - RULE-SET,reject,REJECT
  - RULE-SET,icloud,DIRECT
  - RULE-SET,apple,DIRECT
  # - RULE-SET,google,DIRECT
  - RULE-SET,direct,DIRECT
  - RULE-SET,lancidr,DIRECT,no-resolve
  - RULE-SET,cncidr,DIRECT,no-resolve
  # - GEOIP,LAN,DIRECT,no-resolve
  # - GEOIP,CN,DIRECT,no-resolve
  - GEOIP,LAN,DIRECT
  - GEOIP,CN,DIRECT
  - MATCH,NO_MATCH_SELECTED