summaryrefslogtreecommitdiff
path: root/tor-exit-ssl-check-many
diff options
context:
space:
mode:
Diffstat (limited to 'tor-exit-ssl-check-many')
-rwxr-xr-xtor-exit-ssl-check-many53
1 files changed, 47 insertions, 6 deletions
diff --git a/tor-exit-ssl-check-many b/tor-exit-ssl-check-many
index 9f5a1e7..69dac4a 100755
--- a/tor-exit-ssl-check-many
+++ b/tor-exit-ssl-check-many
@@ -34,16 +34,26 @@ usage() {
echo " -h print this help"
}
+
+TORPID=""
+CHECKDIR=""
+
+cleanup() {
+ [ -z "$TORPID" ] || kill "$TORPID" || true
+ [ -z "$CHECKDIR" ] || rm -rf "$CHECKDIR" || true
+}
+
+
+
AUTH=tor.noreply.org
PER_RUN=60
-DATADIR=$(mktemp -d "/tmp/tor-checks-XXXXXX")
-DUMPFILE=$(tempfile)
DEFAULT_CHECKHOSTS="www.torproject.org"
LOGDIR="tor-exit-ssl-check-many.log"
CACHEDIR="tor-exit-ssl-check-many.cache"
MAIL=0
-
-trap "rm -rf '$DATADIR' '$DUMPFILE'" EXIT
+CHECKDIR=$(mktemp -d "/tmp/cert-check-many-XXXXXX")
+DUMPFILE="$CHECKDIR/dump"
+trap 'cleanup' EXIT
mkdir -vp "$LOGDIR"
mkdir -vp "$CACHEDIR"
@@ -100,7 +110,7 @@ run_some_checks() {
head -n "$PER_RUN" | \
while read fpr; do
[ "$VERBOSE" = 0 ] || echo -n "Checking $host at $fpr..."
- if tor-exit-ssl-check -c "$CACHEDIR" -d "$DATADIR" "$fpr" $host > "$DUMPFILE" 2>&1; then
+ if tor-exit-ssl-check -c "$CACHEDIR" -C "$CONTROLSOCKET" "$fpr" $host > "$DUMPFILE" 2>&1; then
ecode=0
else
ecode="$?"
@@ -132,7 +142,38 @@ run_some_checks() {
done
}
+
+start_tor() {
+ local pidfile="$CHECKDIR/pid"
+
+ if command -v tor > /dev/null; then
+ tor="tor"
+ elif [ -x /usr/sbin/tor ]; then
+ tor="/usr/sbin/tor"
+ else
+ echo >&2 "Cannot find tor executable"
+ exit 1
+ fi
+
+ local datadir="$CHECKDIR/tor"
+ CONTROLSOCKET="$CHECKDIR/sock"
+ cat > "$CHECKDIR/torrc" << EOF
+DataDirectory $datadir
+RunAsDaemon 1
+SocksPort auto
+PidFile $pidfile
+SafeLogging 0
+ControlSocket $CONTROLSOCKET
+StrictNodes 1
+EOF
+
+ mkdir -p -m 0700 "$datadir"
+ "$tor" --hush -f "$CHECKDIR/torrc"
+ TORPID="$(cat $pidfile)"
+}
+
+start_tor
while : ; do
run_some_checks
- sleep 15
+ sleep 60
done