check-tor 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. ## Originally written by Peter Palfrader.
  3. ## This script lets you quickly check if a given router (by nickname)
  4. ## will let you do a TLS handshake, or will let you download a directory.
  5. ## Usage: check-tor nickname
  6. #set -x
  7. router="$1"
  8. dirserver="http://belegost.seul.org:80/tor/"
  9. lines=$( wget -q $dirserver --proxy=off -O - | grep -A5 '^router '"$router"' ' )
  10. line=$( echo "$lines" | head -n1 )
  11. if [ -z "$line" ]; then
  12. echo "Not found" >&2
  13. exit 1
  14. fi
  15. echo "$lines"
  16. echo
  17. ipor=$( echo "$line" | awk '{printf "%s:%s", $3, $4}' )
  18. op=$( echo "$line" | awk '{printf $6}' )
  19. ipop=$( echo "$line" | awk '{printf "%s:%s", $3, $6}' )
  20. echo
  21. echo ">>" openssl s_client -connect "$ipor"
  22. timeout 5 openssl s_client -connect "$ipor" < /dev/null
  23. if [ "$op" != "0" ]; then
  24. echo
  25. echo ">>" wget --proxy=off -O - http://$ipop/tor/
  26. timeout 5 wget --proxy=off -O - http://$ipop/tor/ | head -n3
  27. fi
  28. echo
  29. echo -n "$router "; echo "$lines" | grep 'fingerprint' | sed -e 's/^opt //' -e 's/^fingerprint //';