添加一个批量代理测速工具

This commit is contained in:
2025-04-03 14:48:36 +08:00
parent 309aa6d0e2
commit 175f55c24f
3 changed files with 392 additions and 0 deletions

View File

View File

@@ -0,0 +1,220 @@
110.40.82.248|10000|bx8365|242469
110.40.82.248|10001|eu9328|493237
110.40.82.248|10002|tn6479|247579
110.40.82.248|10003|yx8657|232695
110.40.82.248|10004|ru8396|776448
110.40.82.248|10005|hk2957|897393
110.40.82.248|10006|fk5569|979277
110.40.82.248|10007|nn8859|622638
110.40.82.248|10008|kf4546|927798
110.40.82.248|10009|xd3275|763356
110.40.82.248|10010|jj3257|343429
110.40.82.248|10011|jg2356|944246
110.40.82.248|10012|nc8746|545784
110.40.82.248|10013|vu8328|763628
110.40.82.248|10014|cn2486|725339
110.40.82.248|10015|sn7499|959423
110.40.82.248|10016|am3336|995524
110.40.82.248|10017|tv2487|756939
110.40.82.248|10018|af3324|395465
110.40.82.248|10019|jr3978|279833
110.40.82.248|10020|cd8436|463733
110.40.82.248|10021|cx5686|926872
110.40.82.248|10022|gy7228|769775
110.40.82.248|10023|kk5434|494548
110.40.82.248|10024|fs8824|573884
110.40.82.248|10025|ta3545|994543
110.40.82.248|10026|nu6993|346966
110.40.82.248|10027|qm6599|797659
110.40.82.248|10028|ag3955|322752
110.40.82.248|10029|rp5937|553687
110.40.82.248|10030|qx5558|967645
110.40.82.248|10031|bt4494|426495
110.40.82.248|10032|ng6876|235567
110.40.82.248|10033|un6855|386394
110.40.82.248|10034|yu8965|377993
110.40.82.248|10035|cc5532|366957
110.40.82.248|10036|mc8998|388652
110.40.82.248|10037|hy9866|953847
110.40.82.248|10038|zy3654|677364
110.40.82.248|10039|bw7278|573267
110.40.82.248|10040|cu9527|985595
110.40.82.248|10041|pg9832|843382
110.40.82.248|10042|qm3297|899273
110.40.82.248|10043|gs7356|282863
110.40.82.248|10044|gm7877|432425
110.40.82.248|10045|hm4697|758247
110.40.82.248|10046|tf9359|633623
110.40.82.248|10047|wb8726|863766
110.40.82.248|10048|ah2743|878986
110.40.82.248|10049|pq3996|363742
110.40.82.248|10050|nn3345|632583
110.40.82.248|10051|sc5535|673946
110.40.82.248|10052|rm3356|357357
110.40.82.248|10053|je4855|682973
110.40.82.248|10054|mk9733|697479
110.40.82.248|10055|zk5548|394528
110.40.82.248|10056|et7965|793473
110.40.82.248|10057|xt9423|898449
110.40.82.248|10058|qa5527|645327
110.40.82.248|10059|um2688|289728
110.40.82.248|10060|nk5828|242476
110.40.82.248|10061|yx9554|856994
110.40.82.248|10062|ns4939|759352
110.40.82.248|10063|vb7485|874824
110.40.82.248|10064|zb2372|528727
110.40.82.248|10065|ar6253|955428
110.40.82.248|10066|fr9365|642756
110.40.82.248|10067|zd2644|943294
110.40.82.248|10068|hs4394|675892
110.40.82.248|10069|sh2332|489286
110.40.82.248|10070|cd5293|634294
110.40.82.248|10071|gn6398|839753
110.40.82.248|10072|fc4557|664265
110.40.82.248|10073|ay3762|247893
110.40.82.248|10074|ka2877|796724
110.40.82.248|10075|du8626|278792
110.40.82.248|10076|wq4238|569397
110.40.82.248|10077|ug4962|992737
110.40.82.248|10078|cn4882|642566
110.40.82.248|10079|tq6329|377375
110.40.82.248|10080|dp9622|765854
110.40.82.248|10081|kr8825|849629
110.40.82.248|10082|uk9472|869689
110.40.82.248|10083|hm3646|892348
110.40.82.248|10084|bg9252|497243
110.40.82.248|10085|uh6946|739494
110.40.82.248|10086|rg5298|587796
110.40.82.248|10087|tj7977|726453
110.40.82.248|10088|ze3987|222244
110.40.82.248|10089|em8588|227953
110.40.82.248|10090|tr6446|679972
110.40.82.248|10091|gk8868|298239
110.40.82.248|10092|ut3822|668853
110.40.82.248|10093|pm6427|672442
110.40.82.248|10094|gb2833|755822
110.40.82.248|10095|zm6949|369698
110.40.82.248|10096|xq2658|852574
110.40.82.248|10097|qe8839|464228
110.40.82.248|10098|fp2923|937235
110.40.82.248|10099|xc6925|999539
110.40.82.248|10100|wa8574|732452
110.40.82.248|10101|yx8465|375486
110.40.82.248|10102|ww5494|739866
110.40.82.248|10103|jr7442|567485
110.40.82.248|10104|sd6985|959745
110.40.82.248|10105|xb2244|595966
110.40.82.248|10106|yn7857|372255
110.40.82.248|10107|vw4566|538227
110.40.82.248|10108|pv4723|686467
110.40.82.248|10109|hu8226|222586
110.40.82.248|10110|zr6555|863735
110.40.82.248|10111|rw9996|565957
110.40.82.248|10112|fb4287|549768
110.40.82.248|10113|av8488|877575
110.40.82.248|10114|xv2597|747758
110.40.82.248|10115|bv6832|434947
110.40.82.248|10116|zx3462|674699
110.40.82.248|10117|et4423|272678
110.40.82.248|10118|mr6542|974889
110.40.82.248|10119|df4937|259752
110.40.82.248|10120|rb5549|483455
110.40.82.248|10121|pf6353|588782
110.40.82.248|10122|gp2463|979239
110.40.82.248|10123|zn4727|939486
110.40.82.248|10124|nc8972|223754
110.40.82.248|10125|uc6742|568289
110.40.82.248|10126|wf5342|225866
110.40.82.248|10127|pk6252|767436
110.40.82.248|10128|kg4699|665633
110.40.82.248|10129|rr4552|433777
110.40.82.248|10130|bb4524|465625
110.40.82.248|10131|tj6876|789928
110.40.82.248|10132|je6786|579265
110.40.82.248|10133|jd2567|679592
110.40.82.248|10134|ay5885|592344
110.40.82.248|10135|xt3862|866283
110.40.82.248|10136|nb7497|683947
110.40.82.248|10137|nx2353|256249
110.40.82.248|10138|qv7433|664945
110.40.82.248|10139|py2642|833672
110.40.82.248|10140|ap2489|568855
110.40.82.248|10141|td8773|266242
110.40.82.248|10142|xw2452|593488
110.40.82.248|10143|ff5337|954543
110.40.82.248|10144|tz9987|963433
110.40.82.248|10145|fb8376|985273
110.40.82.248|10146|su2894|323982
110.40.82.248|10147|nb7495|823237
110.40.82.248|10148|yg2564|592488
110.40.82.248|10149|kn9899|227429
110.40.82.248|10150|cg4848|684686
110.40.82.248|10151|tn2256|249727
110.40.82.248|10152|ej3365|335369
110.40.82.248|10153|gx4888|279465
110.40.82.248|10154|hx7765|876632
110.40.82.248|10155|fm7674|254868
110.40.82.248|10156|cv7899|724934
110.40.82.248|10157|za7794|492886
110.40.82.248|10158|es6893|452285
110.40.82.248|10159|wt6853|675724
110.40.82.248|10160|av6876|758346
110.40.82.248|10161|mx7959|885764
110.40.82.248|10162|dy6887|388742
110.40.82.248|10163|nj8722|754387
110.40.82.248|10164|hc9946|863228
110.40.82.248|10165|qz9557|235287
110.40.82.248|10166|ge3847|927394
110.40.82.248|10167|cy8372|767252
110.40.82.248|10168|jj7654|982787
110.40.82.248|10169|zk8335|959346
110.40.82.248|10170|xn5586|639796
110.40.82.248|10171|ad6755|374686
110.40.82.248|10172|ks4839|489756
110.40.82.248|10173|yc9737|546796
110.40.82.248|10174|aq2328|853237
110.40.82.248|10175|wg7776|358652
110.40.82.248|10176|px4656|596576
110.40.82.248|10177|xs2728|453736
110.40.82.248|10178|gy4535|876755
110.40.82.248|10179|gb5937|723928
110.40.82.248|10180|pr2285|748893
110.40.82.248|10181|xd9847|336452
110.40.82.248|10182|td9655|785479
110.40.82.248|10183|rd4335|634744
110.40.82.248|10184|zx5458|674622
110.40.82.248|10185|xq8773|253948
110.40.82.248|10186|cs2696|496264
110.40.82.248|10187|at6665|653586
110.40.82.248|10188|eq7974|549797
110.40.82.248|10189|ty9272|772364
110.40.82.248|10190|tc2559|569529
110.40.82.248|10191|vq7798|855826
110.40.82.248|10192|xa4844|942872
110.40.82.248|10193|gy5679|996892
110.40.82.248|10194|xx7573|242397
110.40.82.248|10195|sg5662|545365
110.40.82.248|10196|be3787|924628
110.40.82.248|10197|pz6235|278446
110.40.82.248|10198|rh9632|349377
110.40.82.248|10199|xr2236|446398
110.40.82.248|10200|gf7455|288766
110.40.82.248|10201|yy5269|687478
110.40.82.248|10202|am7328|282833
110.40.82.248|10203|nh5229|759947
110.40.82.248|10204|hm5592|674869
110.40.82.248|10205|zj5449|622724
110.40.82.248|10206|uv8246|773676
110.40.82.248|10207|yv4955|253927
110.40.82.248|10208|er6533|932487
110.40.82.248|10209|ab8686|938948
110.40.82.248|10210|cu8395|495276
110.40.82.248|10211|nx8453|822793
110.40.82.248|10212|xv3389|885536
110.40.82.248|10213|yj9724|798479
110.40.82.248|10214|uz7896|435885
110.40.82.248|10215|hm9372|243792
110.40.82.248|10216|he7489|387683
110.40.82.248|10217|aw8368|956565
110.40.82.248|10218|cf4883|976237
110.40.82.248|10219|ur6422|388325

172
scripts/speed-tool/speed.sh Normal file
View File

@@ -0,0 +1,172 @@
#!/bin/bash
# 检查是否提供了URL参数
if [ $# -eq 0 ]; then
echo "使用方法: $0 <要测试的URL>"
exit 1
fi
TARGET_URL="$1"
LINKS_FILE="$(dirname "$0")/links.txt"
HIGH_LATENCY_THRESHOLD=400 # 高延迟阈值修改为400毫秒
TIMEOUT=10 # curl 超时时间,单位秒
MAX_RETRIES=1 # 失败重试次数
# 检查links.txt文件是否存在
if [ ! -f "$LINKS_FILE" ]; then
echo "错误: $LINKS_FILE 文件不存在"
exit 1
fi
echo "开始测试代理速度目标URL: $TARGET_URL"
echo "--------------------------------------"
# 初始化变量
total_latency=0
count=0
success_count=0
fail_count=0
retry_success_count=0
high_latency_proxies=""
failed_proxies=""
# 读取并测试每个代理
while IFS='|' read -r ip port username password || [ -n "$ip" ]; do
# 跳过空行和注释行
[[ -z "$ip" || "$ip" =~ ^# ]] && continue
# 去除可能的空白字符
ip=$(echo "$ip" | tr -d '[:space:]')
port=$(echo "$port" | tr -d '[:space:]')
username=$(echo "$username" | tr -d '[:space:]')
password=$(echo "$password" | tr -d '[:space:]')
proxy_url="http://$username:$password@$ip:$port"
echo -n "测试代理: $ip:$port ... "
# 测试逻辑封装成函数以便重试
test_proxy() {
local start_time=$(date +%s%N)
local response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout $TIMEOUT --max-time $TIMEOUT -x "$proxy_url" "$TARGET_URL" 2>/dev/null)
local end_time=$(date +%s%N)
local latency=0
if [ "$response" = "200" ]; then
latency=$(( (end_time - start_time) / 1000000 ))
echo "$response $latency"
else
echo "$response 0"
fi
}
# 第一次尝试
count=$((count + 1))
result=$(test_proxy)
response=$(echo $result | cut -d ' ' -f 1)
latency=$(echo $result | cut -d ' ' -f 2)
# 判断是否需要重试
if [ "$response" != "200" ]; then
echo -n "失败 - HTTP状态码: $response,正在重试... "
# 重试
result=$(test_proxy)
response=$(echo $result | cut -d ' ' -f 1)
latency=$(echo $result | cut -d ' ' -f 2)
if [ "$response" = "200" ]; then
retry_success_count=$((retry_success_count + 1))
fi
fi
# 处理最终结果
if [ "$response" = "200" ]; then
echo "成功 - 延迟: ${latency}ms"
# 累加总延迟
total_latency=$((total_latency + latency))
success_count=$((success_count + 1))
# 检查是否为高延迟代理
if [ $latency -gt $HIGH_LATENCY_THRESHOLD ]; then
high_latency_proxies="${high_latency_proxies}$ip:$port (${latency}ms)\n"
fi
else
echo "最终失败 - HTTP状态码: $response"
fail_count=$((fail_count + 1))
failed_proxies="${failed_proxies}$ip:$port (状态码: $response)\n"
fi
done < "$LINKS_FILE"
echo "--------------------------------------"
# 输出统计结果
echo "测试结果汇总:"
echo "总测试代理数量: $count"
echo "成功代理数量: $success_count (含重试成功: $retry_success_count)"
echo "失败代理数量: $fail_count"
echo "成功率: $(( success_count * 100 / count ))%"
if [ $success_count -gt 0 ]; then
average_latency=$(( total_latency / success_count ))
echo "平均延迟: ${average_latency}ms"
if [ -n "$high_latency_proxies" ]; then
echo -e "\n高延迟代理 (>${HIGH_LATENCY_THRESHOLD}ms):"
echo -e "$high_latency_proxies"
else
echo -e "\n没有发现高延迟代理。"
fi
fi
if [ -n "$failed_proxies" ]; then
echo -e "\n连接失败的代理:"
echo -e "$failed_proxies"
fi
# 输出延迟分布情况
if [ $success_count -gt 0 ]; then
echo -e "\n延迟分布统计:"
# 重新统计以生成延迟分布
low_latency=0 # <100ms
medium_latency=0 # 100-200ms
high_latency=0 # 200-400ms
very_high_latency=0 # >400ms
while IFS='|' read -r ip port username password || [ -n "$ip" ]; do
# 跳过空行和注释行
[[ -z "$ip" || "$ip" =~ ^# ]] && continue
# 去除可能的空白字符
ip=$(echo "$ip" | tr -d '[:space:]')
port=$(echo "$port" | tr -d '[:space:]')
username=$(echo "$username" | tr -d '[:space:]')
password=$(echo "$password" | tr -d '[:space:]')
proxy_url="http://$username:$password@$ip:$port"
# 只测量一次以获取延迟数据,不进行重试统计
start_time=$(date +%s%N)
response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout $TIMEOUT --max-time $TIMEOUT -x "$proxy_url" "$TARGET_URL" 2>/dev/null)
end_time=$(date +%s%N)
if [ "$response" = "200" ]; then
latency=$(( (end_time - start_time) / 1000000 ))
if [ $latency -lt 100 ]; then
low_latency=$((low_latency + 1))
elif [ $latency -lt 200 ]; then
medium_latency=$((medium_latency + 1))
elif [ $latency -lt 400 ]; then
high_latency=$((high_latency + 1))
else
very_high_latency=$((very_high_latency + 1))
fi
fi
done < "$LINKS_FILE"
echo " < 100ms: $low_latency ($(( low_latency * 100 / success_count ))%)"
echo "100-200ms: $medium_latency ($(( medium_latency * 100 / success_count ))%)"
echo "200-400ms: $high_latency ($(( high_latency * 100 / success_count ))%)"
echo " > 400ms: $very_high_latency ($(( very_high_latency * 100 / success_count ))%)"
fi