Last active
March 15, 2025 03:31
-
-
Save yanyongyu/76cf3a4a094fc07c89b682c4c8604a57 to your computer and use it in GitHub Desktop.
Clash For Windows parser for replacing rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parsers: | |
- reg: ^https://.+$ | |
code: | | |
const presetProfile = ` | |
mode: rule | |
log-level: info | |
mixed-port: 7890 | |
allow-lan: false | |
external-controller: :9090 | |
proxy-groups: | |
- name: π§ 樑εΌεζ’ | |
type: select | |
proxies: | |
- π θηΉιζ© | |
- DIRECT | |
_index: 0 | |
- name: π θηΉιζ© | |
type: select | |
proxies: [] | |
- name: π― ε ¨ηη΄θΏ | |
type: select | |
proxies: | |
- DIRECT | |
- π§ 樑εΌεζ’ | |
- name: π ε ¨ηζ¦ζͺ | |
type: select | |
proxies: | |
- REJECT | |
- DIRECT | |
- π§ 樑εΌεζ’ | |
- name: π ζΌη½δΉι±Ό | |
type: select | |
proxies: | |
- π§ 樑εΌεζ’ | |
- DIRECT | |
rule-providers: | |
direct: | |
type: http | |
behavior: domain | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt" | |
path: ./ruleset/direct.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 | |
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 | |
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 | |
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: | |
# DIRECT | |
- DOMAIN,clash.razord.top,π― ε ¨ηη΄θΏ | |
- DOMAIN,yacd.haishan.me,π― ε ¨ηη΄θΏ | |
# PROXY | |
- DOMAIN,services.googleapis.cn,π§ 樑εΌεζ’ # Google Play Store | |
# DEFAULT | |
- RULE-SET,applications,π― ε ¨ηη΄θΏ | |
- RULE-SET,private,π― ε ¨ηη΄θΏ | |
- RULE-SET,reject,π ε ¨ηζ¦ζͺ | |
- RULE-SET,icloud,π― ε ¨ηη΄θΏ | |
- RULE-SET,apple,π― ε ¨ηη΄θΏ | |
- RULE-SET,google,π― ε ¨ηη΄θΏ | |
- RULE-SET,proxy,π§ 樑εΌεζ’ | |
- RULE-SET,direct,π― ε ¨ηη΄θΏ | |
- RULE-SET,lancidr,π― ε ¨ηη΄θΏ | |
- RULE-SET,cncidr,π― ε ¨ηη΄θΏ | |
- RULE-SET,telegramcidr,π§ 樑εΌεζ’ | |
- GEOIP,LAN,π― ε ¨ηη΄θΏ | |
- GEOIP,CN,π― ε ¨ηη΄θΏ | |
- MATCH,π ζΌη½δΉι±Ό | |
dns: | |
enable: true | |
listen: 0.0.0.0:1053 | |
use-hosts: true | |
enhanced-mode: fake-ip | |
default-nameserver: | |
- 223.6.6.6 | |
- 8.8.8.8 | |
- 1.1.1.1 | |
- 114.114.115.115 | |
- 114.114.114.114 | |
nameserver: | |
- https://dns.adguard-dns.com/dns-query | |
- https://doh.pub/dns-query | |
- https://dns.alidns.com/dns-query | |
fallback: | |
- https://dns64.dns.google/dns-query | |
- https://adg.geili.me/dns-query | |
- https://sunnygyl.com/dns-query | |
- tls://8.8.4.4 | |
- tls://1.1.1.1 | |
fallback-filter: | |
geoip: true | |
geoip-code: CN | |
geosite: | |
- gfw | |
ipcidr: | |
- 240.0.0.0/4 | |
domain: | |
- '+.google.com' | |
- '+.facebook.com' | |
- '+.youtube.com' | |
fake-ip-range: 198.18.0.1/16 | |
fake-ip-filter: | |
- "*.lan" | |
- "*.linksys.com" | |
- "*.linksyssmartwifi.com" | |
- swscan.apple.com | |
- mesu.apple.com | |
- "*.msftconnecttest.com" | |
- "*.msftncsi.com" | |
- time.*.com | |
- time.*.gov | |
- time.*.edu.cn | |
- time.*.apple.com | |
- time1.*.com | |
- time2.*.com | |
- time3.*.com | |
- time4.*.com | |
- time5.*.com | |
- time6.*.com | |
- time7.*.com | |
- ntp.*.com | |
- ntp1.*.com | |
- ntp2.*.com | |
- ntp3.*.com | |
- ntp4.*.com | |
- ntp5.*.com | |
- ntp6.*.com | |
- ntp7.*.com | |
- "*.time.edu.cn" | |
- "*.ntp.org.cn" | |
- +.pool.ntp.org | |
- time1.cloud.tencent.com | |
- +.srv.nintendo.net | |
- +.stun.playstation.net | |
- xbox.*.microsoft.com | |
- +.xboxlive.com | |
- localhost.ptlogin2.qq.com | |
- +.stun.*.* | |
- +.stun.*.*.* | |
- +.stun.*.*.*.* | |
- +.stun.*.*.*.*.* | |
- WORKGROUP | |
- controlplane.tailscale.com | |
- log.tailscale.i | |
`; | |
module.exports.parse = async (raw, { yaml }) => { | |
const preset = yaml.parse(presetProfile); | |
const profile = yaml.parse(raw); | |
const proxies = profile.proxies; | |
const proxyNames = proxies.map((proxy) => proxy.name); | |
preset["proxies"] = proxies; | |
preset["proxy-groups"] = preset["proxy-groups"].map((group) => | |
group.name === "π θηΉιζ©" ? { ...group, proxies: proxyNames } : group | |
); | |
return yaml.stringify(preset); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment