#------------------------基础配置------------------------#
mixed-port: 7890 # 混合端口：HTTP(S)和SOCKS5共用端口
geodata-mode: true # GEO模式：true使用geoip.dat数据库,false使用mmdb数据库
tcp-concurrent: true # TCP并发：允许并发连接TCP,提高并发性能
unified-delay: true # 统一延迟：统一显示节点延迟
allow-lan: true # 局域网连接：允许其他设备经过本机代理
bind-address: '*' # 监听地址：*表示绑定所有IP地址
find-process-mode: strict # 进程匹配模式：strict严格,off关闭,always总是
ipv6: true # IPv6开关：是否启用IPv6支持

# 运行模式(任选其一):
# rule: 规则模式 - 根据规则匹配来选择代理
# global: 全局模式 - 全部流量走代理
# direct: 直连模式 - 全部流量不走代理
mode: rule

# 日志等级(按详细程度排序):
# debug: 调试
# info: 信息
# warning: 警告
# error: 错误
# silent: 静默
log-level: info

# 外部控制设置
external-controller: 0.0.0.0:9090 # 外部控制器监听地址
external-ui: ui # 外部控制器UI目录
secret: '' # 外部控制器密码

#------------------------性能调优------------------------#
tcp-concurrent-users: 64 # TCP并发连接数,根据服务器性能调整,建议值:16-128
keep-alive-interval: 15 # 保活心跳间隔(秒),建议值:15-30
inbound-tfo: true # 入站TCP Fast Open
outbound-tfo: true # 出站TCP Fast Open
# Windows示例
#interface-name: WLAN   # Windows中的无线网卡名称
# 或
#interface-name: 以太网  # Windows中的有线网卡名称
# macOS示例
#interface-name: en0    # macOS中通常是Wi-Fi
# 或
#interface-name: en1    # macOS中通常是有线网卡
# Linux示例
#interface-name: eth0   # Linux中常见的有线网卡名
# 或
#interface-name: wlan0  # Linux中常见的无线网卡名

# 连接池配置
connection-pool-size: 256 # 连接池大小,建议值:128-512
idle-timeout: 60 # 空闲超时时间(秒)

#------------------------TLS 配置------------------------#
tls:
  enable: true # 启用TLS支持
  skip-cert-verify: false # 是否跳过证书验证
  alpn: # 应用层协议协商
    - h2 # HTTP/2
    - http/1.1 # HTTP/1.1
  min-version: '1.2' # 最低TLS版本
  max-version: '1.3' # 最高TLS版本
  cipher-suites: # 加密套件优先级
    - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
    - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305

#------------------------TUN 配置------------------------#
tun:
  enable: true
  stack: system
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - any:53
    - tcp://any:53

#------------------------DNS 配置------------------------#
dns:
  enable: true # 启用DNS服务器
  prefer-h3: true # 优先使用HTTP/3查询
  ipv6: true # DNS解析IPv6
  listen: 0.0.0.0:53 # DNS监听地址
  enhanced-mode: redir-host # DNS模式: fake-ip或redir-host
  use-hosts: true # 使用hosts文件

  # 默认DNS服务器(用于解析其他DNS服务器的域名)
  default-nameserver:
    - 223.5.5.5 # 阿里DNS
    - 119.29.29.29 # 腾讯DNS

  # DNS服务器分流策略
  nameserver-policy:
    'www.google.com': 'https://dns.google/dns-query' # Google域名使用Google DNS
    'www.facebook.com': 'https://dns.google/dns-query' # Facebook域名使用Google DNS
    '.cn': 'https://doh.pub/dns-query' # 中国域名使用国内DNS

  # Fake-IP配置
  fake-ip-range: 198.18.0.1/16 # Fake-IP地址段
  fake-ip-filter: # Fake-IP过滤清单
    - '*.lan' # 本地域名
    - 'localhost.ptlogin2.qq.com' # QQ登录

  # 主要DNS服务器
  nameserver:
    # 国内DNS服务器
    - https://doh.pub/dns-query#h3=true # DNSPod DOH
    - https://dns.alidns.com/dns-query#h3=true # 阿里 DOH
    - tls://223.5.5.5:853 # 阿里 DOT

    # 国外DNS服务器
    - https://dns.google/dns-query#h3=true # Google DOH
    - https://cloudflare-dns.com/dns-query#h3=true # Cloudflare DOH
    - quic://dns.adguard.com:784 # AdGuard DOQ

  # 备用DNS服务器(用于解析国外域名)
  fallback:
    - https://doh.dns.sb/dns-query#h3=true
    - https://dns.cloudflare.com/dns-query
    - https://dns.twnic.tw/dns-query
    - https://dns.google/dns-query#h3=true
    - tls://8.8.8.8:853

# ------------------------代理配置------------------------#
proxies:
  - {
      'name': 'Tencent',
      'type': 'vless',
      'server': '43.130.33.145',
      'port': 443,
      'uuid': 'e2c7c2b4-9b8e-4c1e-b7b4-1b0b3e4f6a11',
      'flow': 'xtls-rprx-vision',
      'network': 'tcp',
      'tls': true,
      'udp': true,
      'servername': 'www.cloudflare.com',
      'client-fingerprint': 'chrome',
      'reality-opts': { 'public-key': 'z6HTRHoobeDRNmvLVM-PcYNC2JcRzdqbiwMYaiJROC0', 'short-id': 'a1b2c3d4' },
    }

proxy-groups:
  #------------------------基础分组------------------------#
  - name: 🚀 节点选择
    type: select
    proxies:
      - ♻️ 自动选择
      - 🔯 故障转移
      - IPLC负载组
      - 香港负载组
      - 台湾负载组
      - 日本负载组
      - 新加坡负载组
      - 🇭🇰 香港节点
      - 🇨🇳 台湾节点
      - 🇯🇵 日本节点
      - 🇺🇲 美国节点
      - 🇸🇬 狮城节点
      - DIRECT

  - name: ♻️ 自动选择
    type: url-test
    include-all-providers: true
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  - name: 🔯 故障转移
    type: fallback
    include-all-providers: true
    url: http://www.gstatic.com/generate_204
    interval: 300

  - name: IPLC负载组
    type: load-balance
    strategy: consistent-hashing
    include-all-providers: true
    filter: '(?i)IPLC'
    url: http://www.gstatic.com/generate_204
    interval: 300

  - name: 香港负载组
    type: load-balance
    strategy: consistent-hashing
    include-all-providers: true
    filter: '(?i)港|hk|hongkong|hong kong'
    url: http://www.gstatic.com/generate_204
    interval: 300

  - name: 台湾负载组
    type: load-balance
    strategy: consistent-hashing
    include-all-providers: true
    filter: '(?i)台|tw|taiwan|taipei'
    url: http://www.gstatic.com/generate_204
    interval: 300

  - name: 日本负载组
    type: load-balance
    strategy: consistent-hashing
    include-all-providers: true
    filter: '(?i)日|jp|japan|tokyo|osaka'
    url: http://www.gstatic.com/generate_204
    interval: 300

  - name: 新加坡负载组
    type: load-balance
    strategy: consistent-hashing
    include-all-providers: true
    filter: '(?i)新|sg|singapore'
    url: http://www.gstatic.com/generate_204
    interval: 300

  - name: 美国负载组
    type: load-balance
    strategy: consistent-hashing
    include-all-providers: true
    filter: '(?i)美|us|united states|america|los angeles|san jose|silicon valley'
    url: http://www.gstatic.com/generate_204
    interval: 300

  #------------------------地区分组------------------------#
  - name: 🇭🇰 香港节点
    type: url-test
    include-all-providers: true
    filter: '(?i)港|hk|hongkong|hong kong'
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  - name: 🇨🇳 台湾节点
    type: url-test
    include-all-providers: true
    filter: '(?i)台|tw|taiwan|taipei'
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  - name: 🇸🇬 狮城节点
    type: url-test
    include-all-providers: true
    filter: '(?i)新|sg|singapore'
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  - name: 🇯🇵 日本节点
    type: url-test
    include-all-providers: true
    filter: '(?i)日|jp|japan|tokyo|osaka'
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  - name: 🇺🇲 美国节点
    type: url-test
    include-all-providers: true
    filter: '(?i)美|us|united states|america|los angeles|san jose|silicon valley'
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  - name: 🇬🇧 英国节点
    type: url-test
    include-all-providers: true
    filter: '(?i)英|uk|united kingdom|london'
    url: http://www.gstatic.com/generate_204
    interval: 300
    tolerance: 100

  #------------------------场景分组------------------------#

  - name: 🎬 国外媒体
    type: select
    proxies:
      - 🚀 节点选择
      - IPLC负载组
      - 香港负载组
      - 台湾负载组
      - 日本负载组
      - 新加坡负载组
      - 🇭🇰 香港节点
      - 🇨🇳 台湾节点
      - 🇯🇵 日本节点
      - 🇺🇲 美国节点
      - 🇸🇬 狮城节点

  - name: 🎮 游戏平台
    type: select
    proxies:
      - 🚀 节点选择
      - 🔯 故障转移
      - 🇭🇰 香港节点
      - 🇯🇵 日本节点
      - 🇺🇲 美国节点
      - 🇸🇬 狮城节点
      - DIRECT

  - name: 📱 即时通讯
    type: select
    proxies:
      - 🚀 节点选择
      - IPLC负载组
      - 香港负载组
      - 台湾负载组
      - 日本负载组
      - 新加坡负载组
      - 🔯 故障转移
      - 🇭🇰 香港节点
      - 🇯🇵 日本节点
      - 🇺🇲 美国节点
      - 🇸🇬 狮城节点

  - name: 🤖 OpenAI
    type: select
    proxies:
      - 🚀 节点选择
      - IPLC负载组
      - 香港负载组
      - 台湾负载组
      - 日本负载组
      - 新加坡负载组
      - 美国负载组
      - 🔯 故障转移

  - name: 🔧 GitHub
    type: select
    proxies:
      - 🚀 节点选择
      - 🔯 故障转移
      - IPLC负载组
      - 香港负载组
      - 台湾负载组
      - 日本负载组
      - 新加坡负载组
      - 美国负载组
      - DIRECT

  - name: Ⓜ️ 微软服务
    type: select
    proxies:
      - 🚀 节点选择
      - 🇭🇰 香港节点
      - 🇨🇳 台湾节点
      - 🇯🇵 日本节点
      - 🇺🇲 美国节点
      - 🇸🇬 狮城节点
      - DIRECT

  - name: 🍎 苹果服务
    type: select
    proxies:
      - 🚀 节点选择
      - 🇭🇰 香港节点
      - 🇨🇳 台湾节点
      - 🇯🇵 日本节点
      - 🇺🇲 美国节点
      - 🇸🇬 狮城节点
      - DIRECT

  - name: ♊ Gemini
    type: select
    proxies:
      - 🚀 节点选择
      - IPLC负载组
      - 香港负载组
      - 台湾负载组
      - 日本负载组
      - 新加坡负载组
      - 美国负载组
      - Tencent
      - DIRECT

  #------------------------特殊分组------------------------#
  - name: 🎯 全球直连
    type: select
    proxies:
      - DIRECT
      - 🚀 节点选择

  - name: 🛑 广告拦截
    type: select
    proxies:
      - REJECT
      - DIRECT

  - name: 🍃 应用净化
    type: select
    proxies:
      - REJECT
      - DIRECT

  - name: 🆎 AdBlock
    type: select
    proxies:
      - REJECT
      - DIRECT

  - name: 🛡️ 隐私防护
    type: select
    proxies:
      - REJECT
      - DIRECT

  - name: 🐟 漏网之鱼
    type: select
    proxies:
      - 🚀 节点选择
      - 🎯 全球直连
      - 🔯 故障转移

# 代理提供商配置
proxy-providers:
  fastlink:
    type: http
    url: 'https://10ncydlf.flsubcn.cc:2096/zvlqjih1t/pn4bmosg1c1bezy8?clash=1&extend=1'
    interval: 21600
    path: ./proxy_providers/fastlink.yaml
    health-check:
      enable: true
      url: http://www.google.com/generate_204
      interval: 1800

# 规则提供商配置 - 优化版
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

  # 隐私规则
  privacy:
    type: http
    behavior: domain
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/Privacy/Privacy.yaml'
    path: ./ruleset/privacy.yaml
    interval: 86400

  # 广告扩展规则
  reject-extra:
    type: http
    behavior: domain
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/AdvertisingLite/AdvertisingLite.yaml'
    path: ./ruleset/reject-extra.yaml
    interval: 86400

  # AI平台规则
  openai:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/OpenAI/OpenAI.yaml'
    path: ./ruleset/openai.yaml
    interval: 86400

  gemini:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/Gemini/Gemini.yaml'
    path: ./ruleset/gemini.yaml
    interval: 86400

  # 流媒体规则
  streaming:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/GlobalMedia/GlobalMedia.yaml'
    path: ./ruleset/streaming.yaml
    interval: 86400

  # 社交通讯规则
  social:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/Telegram/Telegram.yaml'
    path: ./ruleset/social.yaml
    interval: 86400

  # 微软服务规则
  microsoft:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/Microsoft/Microsoft.yaml'
    path: ./ruleset/microsoft.yaml
    interval: 86400

  # 苹果服务规则
  apple:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/Apple/Apple.yaml'
    path: ./ruleset/apple.yaml
    interval: 86400

  # 游戏平台规则
  games:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/Game/Game.yaml'
    path: ./ruleset/games.yaml
    interval: 86400

  # 开发平台规则
  dev-platforms:
    type: http
    behavior: classical
    url: 'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script/rule/Clash/GitHub/GitHub.yaml'
    path: ./ruleset/dev-platforms.yaml
    interval: 86400

# 规则配置 - 优化版
rules:
  # 优先处理
  - RULE-SET,reject,🛑 广告拦截,no-resolve
  - RULE-SET,privacy,🛡️ 隐私防护,no-resolve
  - RULE-SET,reject-extra,🆎 AdBlock,no-resolve

  # 本地局域网
  - DOMAIN-SUFFIX,local,DIRECT
  - DOMAIN-SUFFIX,localhost,DIRECT
  - IP-CIDR,127.0.0.0/8,DIRECT
  - IP-CIDR,172.16.0.0/12,DIRECT
  - IP-CIDR,192.168.0.0/16,DIRECT
  - IP-CIDR,10.0.0.0/8,DIRECT
  - IP-CIDR,17.0.0.0/8,DIRECT
  - IP-CIDR,100.64.0.0/10,DIRECT
  - IP-CIDR,224.0.0.0/4,DIRECT
  - IP-CIDR6,fe80::/10,DIRECT

  # 应用分流
  - RULE-SET,openai,🤖 OpenAI,no-resolve
  - RULE-SET,streaming,🎬 国外媒体,no-resolve
  - RULE-SET,social,📱 即时通讯,no-resolve
  - RULE-SET,microsoft,Ⓜ️ 微软服务,no-resolve
  - RULE-SET,apple,🍎 苹果服务,no-resolve
  - RULE-SET,games,🎮 游戏平台,no-resolve
  - RULE-SET,dev-platforms,🔧 GitHub,no-resolve
  - RULE-SET,gemini,♊ Gemini,no-resolve

  # 自定义规则
  - PROCESS-NAME,clash,DIRECT
  - PROCESS-NAME,v2ray,DIRECT
  - PROCESS-NAME,xray,DIRECT
  - PROCESS-NAME,naive,DIRECT
  - PROCESS-NAME,trojan,DIRECT
  - PROCESS-NAME,trojan-go,DIRECT
  - PROCESS-NAME,ss-local,DIRECT
  - PROCESS-NAME,privoxy,DIRECT
  - PROCESS-NAME,leaf,DIRECT
  - PROCESS-NAME,Thunder,DIRECT
  - PROCESS-NAME,DownloadService,DIRECT
  - PROCESS-NAME,qBittorrent,DIRECT
  - PROCESS-NAME,Transmission,DIRECT
  - PROCESS-NAME,fdm,DIRECT
  - PROCESS-NAME,aria2c,DIRECT
  - PROCESS-NAME,Folx,DIRECT
  - PROCESS-NAME,NetTransport,DIRECT
  - PROCESS-NAME,uTorrent,DIRECT
  - PROCESS-NAME,WebTorrent,DIRECT

  # 地域规则
  - GEOIP,LAN,DIRECT,no-resolve
  - GEOIP,CN,DIRECT,no-resolve

  # 兜底规则
  - MATCH,🚀 节点选择
