Skip to content

Commit 0b700ee

Browse files
authored
Create test_trackers.sh
1 parent cf22332 commit 0b700ee

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

test_trackers.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# 检查是否提供了文件名作为参数
4+
if [ "$#" -ne 1 ]; then
5+
echo "Usage: $0 <file>"
6+
exit 1
7+
fi
8+
9+
input_file="$1"
10+
output_file="trackers_best.txt"
11+
12+
# 检查文件是否存在
13+
if [ ! -f "$input_file" ]; then
14+
echo "Error: File not found."
15+
exit 1
16+
fi
17+
18+
# 清空输出文件
19+
> "$output_file"
20+
21+
# 读取文件并逐行处理
22+
while IFS= read -r tracker; do
23+
protocol=$(echo "$tracker" | grep -oE '^[a-z]+')
24+
25+
case $protocol in
26+
http)
27+
if curl -s -f -m 1 "$tracker" &>/dev/null; then
28+
echo "Success: $tracker"
29+
echo "$tracker" >> "$output_file"
30+
else
31+
echo "Failed: $tracker"
32+
fi
33+
;;
34+
https)
35+
if curl -s -f -m 1 "$tracker" &>/dev/null; then
36+
echo "Success: $tracker"
37+
echo "$tracker" >> "$output_file"
38+
else
39+
echo "Failed: $tracker"
40+
fi
41+
;;
42+
udp)
43+
host=$(echo "$tracker" | cut -d'/' -f3)
44+
port=$(echo "$host" | cut -d':' -f2)
45+
host=$(echo "$host" | cut -d':' -f1)
46+
if nc -zuv -w 1 "$host" "$port" &>/dev/null; then
47+
echo "Success: $tracker"
48+
echo "$tracker" >> "$output_file"
49+
else
50+
echo "Failed: $tracker"
51+
fi
52+
;;
53+
wss)
54+
if wscat -c "$tracker" --timeout 1 &>/dev/null; then
55+
echo "Success: $tracker"
56+
echo "$tracker" >> "$output_file"
57+
else
58+
echo "Failed: $tracker"
59+
fi
60+
;;
61+
*)
62+
echo "Unknown protocol: $protocol"
63+
;;
64+
esac
65+
done < "$input_file"
66+
67+
echo "Testing complete."

0 commit comments

Comments
 (0)