diff options
author | Peter Palfrader <peter@palfrader.org> | 2013-07-20 13:23:36 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2013-07-20 13:23:36 +0000 |
commit | 4fb3df8a94f20b6ea2c200ee52d3a20e4199eb27 (patch) | |
tree | ad260d2de1cf19d4f00158cf5f45fee22ab5369f /tor-exit-ssl-check | |
parent | 13e948668a511b1af30eb81a3c9c8bc8a036fb40 (diff) |
Support passing a running tor to tor-exit-ssl-check and have tor-exit-ssl-check-many use that
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@640 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'tor-exit-ssl-check')
-rwxr-xr-x | tor-exit-ssl-check | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/tor-exit-ssl-check b/tor-exit-ssl-check index 0c69dc3..0d7e6a9 100755 --- a/tor-exit-ssl-check +++ b/tor-exit-ssl-check @@ -27,14 +27,17 @@ set -u shopt -s extglob usage() { - echo "Usage: $0 [-v [-v]] [-d <datadir>] -c [<cert-cachedir>] <torserver-fpr> <targethost>[:<targetport>] [<targethost>[:<targetport>] [...]]" - echo " If torserver-fpr is -, a list of fingerprints is read from stdin" + echo "Usage: $0 [-v [-v]] [-d <datadir>] -c [<cert-cachedir>] -C [<control socket>] <torserver-fpr> <targethost>[:<targetport>] [<targethost>[:<targetport>] [...]]" + echo " o If torserver-fpr is -, a list of fingerprints is read from stdin" + echo " o with -C set, this script will not launch a tor. instead it will use the" + echo " specified control socket to manipulate an already running Tor as needed." } verbose=0 cachedir="" datadir="" -while getopts "vhc:d:" OPTION +controlsocket="" +while getopts "vhc:d:C:" OPTION do case "$OPTION" in v) @@ -50,6 +53,9 @@ do d) datadir="$OPTARG" ;; + C) + controlsocket="$OPTARG" + ;; *) usage >&2 exit 1 @@ -85,44 +91,48 @@ cleanup() { tmpdir=$(mktemp -d "/tmp/cert-check-XXXXXX") trap 'cleanup' EXIT -pidfile="$tmpdir/pid" -torlog="$tmpdir/log" -if [ "$verbose" -gt 0 ]; then - tail -F "$torlog" & - logpid=$! -fi +if [ -z "$controlsocket" ]; then -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 + pidfile="$tmpdir/pid" + torlog="$tmpdir/log" + if [ "$verbose" -gt 0 ]; then + tail -F "$torlog" & + logpid=$! + fi -if [ "$verbose" -gt 1 ]; then - loglevel="info" -else - loglevel="notice" -fi + 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 -datadir=${datadir:-$tmpdir/tor} -cat > "$tmpdir/torrc" << EOF + if [ "$verbose" -gt 1 ]; then + loglevel="info" + else + loglevel="notice" + fi + + datadir=${datadir:-$tmpdir/tor} + controlsocket="$tmpdir/sock" + cat > "$tmpdir/torrc" << EOF DataDirectory $datadir RunAsDaemon 1 SocksPort auto PidFile $pidfile Log $loglevel file $torlog SafeLogging 0 -ControlSocket $tmpdir/sock +ControlSocket $controlsocket StrictNodes 1 EOF -mkdir -p -m 0700 "$datadir" -if [ "$verbose" -gt 0 ]; then hush=""; else hush="--hush"; fi -"$tor" $hush -f "$tmpdir/torrc" -torpid="$(cat $pidfile)" + mkdir -p -m 0700 "$datadir" + if [ "$verbose" -gt 0 ]; then hush=""; else hush="--hush"; fi + "$tor" $hush -f "$tmpdir/torrc" + torpid="$(cat $pidfile)" +fi eatdata() { @@ -163,7 +173,7 @@ for ((i=0; i < ${#targets[@]}; i++)); do done -coproc socat UNIX-CONNECT:"$tmpdir/sock" - +coproc socat UNIX-CONNECT:"$controlsocket" - echo 'AUTHENTICATE' >&${COPROC[1]} expect_ok |