-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalScript.js
852 lines (838 loc) · 27.9 KB
/
GlobalScript.js
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
const customRules = [
// 在此添加自定义代理规则。
// 例如:
//"DOMAIN-SUFFIX,gstatic.com,节点选择",
];
// 默认测试网址
const test_url = "http://www.google.com/generate_204";
// 测试网址检测间隔
const test_interval = 240;
// 测试网址的间隔差值,超过这个差值就会切换节点,越小切换越频繁
const test_tolerance = 80;
// 国内DNS服务器,只写最快的一个,写多了会导致访问速度变慢和内核内存占用变大
const domesticNameservers = [
"tls://223.5.5.5", // 阿里云公共DNS
];
// 国外DNS服务器,同上
const foreignNameservers = [
"tls://dns.opendns.com", // OpenDNS
];
// 规则集通用配置
const ruleProviderCommon = {
type: "http",
format: "mrs",
interval: 86400,
};
// 代理组通用配置
const groupBaseOption = {
"interval": 300,
"timeout": 3000,
"url": test_url,
"lazy": true,
"hidden": false,
"disable-udp": false,
};
// 代理规则
const rules = [
// 自定义规则
...customRules,
// 规则集
"RULE-SET,ipdirect,全局直连,no-resolve",
"RULE-SET,ipprivate,全局直连,no-resolve",
"RULE-SET,telegramcidr,电报消息,no-resolve",
"RULE-SET,direct,全局直连",
"RULE-SET,private,全局直连",
"RULE-SET,google,谷歌服务",
"RULE-SET,apple,苹果服务",
"RULE-SET,bing,Bing",
"RULE-SET,github,Github",
"RULE-SET,onedrive,Onedrive",
"RULE-SET,microsoft,微软服务",
"RULE-SET,ai,AI",
"RULE-SET,youtube,YouTube",
"RULE-SET,netflix_ip,Netflix",
"RULE-SET,netflix_site,Netflix",
"RULE-SET,tiktok,TikTok",
"RULE-SET,adobe,Adobe",
"RULE-SET,pornhub,Pornhub",
"RULE-SET,spotify,Spotify",
"RULE-SET,games,游戏服务",
"RULE-SET,speedtest,网速测试",
"RULE-SET,bilibili,Bilibili",
"RULE-SET,proxy,节点选择",
"RULE-SET,gfw,节点选择",
"RULE-SET,tld-not-cn,节点选择",
// 未匹配的规则
"MATCH,漏网之鱼",
];
// 规则集配置
const ruleProviders = {
ipdirect: {
...ruleProviderCommon,
behavior: "ipcidr",
url: "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geoip/cn.mrs",
path: "./ruleset/cncidr.mrs",
},
ipprivate: {
...ruleProviderCommon,
behavior: "ipcidr",
url: "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geoip/private.mrs",
path: "./ruleset/lancidr.mrs",
},
direct: {
...ruleProviderCommon,
behavior: "domain",
url: "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geosite/cn.mrs",
path: "./ruleset/direct.mrs",
},
private: {
...ruleProviderCommon,
behavior: "domain",
url: "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geosite/private.mrs",
path: "./ruleset/private.mrs",
},
google: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/google.mrs",
path: "./ruleset/google.mrs",
},
microsoft: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/microsoft.mrs",
path: "./ruleset/microsoft.mrs",
},
apple: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/apple.mrs",
path: "./ruleset/apple.mrs",
},
bing: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/bing.mrs",
path: "./ruleset/bing.mrs",
},
github: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/github.mrs",
path: "./ruleset/github.mrs",
},
onedrive: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/onedrive.mrs",
path: "./ruleset/onedrive.mrs",
},
youtube: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/youtube.mrs",
path: "./ruleset/youtube.mrs",
},
pornhub: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/pornhub.mrs",
path: "./ruleset/pornhub.mrs",
},
netflix_ip: {
...ruleProviderCommon,
behavior: "ipcidr",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geoip/netflix.mrs",
path: "./ruleset/netflix-ip.mrs",
},
netflix_site: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/netflix.mrs",
path: "./ruleset/netflix-site.mrs",
},
adobe: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/adobe.mrs",
path: "./ruleset/adobe.mrs",
},
ai: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/DustinWin/ruleset_geodata/releases/download/mihomo-ruleset/ai.mrs",
path: "./ruleset/ai.mrs",
},
bilibili: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/bilibili.mrs",
path: "./ruleset/bilibili.mrs",
},
tiktok: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/tiktok.mrs",
path: "./ruleset/tiktok.mrs",
},
spotify: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/spotify.mrs",
path: "./ruleset/spotify.mrs",
},
speedtest: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/speedtest.mrs",
path: "./ruleset/speedtest.mrs",
},
games: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/DustinWin/ruleset_geodata/releases/download/mihomo-ruleset/games-cn.mrs",
path: "./ruleset/games.mrs",
},
telegramcidr: {
...ruleProviderCommon,
behavior: "ipcidr",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geoip/telegram.mrs",
path: "./ruleset/telegramcidr.mrs",
},
proxy: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo-lite/geosite/proxy.mrs",
path: "./rulesets/loyalsoldier/proxy.mrs",
},
gfw: {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/gfw.mrs",
path: "./ruleset/gfw.mrs",
},
"tld-not-cn": {
...ruleProviderCommon,
behavior: "domain",
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/tld-!cn.mrs",
path: "./ruleset/tld-not-cn.mrs",
},
};
// 地区配置
const regionConfig = [
{
name: "🇺🇸 美国 📶",
matcher: "美国|🇺🇸|US|United States|America",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/us.svg"
},
{
name: "🇯🇵 日本 📶",
matcher: "日本|🇯🇵|JP|Japan",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/jp.svg"
},
{
name: "🇰🇷 韩国 📶",
matcher: "韩|🇰🇷|kr|korea",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/kr.svg"
},
{
name: "🇸🇬 新加坡 📶",
matcher: "新加坡|🇸🇬|SG|狮城|Singapore",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/sg.svg"
},
{
name: "🇭🇰 香港 📶",
matcher: "香港|🇭🇰|HK|Hong Kong|HongKong",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/hk.svg"
},
{
name: "🇹🇼 台湾 📶",
matcher: "台湾|🇹🇼|tw|taiwan|tai wan",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/tw.svg"
},
{
name: "🇬🇧 英国 📶",
matcher: "英|🇬🇧|uk|united kingdom|great britain",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/gb.svg"
},
{
name: "🇫🇷 法国 📶",
matcher: "法国|🇫🇷|FR|France",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/fr.svg"
},
{
name: "🇩🇪 德国 📶",
matcher: "德国|🇩🇪|DE|germany",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/de.svg"
},
{
name: "🇵🇱 波兰 📶",
matcher: "波兰|🇵🇱|Poland|PL|Poland",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/pl.svg"
},
{
name: "🇳🇱 荷兰 📶",
matcher: "荷兰|🇳🇱|NL|Netherlands",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/nl.svg"
},
{
name: "🇮🇪 爱尔兰 📶",
matcher: "爱尔兰|🇮🇪|IE|Ireland",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/ie.svg"
},
{
name: "🇸🇪 瑞典 📶",
matcher: "瑞典|🇸🇪|SE|Sweden",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/se.svg"
},
{
name: "🇷🇺 俄罗斯 📶",
matcher: "俄罗斯|🇷🇺|RU|Russia",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/ru.svg"
},
{
name: "🇮🇹 意大利 📶",
matcher: "意大利|🇮🇹|IT|Italy",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/it.svg"
},
{
name: "🇪🇸 西班牙 📶",
matcher: "西班牙|🇪🇸|ES|Spain",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/es.svg"
},
{
name: "🇵🇹 葡萄牙 📶",
matcher: "葡萄牙|🇵🇹|PT|Portugal",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/pt.svg"
},
{
name: "🇹🇷 土耳其 📶",
matcher: "土耳其|🇹🇷|TR|Turkey",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/tr.svg"
},
{
name: "🇦🇷 阿根廷 📶",
matcher: "阿根廷|🇦🇷|AR|Argentina",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/ar.svg"
},
{
name: "🇨🇦 加拿大 📶",
matcher: "加拿大|🇨🇦|CA|Canada",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/ca.svg"
},
{
name: "🇦🇺 澳大利亚 📶",
matcher: "澳大利亚|🇦🇺|AU|Australia",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/au.svg"
},
{
name: "🇮🇷 伊朗 📶",
matcher: "伊朗|🇮🇷|IR|Iran",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/ir.svg"
},
{
name: "🇮🇩 印度尼西 📶",
matcher: "印度尼西亚|印尼|🇮🇩|ID|Indonesia",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/id.svg"
},
{
name: "🇲🇾 马来西亚 📶",
matcher: "马来|🇲🇾|MY|Malaysia",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/my.svg"
},
{
name: "🇵🇭 菲律宾 📶",
matcher: "菲律宾|🇵🇭|PH|Philippines",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/ph.svg"
},
{
name: "🇮🇳 印度 📶",
matcher: "印度|🇮🇳|IN|India",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/in.svg"
},
{
name: "🇻🇳 越南 📶",
matcher: "越南|🇻🇳|VN|Vietnam",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/vn.svg"
},
{
name: "🇹🇭 泰国 📶",
matcher: "泰国|🇹🇭|TH|Thailand",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/th.svg"
},
{
name: "🇨🇳 中国 📶",
matcher: "中国|🇨🇳|CN|cn|china",
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/cn.svg"
},
{
name: "🌐 其他 📶",
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Global.png"
}
];
// 显示节点配置
const proxyGroups = [
{
...groupBaseOption,
name: "节点选择",
type: "select",
proxies: ["延迟选优", "手动选择", "故障转移", "负载均衡(散列)", "负载均衡(轮询)"],
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Airport.png",
},
{
...groupBaseOption,
name: "手动选择",
type: "select",
"include-all": true,
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/adjust.svg",
},
{
...groupBaseOption,
name: "漏网之鱼",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/fish.svg",
},
{
...groupBaseOption,
name: "Bing",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://www.bing.com/favicon.ico",
},
{
...groupBaseOption,
name: "Github",
type: "select",
proxies: [
"节点选择",
"手动选择",
"全局直连",
"延迟选优",
"故障转移",
],
icon: "https://www.clashverge.dev/assets/icons/github.svg",
},
{
...groupBaseOption,
name: "谷歌服务",
type: "select",
proxies: [
"节点选择",
"手动选择",
"全局直连",
"延迟选优",
"故障转移",
],
icon: "https://www.clashverge.dev/assets/icons/google.svg",
},
{
...groupBaseOption,
name: "苹果服务",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://www.clashverge.dev/assets/icons/apple.svg",
},
{
...groupBaseOption,
name: "微软服务",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/microsoft.svg",
},
{
...groupBaseOption,
name: "Onedrive",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/OneDrive.png",
},
{
...groupBaseOption,
name: "AI",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://www.clashverge.dev/assets/icons/chatgpt.svg",
},
{
...groupBaseOption,
name: "Bilibili",
type: "select",
proxies: [
"全局直连",
],
icon: "https://fastly.jsdelivr.net/gh/Orz-3/mini@master/Color/Bili.png",
},
{
...groupBaseOption,
name: "YouTube",
type: "select",
proxies: [
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/youtube.svg",
},
{
...groupBaseOption,
name: "Netflix",
type: "select",
proxies: [
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://www.clashverge.dev/assets/icons/netflix.svg",
},
{
...groupBaseOption,
name: "TikTok",
type: "select",
proxies: [
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/shindgewongxj/WHATSINStash@master/icon/tiktok.png",
},
{
...groupBaseOption,
name: "Pornhub",
type: "select",
proxies: [
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Pornhub_1.png",
},
{
...groupBaseOption,
name: "Spotify",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Spotify.png",
},
{
...groupBaseOption,
name: "Adobe",
type: "select",
proxies: [
"全局直连",
"REJECT",
"节点选择",
],
icon: "https://www.adobe.com/favicon.ico",
},
{
...groupBaseOption,
name: "游戏服务",
type: "select",
proxies: [
"全局直连",
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://www.clashverge.dev/assets/icons/steam.svg",
},
{
...groupBaseOption,
name: "电报消息",
type: "select",
proxies: [
"节点选择",
"手动选择",
"延迟选优",
"故障转移",
],
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/telegram.svg",
},
{
...groupBaseOption,
name: "网速测试",
type: "select",
proxies: ["全局直连",],
"include-all": true,
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/Speedtest.png",
},
{
...groupBaseOption,
name: "负载均衡(轮询)",
type: "load-balance",
strategy: "round-robin",
"include-all": true,
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/balance.svg",
},
{
...groupBaseOption,
name: "负载均衡(散列)",
type: "load-balance",
strategy: "consistent-hashing",
"include-all": true,
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/merry_go.svg",
},
{
...groupBaseOption,
name: "故障转移",
type: "fallback",
"include-all": true,
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/ambulance.svg",
},
{
...groupBaseOption,
name: "全局直连",
type: "select",
proxies: [
"DIRECT",
"REJECT",
"节点选择",
"手动选择",
],
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/link.svg",
},
{
...groupBaseOption,
name: "延迟选优",
type: "url-test",
interval: test_interval,
tolerance: test_tolerance,
"include-all": true,
icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/speed.svg",
},
];
// DNS配置
const dnsConfig = {
"enable": true,
"ipv6": true,
"prefer-h3": false,
"use-hosts": false,
"use-system-hosts": true,
"listen": "0.0.0.0:1053",
"cache-algorithm": "arc",
"enhanced-mode": "fake-ip",
"fake-ip-range": "198.18.0.1/16",
"fake-ip-filter-mode": "blacklist",
"fake-ip-filter": [
"+.lan",
"+.local",
"+.msftconnecttest.com",
"+.msftncsi.com",
"localhost.ptlogin2.qq.com",
"localhost.sec.qq.com",
"localhost.work.weixin.qq.com",
"*.localdomain",
"*.example",
"*.invalid",
"*.localhost",
"*.test",
"*.local",
"*.home.arpa"
],
"nameserver": [...domesticNameservers],
"proxy-server-nameserver": [...foreignNameservers, ...domesticNameservers],
"nameserver-policy": {},
};
// 域名嗅探
const snifferConfig = {
"enable": true,
"force-dns-mapping": true,
"parse-pure-ip": true,
"override-destination": true,
"sniff": {
"TLS": {
"ports": [443, 8443],
},
"HTTP": {
"ports": [80, "8080-8880"],
"override-destination": true,
},
"QUIC": {
"ports": [443, 8443]
},
}
};
// 添加地区分组
function addRegions(config) {
let regions = [];
if (!config.proxies) {
if (!config["proxy-providers"]) return;
const providers = Object.keys(config["proxy-providers"]);
if (providers.length === 0) return;
let exclude = "";
for (const region of regionConfig) {
if (!region.name) continue;
if (region.matcher) {
exclude += (exclude === "" ? region.matcher : `|${region.matcher}`)
config["proxy-groups"].push({
...groupBaseOption,
name: region.name,
type: "url-test",
interval: test_interval,
tolerance: test_tolerance,
use: providers,
filter: region.matcher,
icon: region.icon,
});
} else {
config["proxy-groups"].push({
...groupBaseOption,
name: region.name,
type: "url-test",
use: providers,
interval: test_interval,
tolerance: test_tolerance,
"exclude-filter": exclude,
icon: region.icon,
});
}
regions.push(region.name)
}
} else {
let names = config.proxies.map(p => p.name).filter(Boolean);
if (names.length === 0) return;
for (const region of regionConfig) {
let proxies = [], noproxies = [];
if (!region.matcher) {
proxies = [...names];
noproxies = [];
} else {
const matches = region.matcher.split("|");
if (matches.length === 0) continue;
const result = names.reduce((acc, name) => {
(matches.some(m => name.includes(m)) ? acc.proxies : acc.noproxies).push(name);
return acc;
}, { proxies: [], noproxies: [] });
proxies = result.proxies;
noproxies = result.noproxies;
}
if (proxies.length === 0) continue;
config["proxy-groups"].push({
...groupBaseOption,
name: region.name,
type: "url-test",
interval: test_interval,
tolerance: test_tolerance,
proxies: proxies,
icon: region.icon,
});
regions.push(region.name);
if (noproxies.length === 0) break;
names = noproxies;
}
}
if (regions.length === 0) return;
const entries = config["proxy-groups"];
for (const entry of entries) {
if (!entry || !entry.proxies) continue;
if (entry.name === "节点选择") {
if (entry.proxies.length > 1) {
entry.proxies.splice(2, 0, "地区选择");
}
} else if (entry.name === "全局直连") {
entry.proxies.push("地区选择");
} else if (entry.type === "select" && !entry.hasOwnProperty("include-all")) {
entry.proxies.push(...regions)
}
}
if (entries.length > 0) {
entries.splice(1, 0, {
...groupBaseOption,
name: "地区选择",
type: "select",
proxies: regions,
icon: "https://fastly.jsdelivr.net/gh/Koolson/Qure@master/IconSet/Color/World_Map.png",
})
}
config["proxy-groups"] = entries;
}
// 主函数
function main(config) {
const proxyCount = config?.proxies?.length ?? 0;
const proxyProviderCount =
typeof config?.["proxy-providers"] === "object"
? Object.keys(config["proxy-providers"]).length
: 0;
if (proxyCount === 0 && proxyProviderCount === 0) {
throw new Error("配置文件中未找到任何代理");
}
// 配置
config["profile"] = {
"store-selected": true,
"store-fake-ip": true,
};
// Geo设置
config["geodata-loader"] = "standard";
config["geosite-matcher"] = "mph";
// 全局客户端指纹
config["global-client-fingerprint"] = "chrome";
config["global-ua"] = "chrome";
// 统一延迟
config["unified-delay"] = true;
// TCP 并发
config["tcp-concurrent"] = true;
// 域名服务
config["foreign_nameservers"] = foreignNameservers;
config["domestic_nameservers"] = domesticNameservers;
// DNS配置
config["dns"] = dnsConfig;
// 域名嗅探
config["sniffer"] = snifferConfig;
// 规则
config["rule-providers"] = ruleProviders;
config["rules"] = rules;
// 代理组
config["proxy-groups"] = proxyGroups;
// 地区分组
addRegions(config);
// 返回修改后的配置
return config;
}