forked from NLZLJC/Rule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcname_dev2.js
671 lines (608 loc) · 27.3 KB
/
cname_dev2.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
/**
* 更新日期:2023-07-22 17:41:30 仅支持Surge、Loon
* 用法:Sub-Store Version 2.14+ 脚本操作里添加:默认48H缓存超时 可参数自定
* 符号:🅳电信 🅻联通 🆈移动 🅶广电 🅲公司 🆉直连 🎮游戏
* 作者:@Key @奶茶姐 @小一 @可莉
* 接口:入口查询[国内spapi 识别到国外为ip-api] 落地查询[ip-api]
* 功能:根据接口返回的真实结果,重新对节点命名。添加入口城市、落地国家或地区、国内运营商信息,并对这些数据做持久化缓存(48小时有效期),减少API请求次数,提高运行效率。
*
* 参数必须以"#"开头,多个参数使用"&"连接,例如 https://github.com/Keywos/rule/raw/main/cname.js#city&iisp&name=一元
* 以下是此脚本支持的参数,必须以"#"开头,多个参数使用"&"连接,需要传入参数的话用 "=" 例如 "name=一元" 参考上述地址为例使用参数。
* 无参数时的节点命名格式: "美国 01",如果[入口IP或国家]或[落地IP或国家]一样则为 "直连 德国 01"
* 首次运行或者在没有缓存的情况下会通知进度
# 入口参数
[iisp] 增加入口运营商或者直连标识;
[city] 增加入口城市文字标识;
[sheng] 增加入口省份文字标识;
[yuan] 为境外入口添加真实的入口属地标识,当未配置此此参数时,则将境外入口统一标记为[境外],默认未配置此参数;
# 落地参数
[yisp] 显示落地详细运营商名称;
[yw] 落地归属地使用英文缩写标识,不建议与其他入口参数配合使用,因为其他参数API没有返回英文;
# 图标参数
[game] 增加游戏节点标识;
[flag] 增加国家或地区的旗帜标识,默认无此参数;
[bl] 保留倍率标识;
[snone] 清理某地区内只有一个节点的序号;
# 分隔符参数
[fgf=] 设置入口和落地之间的分隔符,默认为空格;
[sn=] 设置国家与序号之间的分隔符,默认为空格;
[name=] 为节点添加机场名称前缀;
# 通知参数
[offtz] 关闭脚本通知;
[tz=] 为推送通知时添加机场名称;
# 解析参数
[dnsjx] 将节点域名解析为IP,普通用户不建议使用;
# 逻辑参数
[bs=] 批处理节点数建议10个左右,如果经常读不到节点建议减小批处理个数;
# 缓存参数
[h=] 节点缓存有效期,单位小时,时间参数只能二选一,Loon用户不需填写要此参数,请进入Sub-Store插件的配置界面自定义缓存有效期;
[min=] 节点缓存有效期,单位分钟,时间参数只能二选一,Loon用户不需填写要此参数,请进入Sub-Store插件的配置界面自定义缓存有效期;
# 超时参数
[timeout=] 当无任何节点缓存时测试节点HTTP延时允许的最大超时参数,超出允许范围则判定为无效节点,默认2000ms;
[cd=] 当有缓存时,会先读取缓存,且对节点进行延时测试,直接输出结果;
当无缓存时,会对节点直接进行HTTP延时测试,默认460ms。节点延时超过所设定的值时会再次重试,累计两次,若再次超时则会判定为无效节点,并将结果写入缓存;
当设置[cd=]的值小于50时,则直接读取缓存;
# 其他参数
[debug] 调试日志,普通用户不建议使用。
*/
/**
* 已更新: 2023-07-22 :https://github.com/sub-store-org/Sub-Store
* Surge: https://github.com/Keywos/rule/raw/main/Sub-Store/Sub-Store.sgmodule
* Loon: https://github.com/Keywos/rule/raw/main/Sub-Store/Sub-Store.plugin
* 可莉版本 Loon: https://gitlab.com/lodepuly/vpn_tool/-/raw/main/Tool/Loon/Plugin/Sub-Store.plugin
*/
const $ = $substore;
const iar = $arguments;
let FGF = iar.fgf == undefined ? " " : decodeURI(iar.fgf),FGFS = FGF,debug = iar.debug;
debug = 1
const { yw, bl, iisp, yisp, yun, city, flag, game, yuan, sheng, offtz, snone: numone} = iar;
const h = iar.h ? decodeURI(iar.h) : "",min = iar.min ? decodeURI(iar.min) : "",tzname = iar.tz ? decodeURI(iar.tz) : "",firstN = iar.name ? decodeURI(iar.name) : "";
const XHFGF = iar.sn == undefined ? " " : decodeURI(iar.sn),{ isLoon: isLoon, isSurge: isSurge } = $substore.env, dns = iar.dnsjx,target = isLoon ? "Loon" : isSurge ? "Surge" : undefined,keypr= "peedtest";
let cd = iar.cd ? iar.cd : 460, timeout = iar.timeout ? iar.timeout : 2000, writet = "", innum = 1728e5, loontrue = false, onen = false, Sue = false
const keyp = "3.s",EXPIRATION_KEY = "sub-store-csr-expiration-time";
if (min !== "") {
Sue = true;
innum = parseInt(min, 10) * 6e4;
writet = $persistentStore.write(JSON.stringify(innum), EXPIRATION_KEY);
} else if (h !== "") {
Sue = true;
innum = parseInt(h, 10) * 36e5;
writet = $persistentStore.write(JSON.stringify(innum), EXPIRATION_KEY);
} else {
writet = $persistentStore.write(JSON.stringify(innum), EXPIRATION_KEY);
}
let TIMEDKEY = $persistentStore.read(EXPIRATION_KEY);
const nlc =/邀请|返利|循环|官网|客服|网站|网址|获取|订阅|流量|到期|禁止|下次|使用|版本|官址|备用|到期|过期|已用|国内|国际|国外|联系|邮箱|工单|贩卖|倒卖|防止|(\b(USE|USED|TOTAL|EXPIRE|EMAIL)\b)|\d\s?g/i;
// const regexArray = [/\u6e38\u620f|game/i];
// const valueArray = ["Game"];
async function operator(e) {
if(e.length < 1) {
$notification.post("CNAME","订阅无节点","");
return e;}
// let cs = 0;
const startTime = new Date();
const support = isLoon || isSurge;
if (!support) {$.error(`No Loon or Surge`);
return e;
}
if (typeof scriptResourceCache === "undefined") {
klog("\nNCNAME: SubStore 未更新 Version 2.14+,\n查看脚本说明\nhttps://github.com/Keywos/rule/raw/main/cname.js");
if (target == "Surge") {
$notification.post("NCNAME Sub-Store 未更新 Version 2.14+","","请点击或查看klog查看脚本说明安装对应版本",{url: "https://github.com/Keywos/rule/raw/main/Sub-Store/Sub-Store.sgmodule",});
} else if (target == "Loon") {
$notification.post("NCNAME Sub-Store 未更新 Version 2.14+ ","","请点击安装插件, 或查看klog安装对应版本, 并关闭原本的substore","loon://import?plugin=https://gitlab.com/lodepuly/vpn_tool/-/raw/main/Tool/Loon/Plugin/Sub-Store.plugin");
}
return e;
}
var bs = iar.bs ? iar.bs : 8;
const ein = e.length;
/**
* delog() debug:boolean console.log
* klog() console.log
*/
klog(`开始处理节点: ${ein} 个`);
klog(`批处理节点数: ${bs} 个`);
klog(`设定api超时: ${zhTime(timeout)}`);
klog(`有缓api超时: ${zhTime(cd)}`);
e = e.filter((item) => !nlc.test(item.name));
let o = 0,Pushtd = "",intimed = "",stops = false,rere=false;
// do {
while (o < e.length && !stops) {
const batchs = e.slice(o, o + 1);
await Promise.all(
batchs.map(async (pk) => {
try {
const inss = new Map();
const id = getid(pk);
if (inss.has(id)) {
return inss.get(id);
}
const cacheds = scriptResourceCache.get(id);
if (cacheds) {
if (!onen) {
timeout = cd;
onen = true;
stops = true;
}
const readt = scriptResourceCache.gettime(id);
let nt = new Date().getTime();
let timedPush = "";
if (target == "Loon") {
let loontd = "";
const loonkkk={"1分钟":6e4,"5分钟":3e5,"10分钟":6e5,"30分钟":18e5,"1小时":36e5,"2小时":72e5,"3小时":108e5,"6小时":216e5,"12小时":432e5,"24小时":864e5,"48小时":1728e5,"72小时":2592e5,参数传入:"innums"};
intimed = $persistentStore.read("节点缓存有效期");
loontd = loonkkk[intimed] || 1728e5;
if (loontd == "innums") {
loontd = innum;
}
timedPush = zhTime(
parseInt(readt, 10) - nt + parseInt(loontd, 10)
);
} else if (target === "Surge" && Sue) {
timedPush = zhTime(
parseInt(readt, 10) - nt + parseInt(innum, 10)
);
} else {
timedPush = zhTime(
parseInt(readt, 10) - nt + parseInt(TIMEDKEY, 10)
);
}
Pushtd = `, ${timedPush}后过期 \n`;
}
} catch (err) {}
})
);
o += 1;
}
if (!onen && !offtz) $notification.post("CNAME", `开始处理节点: ${ein} 个 批处理数量: ${bs} 个`, "耐心等待, 请勿重复点击预览...");
let i = 0;
while (i < e.length) {
const batch = e.slice(i, i + bs);
await Promise.all(
batch.map(async (pk) => {
try {
let keyover = [], Yserver = pk.server,luodi = "",inQcip = "",nxx = "",adflag = "",
OGame="",Oisp="",Oispflag="",Osh="", Oct="",zhi = "",yuanisp ="",
isCN = false,v4 = false, v6 = false, isNoAli = false;
const inServer = await AliD(Yserver);
delog(inServer)
switch (inServer) { // 入口 server
case "keyn":
isNoAli = true;
inServer = Yserver;
break;
default:
pk.keyrk = inServer;
if (!isNoAli) {
if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(inServer)) {
v4 = true;
} else if (/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(inServer)) {
v6 = true;
}
}
break;
}
const outip = await OUTIA(pk);
let {country:outUsq, countryCode:outUs, city:outCity, query:outQuery, isp:outisp} = outip;//落地
if (yisp) {
yuanisp = FGFS+outisp
};
debug && (pk.keyoutld = outip);
delog("落地信息 " + JSON.stringify(outip))
luodi = (outUsq === "中国") ? outCity : (yw ? outUs : outUsq);
let btip = outQuery !== inServer
if (btip) {
if (!isNoAli || v4) {
const spkey = await SPEC(inServer);//入口国内api查询
let {country:inSpCn,regionName:inSpSheng,city:inSpCity,isp:inSpIsp,ip:inSpIp} = spkey;//入口speedapi
debug && (pk.keyinsp = spkey);
isCN = inSpCn === "中国";
const keycm = {电信:"🅳", 联通:"🅻", 移动: "🆈",广电:"🅶"};
if (isCN){
debug && (pk.keyinsp = spkey)
delog("国内入口 " + JSON.stringify(spkey));
inQcip = inSpIp;
if(iisp && flag){
inSpIsp=inSpIsp.replace(/中国/g, "")
flag && (Oispflag = keycm.hasOwnProperty(inSpIsp) ? keycm[inSpIsp] : "🅲");
} else if(iisp){
Oisp = /电信|联通|移动|广电/.test(inSpIsp) ? inSpIsp.replace(/中国/g, "") : "企业";
}
(inSpSheng === inSpCity) && (inSpCity = "");
if (sheng && city){
Osh = inSpSheng;Oct = inSpCity
} else if (sheng){
Osh = inSpSheng;
} else if (city){
Oct = inSpCity ? inSpCity : inSpSheng;
}
}
}
if (isNoAli || v6 || !isCN) {
const inip = await INIA(Yserver);//ipapi入口
let {country: inUsq, city: inCity, query: inQuery, regionName: inIpSh} = inip;
debug && (pk.keyinipapi = inip);
delog("ipapi入口 " + JSON.stringify(inip));
inQcip = inQuery; //去重ip
if (inUsq === "中国") {
// inCity === inUs ? (incity=inCity)
(/[a-zA-Z]/.test(inCity)) && (inCity = inIpSh);
(inCity === inIpSh) && (inIpSh="");
if (sheng && city){
Osh = inIpSh;Oct = inCity;
} else if (sheng){
Osh = inIpSh;
} else if (city){
Oct = inCity ? inCity : inIpSh;
}
// 运营商 未知
flag && (Oispflag = "🅲");
} else {
if(inQuery === outQuery){
flag && (Oispflag = "🆉");
(sheng || city || iisp) && (zhi = "直连");
} else if (yuan){
flag && (Oispflag = "🅲");
(sheng || city || iisp) && (zhi = inUsq);
} else {
flag && (Oispflag = "🆇");
(sheng || city || iisp) && (zhi = "境外");
}
}
}
} else {
flag && (Oispflag = "🆉");
(sheng || city || iisp) && (zhi = "直连");
}
flag && (adflag = getflag(outUs));
game && (OGame = /game|游戏/i.test(pk.name) ? (flag ? "🎮" : FGF+"Game") : OGame);
if (bl){
const match = pk.name.match(/(倍率\D?((\d\.)?\d+)\D?)|((\d\.)?\d+)(倍|X|x|×)/);
if (match) {
const matchVa = match[0].match(/(\d[\d.]*)/)[0];
if (matchVa !== "1") {
nxx = FGF + matchVa + "X";
}
}
}
// regexArray.forEach((regex, index) => {if (regex.test(pk.name)) {rename = valueArray[index];}});
(!iisp && !city && !sheng) && (Oispflag = "",FGF ="");
keyover = keyover.concat(
firstN, Oispflag,Osh,Oct,Oisp,zhi,FGF,adflag,luodi,OGame,nxx,yuanisp
).filter(ki => ki !== "");
// delog(keyover)
const overName = keyover.join("");
// delog(overName)
dns && (pk.server = inQcip);
pk.name = overName;
pk.qc = inQcip + outQuery;
} catch (err) {}
})
);
i += bs;
klog(`处理进度${i}/${ein}`)
if (!onen){
if(!offtz && (ein > (i*2))){
if (i >= ((e.length / 3)|0) && i < ((e.length * 2 / 3)|0) && ein>i) {
$notification.post("CNAME", `处理进度${i}/${ein}`, "耐心等待, 请勿重复点击预览...");
}
}
await sleep(getRandom());
}
}
// cs++;
e = removels(e);
// rere = e.length < ein * 0.2 || false;
// (rere && cs === 1) && (cd = timeout,await sleep(50));
// } while (rere && cs < 2);
// cs < 3 && (klog("任务执行次数: " + cs));
e = removeqc(e);
e = jxh(e);
// if (firstN !== "") {e.forEach((pk) => {pk.name = firstN + " " + pk.name;});}
numone && (e = onee(e));
let eout = e.length;
const endTime = new Date();
const timeDiff = endTime.getTime() - startTime.getTime();
if (dns) {
klog(`dns解析后共: ${eout} 个`);
}
apiRead > 0 ? klog(`读取api缓存: ${apiRead} 个`) : null;
apiw > 0 ? klog(`写入api缓存: ${apiw} 个`) : null;
klog(`处理完后剩余: ${eout} 个`);
if (target == "Loon") {
klog("缓存过期时间: " + intimed + ", 还剩" + Pushtd.replace(/,|\n/g, ""));
} else {
klog("缓存过期时间: " +zhTime(TIMEDKEY) +", 还剩" +Pushtd.replace(/,|\n/g, ""));
}
klog(`此方法总用时: ${zhTime(timeDiff)}\n----For New CNAME----`);
const readklog = apiRead ? `读取缓存:${apiRead} ` : "";
const writeklog = apiw ? `写入缓存:${apiw}, ` : "";
const Push = (eout === ein && eout === 0) ? "" : (eout === ein ? "全部通过测试, " : "去除无效节点后有" + eout + "个, ");
if (!offtz) {$notification.post(
`${tzname}共${ein}个节点`,
"",
`${writeklog}${readklog}${Pushtd}${Push}用时:${zhTime(timeDiff)}`
);}
return e;
}
function getflag(e) {
const t = e
.toUpperCase()
.split("")
.map((e) => 127397 + e.charCodeAt());
return String.fromCodePoint(...t).replace(/🇹🇼/g, "🇨🇳");
}
function sleep(e) {
return new Promise((t) => setTimeout(t, e));
}
let apiRead = 0,apiw = 0;
const outipApi = new Map();
async function OUTIA(e) {
const t = getid(e);
if (outipApi.has(t)) return outipApi.get(t);
const cached = scriptResourceCache.get(t);
if (cached) {
apiRead++;
return cached;
}
const maxRE = 2;
const url = `http://ip-api.com/json?lang=zh-CN&fields=status,message,country,countryCode,city,query,isp`;
const getHttp = async (reTry) => {
try {
let r = ProxyUtils.produce([e], target);
const response = await Promise.race([
$.http.get({ url:url, node: r, "policy-descriptor": r }),
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), timeout))
]);
const data = JSON.parse(response.body);
if (data.status === "success") {
scriptResourceCache.set(t, data);
return data;
} else {
throw new Error(resdata.message);
}
} catch (error) {
if (reTry < maxRE) {
await sleep(getRandom());
delog(e.name+"-> [outipApi超时查询次数] "+reTry)
return getHttp(reTry + 1);
} else {
throw error;
}
}
};
const resGet = new Promise((resolve, reject) => {
if (cd < 1 && onen) return resGet;
getHttp(1)
.then((data) => {
apiw++;
resolve(data);
})
.catch(reject);
});
outipApi.set(t, resGet);
return resGet;
}
const ali = new Map();
async function AliD(e) {
const ti =/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(e);
if (ti) return e;
const t = getaliid(e);
if (ali.has(t)) return ali.get(t);
const cached = scriptResourceCache.get(t);
if (cached) return cached;
const maxRE = 2;
const url = `http://223.5.5.5/resolve?name=${e}&type=A&short=1`;
const getHttp = async (reTry) => {
try {
const response = await Promise.race([
$.http.get({ url: url }),
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), timeout))
]);
const resdata = JSON.parse(response.body);
if (resdata.length > 0) {
scriptResourceCache.set(t, resdata[0]);
return(resdata[0]);
} else {
return ("keyn");
}
} catch (error) {
if (reTry < maxRE) {
await sleep(getRandom());
delog(e + " [->Ali超时查询次数] " + reTry);
return getHttp(reTry + 1);
} else {
throw error;
}
}
};
const resGet = new Promise((resolve, reject) => {
if (cd < 1 && onen) {
return resGet;
} else {
getHttp(1)
.then((data) => {
resolve(data);
})
.catch(reject);
}
});
ali.set(t, resGet);
return resGet;
}
const spapi = new Map();
async function SPEC(e) {
const n = getspcn(e);
if (spapi.has(n)) return spapi.get(n);
const cached = scriptResourceCache.get(n);
if (cached) return cached;
const maxRE = 2;
const url = `https://api-v${keyp}${keypr}.cn/ip?ip=${e}`;
const getHttp = async (reTry) => {
try {
const response = await Promise.race([
$.http.get({ url: url }),
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), timeout))
]);
const resdata = JSON.parse(response.body);
delog(resdata);
if (resdata.data) {
const { country: e, province: o, city: r, isp: i, ip: c } = resdata.data;
const a = { country: e, regionName: o, city: r, isp: i, ip: c };
delog("写入");
scriptResourceCache.set(n, a);
return a;
} else {
throw new Error(resdata.message);
}
} catch (error) {
if (reTry < maxRE) {
await sleep(getRandom());
delog(e + "-> [SP超时查询次数] " + reTry);
return getHttp(reTry + 1);
} else {
throw error;
}
}
};
const resGet = new Promise((resolve, reject) => {
if (cd < 1 && onen) return resGet;
getHttp(1)
.then((data) => {
resolve(data);
})
.catch(reject);
});
spapi.set(n, resGet);
return resGet;
}
const inipApi = new Map();
async function INIA(e) {
const t = getinid(e);
if (inipApi.has(t)) return inipApi.get(t);
const cached = scriptResourceCache.get(t);
if (cached) return cached;
const maxRE = 2;
const url = `http://ip-api.com/json/${e}?lang=zh-CN&fields=status,message,country,city,query,regionName`;
const getHttp = async (reTry) => {
try {
delog(url)
const response = await Promise.race([
$.http.get({ url:url }),
new Promise((_, reject) => setTimeout(() => reject(new Error("message")), timeout))
]);
const data = JSON.parse(response.body);
if (data.status === "success") {
scriptResourceCache.set(t, data);
return data;
} else {
throw new Error(resdata.message);
}
} catch (error) {
if (reTry < maxRE) {
await sleep(getRandom());
delog(e+"-> [inipApi超时查询次数] "+reTry)
return getHttp(reTry + 1);
} else {
throw error;
}
}
};
const resGet = new Promise((resolve, reject) => {
if (cd < 1 && onen) return resGet;
getHttp(1)
.then((data) => {
resolve(data);
})
.catch(reject);
});
inipApi.set(t, resGet);
return resGet;
}
function getRandom() {
return Math.floor(Math.random() * (500 - 50 + 1) + 50);
}
function delog(...arg) {
if(debug){
console.log('[CNAME] '+arg);
}
}
function klog(...arg) {
console.log('[CNAME] '+ arg);
}
function removels(e) {
const t = new Set();
const n = [];
for (const s of e) {
if (s.qc && !t.has(s.qc)) {
t.add(s.qc);
n.push(s);
}
}
return n;
}
function removeqc(e) {
const t = new Set();
const n = [];
for (const s of e) {
if (!t.has(s.qc)) {
t.add(s.qc);
const e = { ...s };
delete e.qc;
n.push(e);
}
}
return n;
}
function jxh(e) {
const t = e.reduce((e, t) => {
const n = e.find((e) => e.name === t.name);
if (n) {
n.count++;
n.items.push({
...t,
name: `${t.name}${XHFGF}${n.count.toString().padStart(2, "0")}`,
});
} else {
e.push({
name: t.name,
count: 1,
items: [{ ...t, name: `${t.name}${XHFGF}01` }],
});
}
return e;
}, []);
const n = t.flatMap((e) => e.items);
e.splice(0, e.length, ...n);
return e;
}
function onee(e) {
const t = e.reduce((e, t) => {
const n = t.name.replace(/[^A-Za-z0-9\u00C0-\u017F\u4E00-\u9FFF]+\d+$/, "");
if (!e[n]) {
e[n] = [];
}
e[n].push(t);
return e;
}, {});
for (const e in t) {
if (t[e].length === 1 && t[e][0].name.endsWith("01")) {
const n = t[e][0];
n.name = e;
}
}
return e;
}
function zhTime(e) {
e = e.toString().replace(/-/g, "");
if (e < 1e3) {
return `${Math.round(e)}毫秒`;
} else if (e < 6e4) {
return `${Math.round(e / 1e3)}秒`;
} else if (e < 36e5) {
return `${Math.round(e / 6e4)}分钟`;
} else if (e >= 36e5) {
return `${Math.round(e / 36e5)}小时`;
}
}
var MD5=function(e){var t=M(V(Y(X(e),8*e.length)));return t.toLowerCase()};function M(e){for(var t,n="0123456789ABCDEF",s="",o=0;o<e.length;o++)t=e.charCodeAt(o),s+=n.charAt(t>>>4&15)+n.charAt(15&t);return s}function X(e){for(var t=Array(e.length>>2),n=0;n<t.length;n++)t[n]=0;for(n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t}function V(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}function Y(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n=1732584193,s=-271733879,o=-1732584194,r=271733878,i=0;i<e.length;i+=16){var c=n,a=s,u=o,m=r;s=md5_ii(s=md5_ii(s=md5_ii(s=md5_ii(s=md5_hh(s=md5_hh(s=md5_hh(s=md5_hh(s=md5_gg(s=md5_gg(s=md5_gg(s=md5_gg(s=md5_ff(s=md5_ff(s=md5_ff(s=md5_ff(s,o=md5_ff(o,r=md5_ff(r,n=md5_ff(n,s,o,r,e[i+0],7,-680876936),s,o,e[i+1],12,-389564586),n,s,e[i+2],17,606105819),r,n,e[i+3],22,-1044525330),o=md5_ff(o,r=md5_ff(r,n=md5_ff(n,s,o,r,e[i+4],7,-176418897),s,o,e[i+5],12,1200080426),n,s,e[i+6],17,-1473231341),r,n,e[i+7],22,-45705983),o=md5_ff(o,r=md5_ff(r,n=md5_ff(n,s,o,r,e[i+8],7,1770035416),s,o,e[i+9],12,-1958414417),n,s,e[i+10],17,-42063),r,n,e[i+11],22,-1990404162),o=md5_ff(o,r=md5_ff(r,n=md5_ff(n,s,o,r,e[i+12],7,1804603682),s,o,e[i+13],12,-40341101),n,s,e[i+14],17,-1502002290),r,n,e[i+15],22,1236535329),o=md5_gg(o,r=md5_gg(r,n=md5_gg(n,s,o,r,e[i+1],5,-165796510),s,o,e[i+6],9,-1069501632),n,s,e[i+11],14,643717713),r,n,e[i+0],20,-373897302),o=md5_gg(o,r=md5_gg(r,n=md5_gg(n,s,o,r,e[i+5],5,-701558691),s,o,e[i+10],9,38016083),n,s,e[i+15],14,-660478335),r,n,e[i+4],20,-405537848),o=md5_gg(o,r=md5_gg(r,n=md5_gg(n,s,o,r,e[i+9],5,568446438),s,o,e[i+14],9,-1019803690),n,s,e[i+3],14,-187363961),r,n,e[i+8],20,1163531501),o=md5_gg(o,r=md5_gg(r,n=md5_gg(n,s,o,r,e[i+13],5,-1444681467),s,o,e[i+2],9,-51403784),n,s,e[i+7],14,1735328473),r,n,e[i+12],20,-1926607734),o=md5_hh(o,r=md5_hh(r,n=md5_hh(n,s,o,r,e[i+5],4,-378558),s,o,e[i+8],11,-2022574463),n,s,e[i+11],16,1839030562),r,n,e[i+14],23,-35309556),o=md5_hh(o,r=md5_hh(r,n=md5_hh(n,s,o,r,e[i+1],4,-1530992060),s,o,e[i+4],11,1272893353),n,s,e[i+7],16,-155497632),r,n,e[i+10],23,-1094730640),o=md5_hh(o,r=md5_hh(r,n=md5_hh(n,s,o,r,e[i+13],4,681279174),s,o,e[i+0],11,-358537222),n,s,e[i+3],16,-722521979),r,n,e[i+6],23,76029189),o=md5_hh(o,r=md5_hh(r,n=md5_hh(n,s,o,r,e[i+9],4,-640364487),s,o,e[i+12],11,-421815835),n,s,e[i+15],16,530742520),r,n,e[i+2],23,-995338651),o=md5_ii(o,r=md5_ii(r,n=md5_ii(n,s,o,r,e[i+0],6,-198630844),s,o,e[i+7],10,1126891415),n,s,e[i+14],15,-1416354905),r,n,e[i+5],21,-57434055),o=md5_ii(o,r=md5_ii(r,n=md5_ii(n,s,o,r,e[i+12],6,1700485571),s,o,e[i+3],10,-1894986606),n,s,e[i+10],15,-1051523),r,n,e[i+1],21,-2054922799),o=md5_ii(o,r=md5_ii(r,n=md5_ii(n,s,o,r,e[i+8],6,1873313359),s,o,e[i+15],10,-30611744),n,s,e[i+6],15,-1560198380),r,n,e[i+13],21,1309151649),o=md5_ii(o,r=md5_ii(r,n=md5_ii(n,s,o,r,e[i+4],6,-145523070),s,o,e[i+11],10,-1120210379),n,s,e[i+2],15,718787259),r,n,e[i+9],21,-343485551),n=safe_add(n,c),s=safe_add(s,a),o=safe_add(o,u),r=safe_add(r,m)}return Array(n,s,o,r)}function md5_cmn(e,t,n,s,o,r){return safe_add(bit_rol(safe_add(safe_add(t,e),safe_add(s,r)),o),n)}function md5_ff(e,t,n,s,o,r,i){return md5_cmn(t&n|~t&s,e,t,o,r,i)}function md5_gg(e,t,n,s,o,r,i){return md5_cmn(t&s|n&~s,e,t,o,r,i)}function md5_hh(e,t,n,s,o,r,i){return md5_cmn(t^n^s,e,t,o,r,i)}function md5_ii(e,t,n,s,o,r,i){return md5_cmn(n^(t|~s),e,t,o,r,i)}function safe_add(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function bit_rol(e,t){return e<<t|e>>>32-t}function getid(e){let t="ld";return MD5(`${t}-${e.server}-${e.port}`)}function getinid(e){let t="ia";return MD5(`${t}-${e}`)}function getaliid(e){let t="al";return MD5(`${t}-${e}`)}function getspcn(e){let t="sc";return MD5(`${t}-${e}`)}