libevent: updated to 2.0.22
[tomato.git] / release / src-rt-6.x.4708 / router / dnscrypt / resolvers-check.sh
blob94f80566b2f863c01d6d2570416b19272985235f
1 #! /bin/sh
3 RESOLVERS_LIST=dnscrypt-resolvers.csv
4 ONLINE_RESOLVERS_LIST=dnscrypt-online-resolvers.csv
5 DNSCRYPT_PROXY=dnscrypt-proxy
6 MARGIN=720
7 CSV_FILE="$(dirname $0)/${RESOLVERS_LIST}"
9 tmpfile=$(mktemp .${ONLINE_RESOLVERS_LIST}.XXXXXXXXXXXX) || exit 1
10 trap "rm -f ${tmpfile}" EXIT
12 if which csvlint > /dev/null; then
13 csvlint "$RESOLVERS_LIST" || echo "*** Invalid CSV file ***" >&2
16 exec < "$RESOLVERS_LIST"
17 exec > "$tmpfile"
19 read header
20 echo "$header" | egrep -q '^Name,' || echo "*** Invalid CSV file ***" >&2
22 echo "$header"
24 while read line; do
25 resolver_name=$(echo "$line" | cut -d, -f1)
26 eval "${DNSCRYPT_PROXY} -L ${CSV_FILE} -R ${resolver_name} -t ${MARGIN} -m 1"
27 if [ $? -eq 0 ]; then
28 echo "$line"
29 echo "+ ${resolver_name} - OK" >&2
30 else
31 echo "- ${resolver_name} - Failed" >&2
33 done
35 mv -f "$tmpfile" "$ONLINE_RESOLVERS_LIST"