-
Notifications
You must be signed in to change notification settings - Fork 119
/
test_trackers.sh
67 lines (60 loc) · 1.71 KB
/
test_trackers.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
#!/bin/bash
# 检查是否提供了文件名作为参数
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <file>"
exit 1
fi
input_file="$1"
output_file="trackers_best.txt"
# 检查文件是否存在
if [ ! -f "$input_file" ]; then
echo "Error: File not found."
exit 1
fi
# 清空输出文件
> "$output_file"
# 读取文件并逐行处理
while IFS= read -r tracker; do
protocol=$(echo "$tracker" | grep -oE '^[a-z]+')
case $protocol in
http)
if curl -s -f -m 1 "$tracker" &>/dev/null; then
echo "Success: $tracker"
echo "$tracker" >> "$output_file"
else
echo "Failed: $tracker"
fi
;;
https)
if curl -s -f -m 1 "$tracker" &>/dev/null; then
echo "Success: $tracker"
echo "$tracker" >> "$output_file"
else
echo "Failed: $tracker"
fi
;;
udp)
host=$(echo "$tracker" | cut -d'/' -f3)
port=$(echo "$host" | cut -d':' -f2)
host=$(echo "$host" | cut -d':' -f1)
if nc -zuv -w 1 "$host" "$port" &>/dev/null; then
echo "Success: $tracker"
echo "$tracker" >> "$output_file"
else
echo "Failed: $tracker"
fi
;;
wss)
if wscat -c "$tracker" --timeout 1 &>/dev/null; then
echo "Success: $tracker"
echo "$tracker" >> "$output_file"
else
echo "Failed: $tracker"
fi
;;
*)
echo "Unknown protocol: $protocol"
;;
esac
done < "$input_file"
echo "Testing complete."