-
Notifications
You must be signed in to change notification settings - Fork 7
/
cf_speedtest.sh
executable file
·1637 lines (1426 loc) · 53.2 KB
/
cf_speedtest.sh
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
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# 一般配置常量, 可按需更改
PING_COUNT=100 #丢包率和延迟率测试时单个ping检测次数, 缺省100次,次数越高准确度越高但是耗时越长。建议调整为20-100
TARGET_IPS=20 #目标IP数:缺省20
EXPECT_BANDWIDTH=20 #期望的最小带宽(单位)缺省20M
ALGORITHM=1 #算法:1. 直接从cloudflare官网全IP库中拉取IP池; 2. 从udpfile.com过滤过的IP库中拉取IP池
POOL_COMBINE=yes #是否启用与现有生效的代理池订阅进行合并(yes/no),启用后注意各代理节点命名不能有重复,否则本地转换时会出错
SAMPLE_IPS=1000 #每次测试用到的IP池大小,可根据设备性能和网络情况调整,一般无需更改
SPEED_THREAD_NUMBER=5 #带宽测速度的线程数,缺省5,加大线程数可加快测试速度。可根据实际物理带宽和EXPECT_BANDWIDTH期望带宽做调整
#如果物理带宽是200M,期望带宽是20M最大值可以调为5=200/20
STATUS_THREAD_NUMBER=100 #进行丢包率和节点有效性检测的线程数,缺省100,可按实际性能做调整,一般不需要改
SCHEDULE="30 */6 * * *" #计划任务 (由于crontab版本不同,各个平台计划任务的格式可能会稍有差异,按实际情况填写)
GHPROXY='https://ghproxy.com/' #github代理网址,直接访问gihub有问题的可以用这个
PREF_INI_URL="${GHPROXY}https://gist.githubusercontent.com/hansyao/e00678003f4eea63b219217638582414/raw/cloudflare.ini" #远程规则文件,可按需替换
TEMP_DIR='/tmp/mytemp' #临时文件路径(无需更改)
PREF_INI="${TEMP_DIR}/cloudflare.ini" #本地规则文件,如PREF_INI_URL未定义,则抓取PREF_INI本地规则
POOL="${TEMP_DIR}/main_cloudflare.yaml" #脚本自动生成的转换规则前的代理池文件路径
CLASH_CONFIG="${TEMP_DIR}/clash_cloudflare_final.yaml" #脚本自动规则转换后的的代理池文件路径
WWW_PATH='/var/www/html/' #VPS服务器上的web路径,如需要外网访问需要将其路径填写在这里
CLASH_ENABLE=yes #是否应用clash(yes/no), 填no不进行规则转换, opewrt填no同时不应用到配置文件
PASSWALL_ENABLE=yes #是否应用passwall(yes/no), openwrt适用,填no不用passwall
SPEED_TEST=yes #是否启用带宽测速(yes/no)
PACK_LOSS_TEST=no #是否启用丢包率测试(yes/no), 注意丢包率高的未必测速带宽低,具体按实际情况调整
CONVERTER_ENABLE=yes #是否进行规则转换并生成自己的私有订阅链接方便应用到其他代理客户端(必须先开启gist)
GIST_TOKEN= #授予gist权限的github密钥,如不上传留空即可
REMOTE_NAME='cloudflare' #上传到gist上的文件名,按需更改
RULE_PATH_OPENCLASH=/etc/openclash/config #OpenClash配置文件路径(OpenClash缺省,一般无需更改)
RULE_PATH_MERLINCLASH=/koolshare/merlinclash/yaml_bak #梅林路由器clash文件配置文件路径(Merlin koolshare Clash缺省,一般无需更改)
RULE_PATH_OTHERS=${WWW_PATH} #其他服务器clash文件配置文件路径(按需更改为自己的配置文件所在路径)
POOL_COMBINED_CONF="${TEMP_DIR}/pool_combined.yaml" #代理池合并后的文件路径(无需更改)
# 不同客户端规则转换(yes/no, 必须开启gist)
CONVERT_clash=no
CONVERT_clashr=no
CONVERT_quan=no
CONVERT_quanx=no
CONVERT_loon=no
CONVERT_mellow=no
CONVERT_surfboard=no
CONVERT_surge2=no
CONVERT_surge3=no
CONVERT_surge4=yes
CONVERT_v2ray=no
CONVERT_mixed=no
# 上传Github gist用到的全局变量, 以下变量都由脚本自动生成无需更改
DESC_JSON="${TEMP_DIR}/gist.json"
RESPONSE="${TEMP_DIR}/gist_response.json"
GIST_ID_main=
GIST_ID_clash=
GIST_ID_clashr=
GIST_ID_quan=
GIST_ID_quanx=
GIST_ID_loon=
GIST_ID_mellow=
GIST_ID_surfboard=
GIST_ID_surge2=
GIST_ID_surge3=
GIST_ID_surge4=
GIST_ID_v2ray=
GIST_ID_mixed=
# 代理池,改称自己的,如有多个代理每个配置一行按照格式填写即可(注:命名规则: VPS1_美国_CF加速 >>>CF加速字样和分组规则相对应,'vp1'为你的vps名称, '美国'为其他关键字,括号内的'${ID}'不要改)
function pool_generate() {
local SERVER=$1
local ID=$2
echo -e " - {name: VPS1_美国_CF加速(${ID}), server: ${SERVER}, port: 443, type: vmess, uuid: xxxx-xxxx-xxxx-xxxx-0000xxxx, alterId: 0, cipher: auto, tls: true, skip-cert-verify: false, network: ws, ws-path: /PrVbmadf, ws-headers: {Host: your.cloudflare.workers.dev}}"
}
urlencode() {
local data
if [ "$#" -eq 1 ]; then
data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")
if [ ! -z "$data" ]; then
echo "$(echo ${data##/?} |sed 's/\//%2f/g' |sed 's/:/%3a/g' |sed 's/?/%3f/g' \
|sed 's/(/%28/g' |sed 's/)/%29/g' |sed 's/\^/%5e/g' |sed 's/=/%3d/g' \
|sed 's/|/%7c/g' |sed 's/+/%20/g')"
fi
fi
}
parse_json_simple(){
local JSON=$1
local KEY=$2
local VALUE=$(echo "$1" | sed 's/.*"'${KEY}'":\([^,}]*\).*/\1/')
echo "${VALUE}" | sed 's/\"//g'
}
function openwrt_env() {
local RE1=0
local RE2=0
which uci
if [[ $? -ne 0 ]]; then
echo -e "未找到uci工具, 开始安装源依赖"
opkg install ca-certificates wget
opkg update
opkg install uci
if [[ $? -gt 0 ]]; then
echo "uci安装失败, 请手工安装后继续!"
local RE1=1
fi
fi
which shuf
if [[ $? -ne 0 ]]; then
opkg install coreutils-shuf
opkg install ca-certificates wget
opkg update
opkg install coreutils-shuf
if [[ $? -gt 0 ]]; then
echo "shuf安装失败, 请手工安装后继续!"
local RE2=1
fi
fi
if [[ ${RE1} -eq 0 && ${RE1} -eq 0 ]]; then
return 0
else
return 1
fi
}
function passwall_config() {
local POOL=$1
echo -e "删除现有UUID重复的配置"
local UUID_LIST=$(cat "${POOL}" | sed "1d" | awk -F "uuid:" '{print $2}' | awk -F "," '{print $1}' \
| sed 's/^[ \t]*//g' | sed 's/[ \t]*$//g' | sort | uniq)
local CURRENT_NODES=$(uci show passwall | grep uuid=)
echo -e "${CURRENT_NODES}" | while read LINE && [[ -n "${LINE}" ]]
do
local NODE_ID=$(echo -e ${LINE} | cut -d "." -f2)
local UUID=$(echo -e ${LINE} | cut -d "'" -f2)
if [[ -n "$(echo -e "${UUID_LIST}" | grep "${UUID}")" ]]; then
uci delete passwall.${NODE_ID}
fi
done
uci commit passwall
unset LINE
echo -e "清空负载均衡节点配置"
local PROXY_LIST_NUM=$(uci show passwall | grep haproxy_config | tail -n 1| sed "s/^.*\[//g"| sed "s/\].*//g")
while [[ ${PROXY_LIST_NUM} -ge 0 ]]
do
uci delete passwall.@haproxy_config[${PROXY_LIST_NUM}]
local PROXY_LIST_NUM=$((PROXY_LIST_NUM -1))
done
uci commit passwall
echo -e "清空负载均衡中继节点配置"
uci show passwall | grep 127.0.0.1 | cut -d "." -f1,2 | while read LINE && [[ -n "${LINE}" ]]
do
uci delete "${LINE}"
done
uci commit passwall
unset LINE
echo -e "清空负载均衡全局配置"
local HAPROXY_GLOBAL_NUM=$(uci show passwall | grep global_haproxy | tail -n 1| sed "s/^.*\[//g"| sed "s/\].*//g")
while [[ ${HAPROXY_GLOBAL_NUM} -ge 0 ]]
do
uci delete passwall.@global_haproxy[${PROXY_LIST_NUM}]
local HAPROXY_GLOBAL_NUM=$((HAPROXY_GLOBAL_NUM -1))
done
uci commit passwall
echo -e "创建haproxy负载均衡中继节点"
local PORT=1181
echo -e "$(pool_generate)" | while read LINE && [[ -n "${LINE}" ]]
do
local LINE=$(echo -e "${LINE}" | sed "s/.*name/name/g" | sed "s/}$//g" | sed "s/{/,/g" \
| sed "s/}$//g" | sed "s/,/\\n/g" | sed 's/^[ \t]*//g' | sed 's/[ \t]*$//g')
local SERVER_NAME=$(echo -e "${LINE}" | grep -i name: | awk '{print $2}' | sed "s/()//g")
local NODE_ID=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-32)
local PROTOCOL=$(echo -e "${LINE}" | grep type: | awk '{print $2}')
if [[ "${PROTOCOL}" == 'vmess' ]]; then
local TYPE='V2ray'
elif [[ "${PROTOCOL}" == 'vless' ]]; then
local TYPE='V2ray'
elif [[ "${PROTOCOL}" == 'ss' ]]; then
local TYPE='Shadowsocks'
elif [[ "${PROTOCOL}" == 'ssr' ]]; then
local TYPE='ShadowsocksR'
elif [[ "${PROTOCOL}" == 'trojan' ]]; then
local TYPE='Trojan-Plus'
else
echo -e "不支持的协议"
continue
fi
uci set passwall.${NODE_ID}=nodes
uci set passwall.${NODE_ID}.add_mode="CF自动测速"
uci set passwall.${NODE_ID}.remarks="负载均衡 ${SERVER_NAME}"
uci set passwall.${NODE_ID}.type="${TYPE}"
uci set passwall.${NODE_ID}.protocol="${PROTOCOL}"
uci set passwall.${NODE_ID}.port="${PORT}"
uci set passwall.${NODE_ID}.encryption=none
uci set passwall.${NODE_ID}.uuid=$(echo -e "${LINE}" | grep -i uuid: | awk '{print $2}')
uci set passwall.${NODE_ID}.level=1
uci set passwall.${NODE_ID}.cipher=$(echo -e "${LINE}" | grep -i cipher: | awk '{print $2}')
uci set passwall.${NODE_ID}.alter_id=$(echo -e "${LINE}" | grep -i alterId: | awk '{print $2}')
uci set passwall.${NODE_ID}.stream_security=tls
uci set passwall.${NODE_ID}.tls_serverName=$(echo -e "${LINE}" | grep -i Host: | awk '{print $2}')
uci set passwall.${NODE_ID}.transport=$(echo -e "${LINE}" | grep -i network: | awk '{print $2}')
uci set passwall.${NODE_ID}.ws_host=$(echo -e "${LINE}" | grep -i Host: | awk '{print $2}')
uci set passwall.${NODE_ID}.tls_serverName=$(echo -e "${LINE}" | grep -i Host: | awk '{print $2}')
uci set passwall.${NODE_ID}.tls_allowInsecure=1
uci set passwall.${NODE_ID}.security=$(echo -e "${LINE}" | grep -i cipher: | awk '{print $2}')
uci set passwall.${NODE_ID}.is_sub=0
uci set passwall.${NODE_ID}.password=$(echo -e "${LINE}" | grep -i password: | awk '{print $2}')
uci set passwall.${NODE_ID}.ws_path=$(echo -e "${LINE}" | grep -i ws-path: | awk '{print $2}')
uci set passwall.${NODE_ID}.mux=1
uci set passwall.${NODE_ID}.mux_concurrency=8
uci set passwall.${NODE_ID}.address=127.0.0.1
echo -e "$SERVER_NAME" "${PORT}"
echo -e "$SERVER_NAME\`${PORT}" >>"${TEMP_DIR}/main_server.txt"
local PORT=$(( ${PORT} + 1))
done
unset LINE
echo -e "写入haproxy负载均衡全局设置"
local HAPROXY_GLOBAL_NODE=$(uci add passwall global_haproxy)
uci set passwall."${HAPROXY_GLOBAL_NODE}".balancing_enable=1
uci set passwall."${HAPROXY_GLOBAL_NODE}".console_port=1199
uci commit passwall
echo -e "开始写入passwall配置"
local i=1
cat "${POOL}" | sed "1d" | while read PROXY && [[ -n "${PROXY}" ]]
do
local NODE_ID=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-32)
local PROXY=$(echo -e "${PROXY}" | sed "s/.*name/name/g" | sed "s/}$//g" | sed "s/{/,/g" \
| sed "s/}$//g" | sed "s/,/\\n/g" | sed 's/^[ \t]*//g' | sed 's/[ \t]*$//g')
local SERVER_NAME=$(echo -e "${PROXY}" | grep -i name: | awk '{print $2}')
local SERVER_IP=$(echo -e "${PROXY}" | grep -i server: | awk '{print $2}')
local PORT=$(echo -e "${PROXY}" | grep -i port: | awk '{print $2}')
local PROTOCOL=$(echo -e "${PROXY}" | grep type: | awk '{print $2}')
if [[ "${PROTOCOL}" == 'vmess' ]]; then
local TYPE='V2ray'
elif [[ "${PROTOCOL}" == 'vless' ]]; then
local TYPE='V2ray'
elif [[ "${PROTOCOL}" == 'ss' ]]; then
local TYPE='Shadowsocks'
elif [[ "${PROTOCOL}" == 'ssr' ]]; then
local TYPE='ShadowsocksR'
elif [[ "${PROTOCOL}" == 'trojan' ]]; then
local TYPE='Trojan-Plus'
else
echo -e "不支持的协议"
continue
fi
echo -e "添加节点 ${SERVER_IP}:${PORT} 并加入haproxy负载均衡"
uci set passwall.${NODE_ID}=nodes
uci set passwall.${NODE_ID}.add_mode="CF自动测速"
uci set passwall.${NODE_ID}.remarks="${SERVER_NAME}"
uci set passwall.${NODE_ID}.type="${TYPE}"
uci set passwall.${NODE_ID}.protocol="${PROTOCOL}"
uci set passwall.${NODE_ID}.port="${PORT}"
uci set passwall.${NODE_ID}.encryption=none
uci set passwall.${NODE_ID}.uuid=$(echo -e "${PROXY}" | grep -i uuid: | awk '{print $2}')
uci set passwall.${NODE_ID}.level=1
uci set passwall.${NODE_ID}.cipher=$(echo -e "${PROXY}" | grep -i cipher: | awk '{print $2}')
uci set passwall.${NODE_ID}.alter_id=$(echo -e "${PROXY}" | grep -i alterId: | awk '{print $2}')
uci set passwall.${NODE_ID}.stream_security=tls
uci set passwall.${NODE_ID}.tls_serverName=$(echo -e "${PROXY}" | grep -i Host: | awk '{print $2}')
uci set passwall.${NODE_ID}.transport=$(echo -e "${PROXY}" | grep -i network: | awk '{print $2}')
uci set passwall.${NODE_ID}.ws_host=$(echo -e "${PROXY}" | grep -i Host: | awk '{print $2}')
uci set passwall.${NODE_ID}.tls_serverName=$(echo -e "${PROXY}" | grep -i Host: | awk '{print $2}')
uci set passwall.${NODE_ID}.tls_allowInsecure=1
uci set passwall.${NODE_ID}.security=$(echo -e "${PROXY}" | grep -i cipher: | awk '{print $2}')
uci set passwall.${NODE_ID}.is_sub=0
uci set passwall.${NODE_ID}.password=$(echo -e "${PROXY}" | grep -i password: | awk '{print $2}')
uci set passwall.${NODE_ID}.ws_path=$(echo -e "${PROXY}" | grep -i ws-path: | awk '{print $2}')
uci set passwall.${NODE_ID}.mux=1
uci set passwall.${NODE_ID}.mux_concurrency=8
uci set passwall.${NODE_ID}.address="${SERVER_IP}"
local SERVER_NAME=$(echo -e "${SERVER_NAME}" | sed "s/(.*$//g")
local HAPROXY_PORT=$(cat "${TEMP_DIR}/main_server.txt" | grep -E "^${SERVER_NAME}\`" | awk -F '`' '{print $2}')
local HAPROXY_NODE=$(uci add passwall haproxy_config)
if [[ ${i} -le 6 ]]; then
local LBWEIGHT=20
local BACKUP=0
else
local LBWEIGHT=5
local BACKUP=1
fi
uci set passwall.${HAPROXY_NODE}.enabled=1
uci set passwall.${HAPROXY_NODE}.lbort=${PORT}
uci set passwall.${HAPROXY_NODE}.haproxy_port=${HAPROXY_PORT}
uci set passwall.${HAPROXY_NODE}.lbweight=${LBWEIGHT}
uci set passwall.${HAPROXY_NODE}.export=1
uci set passwall.${HAPROXY_NODE}.backup=${BACKUP}
uci set passwall.${HAPROXY_NODE}.lbss="${SERVER_IP}:${PORT}"
let i++
done
uci commit passwall
rm -f "${TEMP_DIR}/main_server.txt"
unset i
}
blue(){
echo -e "\033[34m\033[01m$1\033[0m"
}
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
red(){
echo -e "\033[31m\033[01m$1\033[0m"
}
function dec2bin() {
local num=$1
local rem=1
local bno=" "
while [[ ${num} -gt 0 ]]
do
local rem=$(( $num % 2 ))
local bno=$bno$rem
local num=$(( $num / 2 ))
done
local i=${#bno}
local final=" "
while [[ $i -gt 0 ]]
do
local rev=`echo $bno | awk '{ printf substr( $0,'$i',1 ) }'`
local final=$final$rev
local i=$(( $i - 1 ))
done
echo "$final" | sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g'
}
function bin2dec() {
bino=$1
local len=${#bino}
local i=1
local pow=$((len - 1 ))
while [ $i -le $len ]
do
local n=`echo $bino | awk '{ printf substr( $0,'$i',1 )}' `
local j=1
local p=1
while [ $j -le $pow ]
do
p=$(( p * 2 ))
j=$(( j + 1 ))
done
local dec=$(( n * p ))
local findec=$(( findec + dec ))
local pow=$((pow - 1 ))
local i=$(( i + 1 ))
done
echo "$findec" | sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g'
}
function reverse_chars() {
awk '{ for (i=length($0);i>0;i--) {printf substr($0,i,1)}; printf"\n"}'
}
function bit_calc() {
local a=$(echo -e "$1" | sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g')
local OPT=$2
local b=$(echo -e "$3" | sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g')
local output=$4
echo -e "${a}" >${TEMP_DIR}/a.txt
echo -e "${b}" >${TEMP_DIR}/b.txt
local max_len=$(( ${#a}> ${#b} ? ${#a} :${#b} ))
local a1
while read -n 1 char && [[ -n "${char}" ]]
do
local a1="${char}\\n${a1}"
let i++
done <${TEMP_DIR}/a.txt
a=$(echo -e "${a1}" | grep -v "^$")
# echo -e "${a}"
local b1
while read -n 1 char && [[ -n "${char}" ]]
do
b1="${char}\\n${b1}"
let i++
done <${TEMP_DIR}/b.txt
b=$(echo -e "${b1}" | grep -v "^$")
# echo -e "${b}"
local i=1
local final
while [[ ${i} -le ${max_len} ]]
do
a1=$(echo -e "${a}" | sed -n "${i}p")
b1=$(echo -e "${b}" | sed -n "${i}p")
if [[ -z ${a1} ]]; then local a1=0; fi
if [[ -z ${b1} ]]; then local b1=0; fi
if [[ "$OPT" == '|' ]]; then
if [[ ${a1} -eq 1 || ${b1} -eq 1 ]]; then
local result=1
else
local result=0
fi
elif [[ "$OPT" == '&' ]]; then
if [[ $a1 -eq 1 && $b1 -eq 1 ]]; then
local result=1
else
local result=0
fi
elif [[ "$OPT" == '^' ]]; then
if [[ $a1 -eq $b1 ]]; then
local result=1
else
local result=0
fi
else
return 1
fi
final="${result}${final}"
let i++
done
if [[ "${output}" == 'dec' ]]; then
bin2dec $(echo -e "$final" | xargs echo -n \
| sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g')
else
echo -e "$final" | xargs echo -n \
| sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g'
fi
}
function serials_num_generate() {
local START=$1
local END=$2
local FINAL
while [[ ${START} -le ${END} ]]
do
local FINAL="${FINAL} ${START}"
let START++
done
echo $FINAL
}
function prefix_to_bit_netmask() {
local prefix=$1;
local shift=$(( 32 - prefix ));
local bitmask=""
local i=0
while [[ ${i} -lt 32 ]]
do
local num=0
if [ $i -lt $prefix ]; then
local num=1
fi
local space=
if [ $(( i % 8 )) -eq 0 ]; then
space=" ";
fi
local bitmask="${bitmask}${space}${num}"
let i++
done
echo -e "$bitmask" | sed "s/\ /\\n/g" | grep -v '^$' >"${TEMP_DIR}/bitmask.txt"
echo -e "$bitmask"
unset i
}
function bit_netmask_to_wildcard_netmask() {
local wildcard_mask=
while read octect && [[ -n "${octect}" ]]
do
local octet=$(bin2dec ${octect})
local wildcard_mask="${wildcard_mask} $(( 255 - $octet ))"
done < "${TEMP_DIR}/bitmask.txt"
echo $wildcard_mask;
}
function check_net_boundary() {
local net=$1;
local wildcard_mask=$2;
local is_correct=1
local i=1
while [[ ${i} -le 4 ]]
do
local net_octet=$(echo $net | cut -d '.' -f $i)
local mask_octet=$(bit_netmask_to_wildcard_netmask | cut -d ' ' -f $i)
if [ $mask_octet -gt 0 ]; then
if [[ $(bit_calc "$(dec2bin $net_octet)" '&' \
"$(dec2bin $mask_octet)" 'dec') -ne 0 ]]; then
local is_correct=0;
fi
fi
let i++
done
echo $is_correct
unset i
}
function help_cidr_to_ips() {
echo ""
echo "转换CIDR规则地址为IP列表.
使用方法:
cidr_to_ips [OPTION(only one)] [STRING/FILENAME]
详细说明:
-h 显示帮助
-i 输入文件路径
-o 输出结果的文件路径
-l 输入CIDR列表(逗号分隔)
-f 强制检查network boundary
-i 从文件中读取 (不检查network boundary)
-b 从文件中读取 (同时检查network boundary)
举例:
cidr_to_ips -l 192.168.0.1/24
cidr-to-ips -l 192.168.0.1/24,10.10.0.0/28
cidr-to-ips -f 192.168.0.0/16
cidr-to-ips -i inputfile.txt
cidr-to-ips -b inputfile.txt
"
}
function cidr_to_ips() {
OPTIND=1
local START_TIME=$(date +%s)
local TEMP_DIR=${TEMP_DIR}
if [[ ! -d ${TEMP_DIR} ]]; then mkdir -p ${TEMP_DIR}; fi
while getopts 'fl:i:b:o:h' OPT
do
case $OPT in
f) local force='f';;
i) local INPUT_FILE=$OPTARG;;
b) local INPUT_FILE=$OPTARG; force='b';;
o) local OUTPUT_FILE=$OPTARG;;
l) local CIDR_LIST=$OPTARG;;
h) help_cidr_to_ips; exit;;
?) help_cidr_to_ips; exit;;
esac
done
echo -e "开始转换以下CIDR地址:"
cat "${INPUT_FILE}"
echo -e "\\n"
rm -f "${OUTPUT_FILE}"
if [[ -n "${CIDR_LIST}" ]]; then
echo -e "${CIDR_LIST}" | sed "s/,/\\n/g" >${INPUT_FILE}
fi
while read ip && [[ -n "${ip}" ]]
do
local net=$(echo $ip | cut -d '/' -f 1);
local prefix=$(echo $ip | cut -d '/' -f 2);
local do_processing=1
local bit_netmask=$(prefix_to_bit_netmask $prefix)
local wildcard_mask=$(bit_netmask_to_wildcard_netmask "$bit_netmask")
local is_net_boundary=$(check_net_boundary $net "$wildcard_mask")
if [[ "$force" = 'f' && $is_net_boundary -ne 1 \
|| "$force" = 'b' && $is_net_boundary -ne 1 ]]; then
read -p "Not a network boundary! Continue anyway (y/N)? " -n 1 -r
echo ## move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
local do_processing=1
else
local do_processing=0
fi
fi
if [[ $do_processing -eq 1 ]]; then
local str=
local i=1
while [[ ${i} -le 4 ]]
do
local range=$(echo $net | cut -d '.' -f $i)
local mask_octet=$(echo $wildcard_mask | cut -d ' ' -f $i)
if [[ "$mask_octet" -gt 0 ]]; then
local range="{$range..$(bit_calc "$(dec2bin $range)" '|' \
"$(dec2bin $mask_octet)" 'dec')}"
fi
local str="${str} $range"
let i++
done
echo -e "${str}" | while read a b c d
do
if [[ -n "$(echo "${a}" | grep '{')" ]]; then
local start_num=$(echo "${a}" | cut -d "{" -f2 \
| cut -d "." -f1 )
local end_num=$(echo "${a}" | cut -d "}" -f1 \
| awk -F "." '{print $(NF)}')
serials_num_generate $start_num $end_num \
| sed "s/\ /\\n/g" >${TEMP_DIR}/a.txt
else
echo "${a}" >${TEMP_DIR}/a.txt
fi
if [[ -n "$(echo "${b}" | grep '{')" ]]; then
local start_num=$(echo "${b}" | cut -d "{" -f2 \
| cut -d "." -f1 )
local end_num=$(echo "${b}" | cut -d "}" -f1 \
| awk -F "." '{print $(NF)}')
serials_num_generate $start_num $end_num \
| sed "s/\ /\\n/g" >${TEMP_DIR}/b.txt
else
echo "${b}" >${TEMP_DIR}/b.txt
fi
if [[ -n "$(echo "${c}" | grep '{')" ]]; then
local start_num=$(echo "${c}" | cut -d "{" -f2 \
| cut -d "." -f1 )
local end_num=$(echo "${c}" | cut -d "}" -f1 \
| awk -F "." '{print $(NF)}')
serials_num_generate $start_num $end_num \
| sed "s/\ /\\n/g" >${TEMP_DIR}/c.txt
else
echo "${c}" >${TEMP_DIR}/c.txt
fi
if [[ -n "$(echo "${d}" | grep '{')" ]]; then
local start_num=$(echo "${d}" | cut -d "{" -f2 \
| cut -d "." -f1 )
local end_num=$(echo "${d}" | cut -d "}" -f1 \
| awk -F "." '{print $(NF)}')
serials_num_generate $start_num $end_num \
| sed "s/\ /\\n/g" >${TEMP_DIR}/d.txt
else
echo "${d}" >${TEMP_DIR}/d.txt
fi
while read a && [[ -n ${a} ]]
do
while read b && [[ -n ${b} ]]
do
while read c && [[ -n ${c} ]]
do
while read d && [[ -n ${d} ]]
do
awk '{print "'${a}.'" "'${b}.'" "'${c}.'" $0}' \
>>"${OUTPUT_FILE}"
green "+\\c"
done < ${TEMP_DIR}/d.txt
done < ${TEMP_DIR}/c.txt
done < ${TEMP_DIR}/b.txt
done < ${TEMP_DIR}/a.txt
done
else
exit
fi
done < "${INPUT_FILE}"
echo -e "\033[0m"
END_TIME=$(date +%s)
echo -e "CIDR转IP列表运行总耗时 $((${END_TIME} - ${START_TIME})) 秒"
echo -e "共转换为 $(cat ${OUTPUT_FILE} | wc -l)个 IP地址, 转换后的IP列表保存在: ${OUTPUT_FILE}"
}
function check_ip() {
local IP=$1
local VALID_CHECK=$(echo ${IP} \
| awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}')
local RULE="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
if [[ -n "$(echo -e ${IP} | grep -E ${RULE})" ]]; then
if [[ "${VALID_CHECK}" == "yes" ]]; then
echo "IP ${IP} available."
else
echo "IP ${IP} not available!"
fi
else
echo "IP format error!"
fi
}
function get_cf_ip_list_udp() {
local META=$(curl -s https://speed.cloudflare.com/meta)
local ASN=$(parse_json_simple "${META}" asn)
local CITY=$(parse_json_simple "${META}" city)
local COUNTRY=$(parse_json_simple "${META}" country)
# 获取udpfile配置文件
local UDPFILE_CONF=$(curl -s --ipv4 --retry 3 \
https://service.udpfile.com\?asn\="${ASN}"\&city="${CITY}")
if [[ -z "${UDPFILE_CONF}" ]]; then
echo -e "CF解析节点获取失败, 退出任务"
exit 1
fi
echo -e "${UDPFILE_CONF}" >"${TEMP_DIR}/udpfile.txt"
# 获取cloudflare CDN IP列表
echo -e "${UDPFILE_CONF}" | sed '1,4d'
}
function get_cf_ip_list_official() {
local IP_LIST_FILE=$1
curl https://ghproxy.com/https://raw.githubusercontent.com/hansyao/breakwall/master/cf_ip_database.txt \
-o ${IP_LIST_FILE}
echo -e "检查cloudflare IP库是否下载成功"
if [[ -n "$(check_ip $(cat ${IP_LIST_FILE} | head -n 1) \
| grep -E "(error|not available)")" ]]; then
echo -e "cloudflare IP库下载失败,开始从cloudflare官网拉取CIDR规则文件进行本地转换"
echo -e "(转换结果会缓存为临时文件,除非设备重启,下次不会再重新转换)"
echo -e "本地转换耗时较长,请耐心等待......"
rm -f ${IP_LIST_FILE}
curl -s https://www.cloudflare.com/ips-v4 >${TEMP_DIR}/cf_cidr_list.txt
cidr_to_ips -i "${TEMP_DIR}/cf_cidr_list.txt" -o ${IP_LIST_FILE}
fi
}
function pack_loss_test() {
local CF_IP_LIST=$1
local PACK_LOSS_RESULT=$2
local EXPECT_IPS=$3
local PING_COUNT=${PING_COUNT}
local THREAD_NUMBER=${STATUS_THREAD_NUMBER}
local EXPECT_RATE=0
local TOTAL_IPS=$(echo -e "${CF_IP_LIST}" | wc -l)
echo "丢包率测试要求: ${PING_COUNT}次ping的丢包率<=${EXPECT_RATE}%"
local i=1
if [[ ${TOTAL_IPS} -lt ${THREAD_NUMBER} ]]; then
local j=1
else
local j=$(( ${TOTAL_IPS} / ${THREAD_NUMBER} ))
fi
local START_LINE=1
local END_LINE=$((${START_LINE} + ${THREAD_NUMBER} -1))
local PACK_RESULT_IPS=0
while [[ ${i} -le ${j} ]]
do
echo -e "${CF_IP_LIST}" | sed -n "${START_LINE},${END_LINE}p" \
>"${TEMP_DIR}/cf_ip_list.txt"
while read LINE && [[ -n "${LINE}" ]] && [[ ${PACK_RESULT_IPS} -lt ${EXPECT_IPS} ]]
do
{
if [[ -e ${PACK_LOSS_RESULT} ]]; then
local PACK_RESULT_IPS=$(cat ${PACK_LOSS_RESULT} | wc -l)
else
local PACK_RESULT_IPS=0
fi
if [[ ${PACK_RESULT_IPS} -gt ${EXPECT_IPS} ]]; then exit 0; fi
local PING_RESULT=$(ping -c ${PING_COUNT} -n -q "${LINE}")
local LOSS_RATE=$(echo -e "${PING_RESULT}" | grep "packet loss" | sed "s/,\ /\n/g" \
| grep "packet loss" | awk '{print $1}')
local DELAY=$(echo -e "${PING_RESULT}" | grep avg \
| awk -F "=" '{print $2}' | cut -d "/" -f2)
echo -e "${LOSS_RATE}(丢包率) ${DELAY}ms(${PING_COUNT}次ping平均延迟) ${LINE}"
if [[ $(echo "${LOSS_RATE}" | cut -d "%" -f1) -le ${EXPECT_RATE} ]]; then
echo -e "${LOSS_RATE}(丢包率) ${DELAY}ms(${PING_COUNT}次ping平均延迟) ${LINE}"\
>>"${PACK_LOSS_RESULT}"
fi
}&
if [[ -e ${PACK_LOSS_RESULT} ]]; then
local PACK_RESULT_IPS=$(cat ${PACK_LOSS_RESULT} | wc -l)
else
local PACK_RESULT_IPS=0
fi
done < "${TEMP_DIR}/cf_ip_list.txt"
wait
local START_LINE=$((${START_LINE} + ${THREAD_NUMBER}))
local END_LINE=$((${END_LINE} + ${THREAD_NUMBER}))
let i++
done
echo -e "筛选出 ${PACK_RESULT_IPS}个 节点IP地址满足丢包率小于或等于 ${EXPECT_RATE}"
}
function clash_config() {
local PREF_INI=$1
local POOL=$2
# 生成基本配置
local HEADER_CONF="${TEMP_DIR}/header.yaml"
cat > ${HEADER_CONF} <<EOF
port: 7890
socks-port: 7891
allow-lan: true
mode: Rule
log-level: silent
external-controller: 0.0.0.0:9090
EOF
# 生成代理组proxy_groups
local PROXY_GROUPS="${TEMP_DIR}/proxy_groups.yaml"
echo "proxy-groups:" >${PROXY_GROUPS}
cat "${PREF_INI}" | grep "^custom_proxy_group=" | while read LINE && [[ -n "${LINE}" ]]
do
local GROUP=$(echo -e "$LINE" | cut -d "=" -f2-)
local NAME=$(echo -e "${GROUP}" | awk -F "\`" '{print $1}')
local TYPE=$(echo -e "${GROUP}" | sed "s/${NAME}//g" | cut -d "\`" -f2)
local GROUP=$(echo -e "${GROUP}" | awk -F "\`" '{for (i=3;i<=NF;i++)printf("%s\t", $i);print ""}')
# 如果存在[]数组
local PROXY_GROUP1=$(echo -e "${GROUP}" | sed "s/\t/\n/g" | grep "\[]" | sed "s/\[]//g" \
| sed '/^[ ]*$/d' )
# 如果不存在[]数组
local PROXY_GROUP2=$(echo -e "${GROUP}" | sed "s/\t/\n/g" | grep -v "\[]" | sed "s/\[]//g")
if [[ -n "${PROXY_GROUP2}" ]]; then
local PROXY_LIST=$(cat ${POOL} | sed '1d' | awk -F "name:" '{print $2}' | cut -d "," -f1 \
| sed 's/^[ \t]*//g' | sed 's/[ \t]*$//g' | sed '/^[ ]*$/d' \
| grep -E "$(echo -e "${PROXY_GROUP2}" | sed -n '1p')")
fi
echo " - name: ${NAME}" >>${PROXY_GROUPS}
echo " type: ${TYPE}" >>${PROXY_GROUPS}
if [[ "${TYPE}" == 'url-test' || "${TYPE}" == 'load-balance' ]]; then
echo " url: $(echo -e "${PROXY_GROUP2}" | sed -n '2p')" >>${PROXY_GROUPS}
echo " interval: $(echo -e "${PROXY_GROUP2}" | sed -n '3p' \
| awk -F "," '{print $1}')" >>${PROXY_GROUPS}
echo " tolerance: $(echo -e "${PROXY_GROUP2}" | sed -n '3p' \
| awk -F "," '{print $(NF)}')" >>${PROXY_GROUPS}
fi
echo " proxies:" >>${PROXY_GROUPS}
echo -e "${PROXY_GROUP1} \\n ${PROXY_LIST}" \
| sed 's/^[ \t]*//g' | sed 's/[ \t]*$//g' | sed '/^[ ]*$/d' \
| awk '{print " - " $0}' >>${PROXY_GROUPS}
unset PROXY_LIST
done
# 生成规则表
local RULES="${TEMP_DIR}/tmp_rules.yaml"
local FINAL_RULES="${TEMP_DIR}/final_rules.yaml"
rm -f ${RULES}
cat "${PREF_INI}" | grep "^ruleset=" >${TEMP_DIR}/pref_tmp.ini
local i=1
while read LINE && [[ -n "${LINE}" ]]
do
unset GROUP
{
local LINE=$(echo -e "${LINE}" | cut -d "=" -f2)
local GROUP=$(echo -e "${LINE}" | cut -d "," -f1)
local URL=$(echo -e "${LINE}" | cut -d "," -f2)
if [[ -n "$(echo -e "$URL" | grep 'http')" ]]; then
echo "正在下载远程规则 ${URL}"
curl -s "${URL}" | grep -Ev "(^\ *$|\#)" | awk -F "," '{print $1","$2",""'"${GROUP}"'"","$3}' >"${TEMP_DIR}/split_rule_remote_${i}.txt"
else
echo "应用本地规则 ${LINE}"
echo -e $(echo -e "${LINE}" | cut -d "," -f2- | sed 's/\[]//g'),"${GROUP}" >"${TEMP_DIR}/split_rule_local_${i}.txt"
fi
}&
let i++
done < ${TEMP_DIR}/pref_tmp.ini
wait
local SPLIT_RULE_LIST=$(ls -l ${TEMP_DIR}/* | grep split_rule | awk '{print $(NF)}')
echo -e "${SPLIT_RULE_LIST}" | while read SPLIT_RULE && [[ -n "${SPLIT_RULE}" ]]
do
cat ${SPLIT_RULE} >>${RULES}
rm -f ${SPLIT_RULE}
done
echo -e "规则去重并移除不支持的规则格式"
sed -i "s/,$//g" ${RULES}
echo "rules:" >${FINAL_RULES}
local INCL="(DOMAIN\|DOMAIN\-KEYWORD\|DOMAIN\-SUFFIX\|GEOIP\|IP-CIDR\|IP-CIDR6\|FINAL\|PROCESS-NAME)"
cat ${RULES} | grep "${INCL}" | sed "s/FINAL,/MATCH,/g" \
| sort -n | uniq | awk '{print " - "$0}' >>${FINAL_RULES}
# 合并clash配置文件
cat >"${CLASH_CONFIG}"<< EOF
$(cat ${HEADER_CONF})
$(cat ${POOL})
$(cat ${PROXY_GROUPS})
$(cat ${FINAL_RULES})
EOF
}
function pool_combine() {
local POOL_CF=$1
local POOL_COMBINED_CONF=$2
if [[ -d "${RULE_PATH_OPENCLASH}" ]]; then
local PROXY_FILE_LIST=$(ls -l ${RULE_PATH_OPENCLASH}/* \
| grep -v $(echo -e "${CLASH_CONFIG}" | awk -F "/" '{print $(NF)}') \
| grep '\.yaml' | awk '{print $(NF)}')
elif [[ -d "${RULE_PATH_MERLINCLASH}" ]]; then
local PROXY_FILE_LIST=$(ls -l ${RULE_PATH_MERLINCLASH}/* \
| grep -v $(echo -e "${CLASH_CONFIG}" | awk -F "/" '{print $(NF)}') \
| grep '\.yaml' | awk '{print $(NF)}')
elif [[ -d "${RULE_PATH_OTHERS}" ]]; then
local PROXY_FILE_LIST=$(ls -l ${RULE_PATH_OTHERS}/* \
| grep -v $(echo -e "${CLASH_CONFIG}" | awk -F "/" '{print $(NF)}') \
| grep '\.yaml' | awk '{print $(NF)}')
fi
rm -f "${TEMP_DIR}/pool_combined_tmp.yaml"
cat "${POOL_CF}" | grep "\- {" >>"${TEMP_DIR}/pool_combined_tmp.yaml"
echo -e "${PROXY_FILE_LIST}" | while read PROXY_FILE && [[ -n "${PROXY_FILE}" ]]
do
cat "${PROXY_FILE}" | grep "\- {" >>"${TEMP_DIR}/pool_combined_tmp.yaml"
done
# 去重
echo "proxies:" >"${POOL_COMBINED_CONF}"
cat "${TEMP_DIR}/pool_combined_tmp.yaml" | sort -n | uniq >>"${POOL_COMBINED_CONF}"
rm -f "${TEMP_DIR}/pool_combined_tmp.yaml"
}
function speed_test() {
# 基本参数设置
local IP_LIST_FILE=/tmp/ip_list.txt
local TEMP_DIR=${TEMP_DIR}
local EXPECT_IPS=$1
local EXPECT_BANDWIDTH=$2
local ALGORITHM=$3
local SAMPLE_IPS=$4
local PACK_LOSS_TEST=$5
local SPEED_TEST=$6
local RESULT_FILE=$7
local SPEED_THREAD_NUMBER=${SPEED_THREAD_NUMBER}
local STATUS_THREAD_NUMBER=${STATUS_THREAD_NUMBER}
local BASEPATH=$(cd `dirname $0`; pwd)
# 环境初始化
local START_TIME=$(date +%s)
if [[ ${ALGORITHM} -eq 1 ]]; then
echo -e "执行获取节点IP算法一: 直接从cloudflare官方获取"
# 第一步 将Cloudflare的IP段生成IP地址清单
echo -e "开始检查Cloudflarae IP库"
if [[ ! -e "${IP_LIST_FILE}" ]]; then
echo -e "未发现cloudflare本地IP库, 开始远程下载"
get_cf_ip_list_official "${IP_LIST_FILE}"
else
if [[ -n "$(check_ip $(cat ${IP_LIST_FILE} | head -n 1) \
| grep 'error\|not available')" ]];then
echo -e "IP库异常, 开始远程下载"
get_cf_ip_list_official "${IP_LIST_FILE}"
fi
fi
local TOTAL_IPS=$(cat "${IP_LIST_FILE}" | wc -l)
echo -e "查询到Cloudflare IP库共有 ${TOTAL_IPS}个 IP地址"
# 第二步 从第一步生成的IP地址清单中随机挑选 ${SAMPLE_IPS} 条
echo -e "随机挑选 ${SAMPLE_IPS}个 IP进行有效性测试"
shuf -n ${SAMPLE_IPS} "${IP_LIST_FILE}" >${TEMP_DIR}/selected_iplist_random_tmp.txt
# 排除已经扫描过的IP
if [[ -e "${TEMP_DIR}/history_scanned_ips.txt" ]]; then
diff -B -T -w ${TEMP_DIR}/history_scanned_ips.txt \
"${TEMP_DIR}/selected_iplist_random_tmp.txt" \
| grep -E "(\+|>)$(printf '\t')" | awk '{print $(NF)}' \
>>${TEMP_DIR}/selected_iplist_random.txt
else
cat ${TEMP_DIR}/selected_iplist_random_tmp.txt \
>>${TEMP_DIR}/selected_iplist_random.txt
fi
elif [[ ${ALGORITHM} -eq 2 ]]; then
echo -e "执行获取节点IP算法二: 从service.udpfile.com获取"
rm -f "${TEMP_DIR}/udpfile.txt"
rm -f "${TEMP_DIR}/udpfile_ip_list.txt"