2
0
mirror of https://github.com/mozilla/cipherscan.git synced 2024-11-22 14:23:41 +01:00

testtop1m.sh: correct counting of background jobs

`jobs` command returns multiple lines for a jobs with `if` so counting
number of background jobs was off
This commit is contained in:
Hubert Kario 2014-04-26 22:43:44 +02:00 committed by Hubert Kario
parent 92851d7c74
commit 8817a7b1c8

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
parallel=50 parallel=50
max_bg=400 max_bg=50
[ ! -e "results" ] && mkdir results [ ! -e "results" ] && mkdir results
function wait_for_jobs() { function wait_for_jobs() {
@ -13,6 +13,20 @@ function wait_for_jobs() {
done done
} }
function scan_host() {
tcping -u 10000000 $1 443;
if [ $? -gt 0 ];then
tcping -u 10000000 www.$1 443;
if [ $? -gt 0 ]; then
return;
else
../cipherscan -json www.$1:443 > results/www.$t
return;
fi;
fi;
../cipherscan -json $t:443 > results/$t
}
i=0 i=0
count=$(wc -l top-1m.csv | awk '{print $1}') count=$(wc -l top-1m.csv | awk '{print $1}')
while [ $i -lt $count ] while [ $i -lt $count ]
@ -20,16 +34,7 @@ do
echo processings sites $i to $((i + parallel)) echo processings sites $i to $((i + parallel))
for t in $(tail -$(($count - $i)) top-1m.csv | head -$parallel |cut -d ',' -f 2) for t in $(tail -$(($count - $i)) top-1m.csv | head -$parallel |cut -d ',' -f 2)
do do
(tcping -u 10000000 $t 443; (scan_host $t)&
if [ $? -gt 0 ];then
tcping -u 10000000 www.$t 443;
if [ $? -gt 0 ]; then
continue;
else
../cipherscan -json www.$t:443 > results/www.$t
continue;
fi;
fi;../cipherscan -json $t:443 > results/$t )&
done done
i=$(( i + parallel)) i=$(( i + parallel))
wait_for_jobs $max_bg wait_for_jobs $max_bg