sd 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2005, 2006, 2007, 2008 Peter Palfrader <peter@palfrader.org>
  4. # Copyright (c) 2008 Jacob Appelbaum <jacob@appelbaum.net>
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining
  7. # a copy of this software and associated documentation files (the
  8. # "Software"), to deal in the Software without restriction, including
  9. # without limitation the rights to use, copy, modify, merge, publish,
  10. # distribute, sublicense, and/or sell copies of the Software, and to
  11. # permit persons to whom the Software is furnished to do so, subject to
  12. # the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be
  15. # included in all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  21. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. #
  25. # This small script fetches information about a server when given a nickname.
  26. # It currently uses the v2 dir information and not the v3 consensus by default.
  27. # It requires wget, perl, awk to function properly. This is based on a zsh
  28. # dotfile from weasel and adapted to be a small bash utility.
  29. #
  30. set -u;
  31. set -e;
  32. # Feel free to set any authority you desire, we're using weasel's by default
  33. # You could also try the v3 directory infomation in weasel's dir authority:
  34. # http://tor.noreply.org/tor/status-vote/current/consensus
  35. #
  36. authority="http://tor.noreply.org:80/tor/status/authority";
  37. nickname="$1";
  38. fp=`wget -q -O - $authority | \
  39. awk '$1 == "r" && $2 == "'$nickname'" {printf "%s===", $3}' | \
  40. perl -MMIME::Base64 -e "print unpack(\"H*\", decode_base64(<>)),\"\n\"";`
  41. if [ "$fp" != "" ];
  42. then
  43. wget -q -O - http://tor.noreply.org:80/tor/server/fp/$fp;
  44. exit $?;
  45. else
  46. echo "It appears the nickname is not currently known by the directory authority.";
  47. exit 1;
  48. fi