-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck_proxy.sh
65 lines (59 loc) · 1.14 KB
/
check_proxy.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
#!/bin/bash
#get proxy list
declare check_threads=10
declare line
declare times
declare ip
declare port
declare i
declare j
declare mod
function quit() {
exit "$1"
}
#echo "start check proxy's functionality..."
#retarget the input file to stdin
if [ "$#" -gt "0" ]
then
exec 0<$1
else
exec 1>&2
echo "usage: bash $0 proxyListFile.txt"
echo "error: must have one input arg"
quit 1
fi
#check proxy's functionality
times=0
while read line
do
times=$((times+1))
j=0
for i in `echo $line | tr ' ' '\n' | grep -E '^[^\s].*$'`
do
j=$((j+1))
if [ "$j" -eq 1 ]
then
ip=$i
else
port=$i
fi
done
#echo "times=$times ip=$ip port=$port"
# start test
if GET -t 5 -p "http://$ip:$port" "http://baidu.com" &>/dev/null
then
echo "$ip $port"
echo ":) ip=$ip port=$port " &>/dev/null
else
echo "invalid ip=$ip port=$port : please check ip:host or network" &>/proc/self/fd/2
fi &
mod=$((times%check_threads))
if [ "$mod" -eq "0" ]
then
wait
fi
done
#close the fd of input file
exec 0>&-
quit 0
#exit