-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser
259 lines (229 loc) · 10.1 KB
/
parser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
parsers: # array
# - reg: ^.*$ 匹配所有订阅,或 - url: https://example.com/profile.yaml 指定订阅
- url: 订阅地址
# 删除服务商提供的策略组和规则
code: |
module.exports.parse = (raw, { yaml }) => {
const rawObj = yaml.parse(raw)
const groups = []
const rules = []
return yaml.stringify({ ...rawObj, 'proxy-groups': groups, rules })
}
# 建立自己的配置
yaml:
prepend-proxy-groups: # 建立策略组
- name: 🔯 代理模式
type: select
proxies:
- 绕过大陆丨黑名单(GFWlist) # 黑名单模式,意为「只有命中规则的网络流量,才使用代理」
- 绕过大陆丨白名单(Whitelist) # 白名单模式,意为「没有命中规则的网络流量,统统使用代理」
- name: 🔰 选择节点
type: select
- name: 🛑 广告拦截
type: select
proxies:
- DIRECT
- REJECT
- PROXY
- name: 绕过大陆丨黑名单(GFWlist)
type: url-test
url: http://www.gstatic.com/generate_204
interval: 86400
proxies:
- DIRECT
- name: 绕过大陆丨白名单(Whitelist)
type: url-test
url: http://www.gstatic.com/generate_204
interval: 86400
proxies:
- PROXY
- name: PROXY
type: url-test
url: http://www.gstatic.com/generate_204
interval: 86400
proxies:
- 🔰 选择节点
- name: ♻️ 自动选择
type: url-test
url: http://www.gstatic.com/generate_204
interval: 300
tolerance: 50
#暂时以台湾节点作为 ai 服务的节点
- name: 🤖 OpenAi
type: url-test
url: http://www.gstatic.com/generate_204
interval: 300
tolerance: 50
# 策略组示例
# - name: 分组名
# type: select # 手动选点
# url-test # 自动选择延迟最低的节点
# fallback # 节点故障时自动切换下一个
# laod-balance # 均衡使用分组内的节点
# url: http://www.gstatic.com/generate_204 # 测试地址 非select类型分组必要
# interval: 300 # 自动测试间隔时间,单位秒 非select类型分组必要
# tolerance: 50 # 允许的偏差,节点之间延迟差小于该值不切换 非必要
# proxies:
# - 节点名称或其他分组套娃
commands:
- proxy-groups.🔰 选择节点.proxies=[]proxyNames # 向指定策略组添加订阅中的节点名,可使用正则过滤
- proxy-groups.🔰 选择节点.proxies.0+DIRECT # 向指定分组第一个位置添加一个 DIRECT 节点名
- proxy-groups.♻️ 自动选择.proxies=[]proxyNames|^(?:(?!流量|耗尽).)*$
- proxy-groups.🔰 选择节点.proxies.0+♻️ 自动选择
- proxy-groups.AI节点.proxies=[]proxyNames|TW
# 一些可能用到的正则过滤节点示例,使分组更细致
# []proxyNames|a # 包含a
# []proxyNames|^(.*)(a|b)+(.*)$ # 包含a或b
# []proxyNames|^(?=.*a)(?=.*b).*$ # 包含a和b
# []proxyNames|^((?!b).)*a((?!b).)*$ # 包含a且不包含b
# []proxyNames|^((?!b|c).)*a((?!b|c).)*$ # 包含a且不包含b或c
# 添加规则
prepend-rules: # 规则由上往下遍历,如上面规则已经命中,则不再往下处理
- DOMAIN-SUFFIX,aod.itunes.apple.com,DIRECT
- DOMAIN-SUFFIX,music.apple.com/cn,DIRECT
#AI 域名
- DOMAIN-SUFFIX,openai.com,🤖 OpenAi
- DOMAIN-SUFFIX,pay.openai.com,🤖 OpenAi
- DOMAIN-SUFFIX,chat.openai.com,🤖 OpenAi
- DOMAIN-SUFFIX,challenges.cloudflare.com,🤖 OpenAi
- DOMAIN-SUFFIX,auth0.openai.com,🤖 OpenAi
- DOMAIN-SUFFIX,platform.openai.com,🤖 OpenAi
- DOMAIN-KEYWORD,openai,🤖 OpenAi
- DOMAIN-SUFFIX,auth0.com,🤖 OpenAi
- DOMAIN-SUFFIX,challenges.cloudflare.com,🤖 OpenAi
- DOMAIN-SUFFIX,client-api.arkoselabs.com,🤖 OpenAi
- DOMAIN-SUFFIX,events.statsigapi.net,🤖 OpenAi
- DOMAIN-SUFFIX,featuregates.org,🤖 OpenAi
- DOMAIN-SUFFIX,identrust.com,🤖 OpenAi
- DOMAIN-SUFFIX,intercom.io,🤖 OpenAi
- DOMAIN-SUFFIX,intercomcdn.com,🤖 OpenAi
- DOMAIN-SUFFIX,oaistatic.com,🤖 OpenAi
- DOMAIN-SUFFIX,oaiusercontent.com,🤖 OpenAi
- DOMAIN-SUFFIX,openai.com,🤖 OpenAi
- DOMAIN-SUFFIX,openaiapi-site.azureedge.net,🤖 OpenAi
- DOMAIN-SUFFIX,sentry.io,🤖 OpenAi
- DOMAIN-SUFFIX,stripe.com,🤖 OpenAi
- DOMAIN-SUFFIX,openai.com,🤖 OpenAi
- DOMAIN-SUFFIX,openai.nooc.ink,🤖 OpenAi
- DOMAIN-SUFFIX,AI.com,🤖 OpenAi
- DOMAIN-SUFFIX,cdn.auth0.com,🤖 OpenAi
- DOMAIN-SUFFIX,openaiapi-site.azureedge.net,🤖 OpenAi
- DOMAIN-SUFFIX,opendns.com,🤖 OpenAi
- DOMAIN-SUFFIX,bing.com,🤖 OpenAi
- DOMAIN-SUFFIX,civitai.com,🤖 OpenAi
- DOMAIN,bard.google.com,🤖 OpenAi
- DOMAIN,ai.google.dev,🤖 OpenAi
- DOMAIN,gemini.google.com,🤖 OpenAi
- DOMAIN-SUFFIX,googleapis.com,🤖 OpenAi
- DOMAIN-SUFFIX,sentry.io,🤖 OpenAi
- DOMAIN-SUFFIX,intercom.io,🤖 OpenAi
- DOMAIN-SUFFIX,featuregates.org,🤖 OpenAi
- DOMAIN-SUFFIX,statsigapi.net,🤖 OpenAi
- DOMAIN-SUFFIX,claude.ai,🤖 OpenAi
- DOMAIN-SUFFIX,Anthropic.com,🤖 OpenAi
- DOMAIN-SUFFIX,opera-api.com,🤖 OpenAi
- RULE-SET,applications,DIRECT
- DOMAIN,clash.razord.top,DIRECT
- DOMAIN,yacd.haishan.me,DIRECT
- RULE-SET,private,DIRECT
- RULE-SET,reject,🛑 广告拦截
- RULE-SET,icloud,DIRECT #
- RULE-SET,apple,DIRECT # 这三个为国内可直连地址,如果希望走代理改为PROXY
- RULE-SET,google,DIRECT #
- RULE-SET,tld-not-cn,PROXY
- RULE-SET,gfw,PROXY
- RULE-SET,greatfire,PROXY
- RULE-SET,telegramcidr,PROXY
- RULE-SET,lancidr,DIRECT
- RULE-SET,cncidr,DIRECT
- GEOIP,,DIRECT
- GEOIP,CN,DIRECT
- RULE-SET,direct,DIRECT
- RULE-SET,proxy,🔯 代理模式
- MATCH,🔯 代理模式 # 规则之外的
# 添加规则集
mix-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
icloud: # iCloud 域名列表
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt"
path: ./ruleset/icloud.yaml
interval: 86400
apple: # Apple 在中国大陆可直连的域名列表
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt"
path: ./ruleset/apple.yaml
interval: 86400
google: # Google 在中国大陆可直连的域名列表
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt"
path: ./ruleset/google.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
direct: # 直连域名列表
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt"
path: ./ruleset/direct.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: # GFWList 域名列表
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/gfw.txt"
path: ./ruleset/gfw.yaml
interval: 86400
greatfire: # GreatFire 域名列表
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/greatfire.txt"
path: ./ruleset/greatfire.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: # Telegram 使用的 IP 地址列表
type: http
behavior: ipcidr
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt"
path: ./ruleset/telegramcidr.yaml
interval: 86400
cncidr: # 中国大陆 IP 地址列表
type: http
behavior: ipcidr
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt"
path: ./ruleset/cncidr.yaml
interval: 86400
lancidr: # 局域网 IP 及保留 IP 地址列表
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