[custom] ; HappaConfig:用于生成 Surge 配置的 Subconverter 外部模板 ; DoT 需要 Surge Mac 5.10.2+ / iOS 5.14.5+;ver=4 是转换格式参数。 ; 使用时将本文件地址填入订阅转换工具的 config / 远程配置字段。 ; target=surge&ver=4;订阅链接通过 url 参数传入,文件名可设为 HappaConfig。 ; url 与 config 参数均需进行 URL 编码。 ; 官方格式说明:https://github.com/tindy2013/subconverter/blob/master/base/config/example_external_config.ini ; 基础模板保存通用参数、Host、MITM 参数、脚本与分流变量引用。 surge_rule_base=https://document.happanetwork.com/HappaConfig/HappaConfig.conf ; 完整分流定义见下方 template 节,基础模板按引用顺序展开,保留 Surge 原生语法。 enable_rule_generator=false overwrite_original_rules=false ; 保留订阅原有节点名称和 Emoji,便于地区正则按名称筛选。 add_emoji=false remove_old_emoji=false ; 分组格式:分组名`select`成员;[] 前缀直接引用策略或其他分组。 ; 不带 [] 的成员是节点名称正则;.* 导入此次转换得到的全部节点。 ; select 首位成员为初始默认项;Surge 已保存的手动选择会继续保留。 ; 英文分组名称用于规则引用,说明保持中文。 ; 通用出站入口 custom_proxy_group=Proxy`select`[]All Proxies`[]HK`[]JP`[]SG`[]US`[]TW`[]International`[]DIRECT ; 展示此次转换得到的全部节点 custom_proxy_group=All Proxies`select`.* ; 业务策略组按名称升序排列。 ; Apple 服务,可选直连 custom_proxy_group=Apple`select`[]DIRECT`[]All Proxies`[]HK`[]US`[]JP`[]SG`[]TW`[]International`[]Proxy ; 国内网站与视频服务 custom_proxy_group=China`select`[]DIRECT`[]All Proxies`[]HK`[]TW`[]Proxy ; Claude 服务 custom_proxy_group=Claude`select`[]US`[]All Proxies ; Disney 单独选择出口 custom_proxy_group=Disney`select`[]Proxy`[]All Proxies`[]HK`[]JP`[]TW`[]US`[]SG`[]International ; Emby 流量单独选择出口 custom_proxy_group=Emby`select`[]Proxy`[]All Proxies`[]DIRECT`[]HK`[]JP`[]US`[]SG ; GitHub、GitLab、Google 与其他全球网站 custom_proxy_group=Global`select`[]Proxy`[]All Proxies`[]HK`[]JP`[]US`[]SG`[]TW`[]International ; YouTube、国际社交、TikTok 与其他国际媒体共用此组 custom_proxy_group=Global Media`select`[]Proxy`[]All Proxies`[]HK`[]JP`[]US`[]SG`[]TW`[]International ; Google Voice 单独选择出口 custom_proxy_group=Google Voice`select`[]US`[]All Proxies`[]HK`[]JP`[]SG`[]TW`[]International ; 校园内网默认使用 aTrust 节点组。 custom_proxy_group=Hziee`select`[]aTrust`[]DIRECT`[]Proxy`[]All Proxies ; Netflix 单独选择出口 custom_proxy_group=Netflix`select`[]Proxy`[]All Proxies`[]HK`[]JP`[]TW`[]US`[]SG`[]International ; OpenAI 服务 custom_proxy_group=OpenAI`select`[]Proxy`[]All Proxies`[]US`[]JP ; Siri 基础服务默认直连,Apple Intelligence 默认使用 Proxy。 custom_proxy_group=Siri-Direct`select`[]DIRECT`[]Proxy`[]US`[]All Proxies custom_proxy_group=Siri-Proxy`select`[]Proxy`[]US`[]All Proxies`[]DIRECT ; 测速网站,可选直连或某个代理 custom_proxy_group=SpeedTest`select`[]Proxy`[]All Proxies`[]DIRECT`[]HK`[]JP`[]SG`[]US`[]TW`[]International ; Spotify 音乐流量 custom_proxy_group=Spotify`select`[]Proxy`[]All Proxies`[]HK`[]JP`[]TW`[]US`[]SG`[]International ; 保留独立 TikTok 选项供手动引用。 custom_proxy_group=TikTok`select`[]Proxy`[]All Proxies`[]JP`[]TW`[]HK`[]US`[]SG`[]International ; 未命中前面规则的兜底组 custom_proxy_group=Final`select`[]Proxy`[]All Proxies`[]DIRECT`[]HK ; 地区归类沿用原配置的节点名称筛选,名称变化会影响匹配结果。 ; 某组无匹配节点时,Subconverter 会使用 DIRECT 作为该组的内容。 ; 按节点名称包含 aTrust 筛选,不区分大小写。 custom_proxy_group=aTrust`select`(?i)atrust custom_proxy_group=HK`select`(?=.*(港|HK|🇭🇰|(?i)Hong))^((?!(WARP|台|日|韩|新|美)).)*$ custom_proxy_group=JP`select`(?=.*(日|JP|🇯🇵|(?i)Japan))^((?!(WARP|港|台|韩|新|狮|美|利亚)).)*$ custom_proxy_group=TW`select`(?=.*(台|TW|(?i)Taiwan))^((?!(WARP|港|日|韩|新|美)).)*$ custom_proxy_group=SG`select`(?=.*(新|狮|獅|SG|🇸🇬|(?i)Singapore))^((?!(WARP|港|台|日|韩|美)).)*$ custom_proxy_group=US`select`(?=.*(美|US|🇺🇸|(?i)States|American))^((?!(WARP|港|台|日|韩|新)).)*$ ; 名称不含下方排除标记的其他国际节点 custom_proxy_group=International`select`(?=.*)^((?!(WARP|港|HK|日|JP|台|TW|新|SG|美|US|🇨🇳|🇭🇰|🇺🇸|🇯🇵|🏳️‍🌈|🇸🇬)).)*$ [template] ; DNS 参数在本节定义,基础模板的 General 节引用。 ; 常规 DNS 仅用于连通性测试;DoT 使用 IP 端点,无需明文解析端点域名。 dns_server=dns-server = 1.1.1.1, 1.0.0.1 encrypted_dns_server=encrypted-dns-server = tls://1.1.1.1, tls://1.0.0.1 encrypted_dns_follow_outbound=encrypted-dns-follow-outbound-mode = true encrypted_dns_verify=encrypted-dns-skip-cert-verification = false ; 增强模式 / iOS VPN 接管应用发送到53端口的 DNS 请求。 dns_hijack=hijack-dns = *:53 ; 超星课程静态资源使用阿里 DoH,避免 CDN 解析到当前直连不可用的节点。 chaoxing_dns_host=mooc-res2.chaoxing.com = server:https://dns.alidns.com/dns-query ; DoT 优先使用 All Proxies;请选择海外节点,代理服务器使用 IP 可避免解析循环触发直连回退。 ; 代理请求的目标域名通常由代理服务器解析,出口 DNS 也取决于节点服务商。 ; 参考:https://manual.nssurge.com/dns/encrypted-dns.html dot_rule=PROTOCOL,DOT,All Proxies ; 全部80条分流规则在本节定义,基础模板只引用变量。 ; 规则模式下自上而下匹配,首条命中决定策略;调整顺序会改变分流结果。 ; RULE-SET 引用外部规则集合;DOMAIN-SET 引用域名集合;行末是目标策略或策略组。 ; 参考:https://manual.nssurge.com/rules/overview.html ; 逻辑规则:拒绝目标端口为443的 UDP 请求(常用于 QUIC / HTTP/3)。 ; REJECT-NO-DROP 避免常规 REJECT 因频繁命中自动升级为静默丢弃。 udp_443_rule=AND,((PROTOCOL,UDP), (DEST-PORT,443)),REJECT-NO-DROP ; 拦截 STUN;Mac 需开启增强模式,可能影响语音和视频通话,无法保证完全禁用 WebRTC。 stun_rule=PROTOCOL,STUN,REJECT ; 通用拦截优先于服务分流,保留扩展匹配。 reject_no_drop_rule=RULE-SET,https://ruleset.skk.moe/List/non_ip/reject-no-drop.conf,REJECT-NO-DROP,extended-matching reject_drop_rule=RULE-SET,https://ruleset.skk.moe/List/non_ip/reject-drop.conf,REJECT-DROP,extended-matching ; 抖音使用 China,与 TikTok 分别分流。 douyin_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/DouYin/DouYin.list,China ; 校园内网规则优先于局域网和国内直连。 hziee_rule=RULE-SET,https://raw.githubusercontent.com/OyamaMeek/Document/refs/heads/main/HappaConfig/Hziee.list,Hziee ; 微信与腾讯 ; User-Agent 仅在 Surge 能读取对应 HTTP 请求头时匹配,不保证覆盖全部 HTTPS。 wechat_ua_messenger_rule=USER-AGENT,MicroMessenger%20Client,DIRECT wechat_ua_desktop_rule=USER-AGENT,WeChat*,DIRECT wechat_ua_work_rule=USER-AGENT,%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1*,DIRECT ; 腾讯域名及子域直连,顺序沿用 260810.conf 上游中国规则的腾讯段。 tencent_gtimg_rule=DOMAIN-SUFFIX,gtimg.com,DIRECT tencent_idqqimg_rule=DOMAIN-SUFFIX,idqqimg.com,DIRECT tencent_igamecj_rule=DOMAIN-SUFFIX,igamecj.com,DIRECT tencent_myapp_rule=DOMAIN-SUFFIX,myapp.com,DIRECT tencent_myqcloud_rule=DOMAIN-SUFFIX,myqcloud.com,DIRECT tencent_qq_rule=DOMAIN-SUFFIX,qq.com,DIRECT tencent_qqmail_rule=DOMAIN-SUFFIX,qqmail.com,DIRECT tencent_servicewechat_rule=DOMAIN-SUFFIX,servicewechat.com,DIRECT tencent_domain_rule=DOMAIN-SUFFIX,tencent.com,DIRECT tencent_cloud_rule=DOMAIN-SUFFIX,tencent-cloud.net,DIRECT tencent_tenpay_rule=DOMAIN-SUFFIX,tenpay.com,DIRECT wechat_domain_rule=DOMAIN-SUFFIX,wechat.com,DIRECT tencent_akamai_rule=DOMAIN,file-igamecj.akamaized.net,DIRECT ; 微信进程(仅 Mac)及图片域名:目标 IP 属于中国时直连,其他请求进入 Final。 ; IPv4 与 IPv6 使用相同判断;Final 使用客户端当前所选出口。 wechat_cn_rule=AND,((OR,((PROCESS-NAME,WeChat),(DOMAIN-SUFFIX,qpic.cn),(DOMAIN-SUFFIX,qlogo.cn))),(GEOIP,CN)),DIRECT wechat_final_rule=OR,((PROCESS-NAME,WeChat),(DOMAIN-SUFFIX,qpic.cn),(DOMAIN-SUFFIX,qlogo.cn)),Final ; 指定 IPv4 网段直连;/24 覆盖 23.247.129.0 至 23.247.129.255。 ip_direct_rule=IP-CIDR,23.247.129.1/24,DIRECT ; 去广告示例(未启用);基础模板没有对应引用。 ; adblock_rule=RULE-SET,http://script.hub/file/_start_/https://raw.githubusercontent.com/RuCu6/QuanX/main/Rules/MyBlockAds.list/_end_/qx_RuCu6_MyBlockAds.list?type=rule-set&target=surge-rule-set&x=mall.bilibili.com%2Bpassport.bilibili.com&del=true&nore=true&sni=httpdns%2B163,REJECT ; 小米优先直连;后面的同源小米规则不会覆盖已命中的请求。 xiaomi_direct_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/XiaoMi/XiaoMi_Resolve.list,DIRECT ; Emby emby_rule=RULE-SET,https://raw.githubusercontent.com/Softlyx/Clash/main/rule/Emby.list,Emby ; Google Voice google_voice_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/GoogleVoice/GoogleVoice.list,Google Voice ; OpenAI openai_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/OpenAI/OpenAI.list,OpenAI claude_rule=RULE-SET,https://document.happanetwork.com/HappaConfig/Claude.list,Claude ; Netflix netflix_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Netflix/Netflix_Resolve.list,Netflix ; SpeedTest speedtest_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Speedtest/Speedtest.list,SpeedTest ; 黑料不打烊 hlbdy_rule=RULE-SET,https://raw.githubusercontent.com/Softlyx/Surge/main/rule/HLbdy.list,Global ; 国际社交 Telegram telegram_asn_rule=RULE-SET,https://raw.githubusercontent.com/VirgilClyne/GetSomeFries/main/ruleset/ASN.Telegram.list,Global Media telegram_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Telegram/Telegram_Resolve.list,Global Media ; Twitter twitter_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Twitter/Twitter_Resolve.list,Global Media ; WhatsApp whatsapp_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Whatsapp/Whatsapp_Resolve.list,Global Media ; TikTok tiktok_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/TikTok/TikTok.list,Global Media ; Spotify spotify_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Spotify/Spotify_Resolve.list,Spotify ; 国际媒体 Disney disney_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Disney/Disney.list,Disney ; YouTube youtube_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/YouTube/YouTube_Resolve.list,Global Media ; 其他国际媒体与域名集合共用 Global Media 策略组。 global_media_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/GlobalMedia/GlobalMedia_Resolve.list,Global Media global_media_domain_rule=DOMAIN-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/GlobalMedia/GlobalMedia_Domain.list,Global Media ; 全球加速 github_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/GitHub/GitHub.list,Global gitlab_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/GitLab/GitLab.list,Global global_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Global/Global_Resolve.list,Global global_domain_rule=DOMAIN-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Global/Global_Domain.list,Global ; Google google_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Google/Google_Resolve.list,Global ; Apple:应用商店、开发者、固件、账号、邮件、媒体等规则共用 Apple 策略组。 siri_direct_rule=RULE-SET,https://raw.githubusercontent.com/OyamaMeek/Document/refs/heads/main/HappaConfig/Siri-Direct.list,Siri-Direct siri_proxy_rule=RULE-SET,https://raw.githubusercontent.com/OyamaMeek/Document/refs/heads/main/HappaConfig/Siri-Proxy.list,Siri-Proxy ; 修正规则位于 Siri-Proxy 之后,其余命中流量使用 China。 corrects_rule=RULE-SET,https://raw.githubusercontent.com/Softlyx/Surge/main/rule/Corrects.list,China appstore_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppStore/AppStore.list,Apple apple_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Apple/Apple_Resolve.list,Apple apple_domain_rule=DOMAIN-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Apple/Apple_Domain.list,Apple apple_daily_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleDaily/AppleDaily.list,Apple apple_dev_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleDev/AppleDev.list,Apple apple_firmware_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleFirmware/AppleFirmware.list,Apple apple_hardware_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleHardware/AppleHardware.list,Apple apple_id_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleID/AppleID.list,Apple apple_mail_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleMail/AppleMail.list,Apple apple_media_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleMedia/AppleMedia.list,Apple apple_music_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleMusic/AppleMusic.list,Apple apple_news_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleNews/AppleNews.list,Apple apple_proxy_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleProxy/AppleProxy.list,Apple apple_tv_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/AppleTV/AppleTV.list,Apple ; 全球通用列表位于 Siri、Apple 等专用规则之后。 global_all_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Global/Global_All_No_Resolve.list,Global ; 国内服务 china_media_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/ChinaMedia/ChinaMedia_Resolve.list,China china_asn_resolve_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/ChinaASN/ChinaASN_Resolve.list,China ; 新增 China 策略优先于后面的原 Lan DIRECT 规则。 lan_china_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Lan/Lan.list,China china_max_no_ip_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/ChinaMaxNoIP/ChinaMaxNoIP_All_No_Resolve.list,China ; 保留原国内网站、自定义规则与小米服务。 china_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/China/China_Resolve.list,China china_domain_rule=DOMAIN-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/China/China_Domain.list,China china_happa_rule=RULE-SET,https://document.happanetwork.com/HappaConfig/China.list,China china_asn_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/ChinaASN/ChinaASN.list,China xiaomi_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/XiaoMi/XiaoMi_Resolve.list,China ; 保留原局域网规则。 lan_rule=RULE-SET,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Surge/Lan/Lan.list,DIRECT ; 中国 IP 特定列表优先交给 HK,随后 GEOIP 判为 CN 的其余请求直连。 china_ip_rule=RULE-SET,https://raw.githubusercontent.com/Softlyx/Surge/main/rule/ChinaIP,HK geoip_cn_rule=GEOIP,CN,DIRECT ; 其余请求与 IP 规则判断中的 DNS 失败进入 Final;选择直连时,无法解析的域名仍可能连接失败。 final_rule=FINAL,Final,dns-failed