3 # Copyright (c) 2005, 2006, 2007, 2008 Peter Palfrader <peter@palfrader.org>
4 # Copyright (c) 2008, 2009 Jacob Appelbaum <jacob@appelbaum.net>
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:
14 # The above copyright notice and this permission notice shall be
15 # included in all copies or substantial portions of the Software.
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.
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.
31 # Feel free to set any authority you desire, we're using weasel's by default
32 # You could also try the v3 directory infomation in weasel's dir authority:
33 # http://tor.noreply.org/tor/status-vote/current/consensus
36 # Users can select between the two
37 v3authority
="http://tor.noreply.org/tor/status-vote/current/consensus";
38 v2authority
="http://tor.noreply.org:80/tor/status/authority";
39 authority
=$v2authority;
42 echo "Usage: $0 [-2|-3] nodenickname";
51 # Are we switching between v2 or v3?
52 if [ "$1" == "-2" -o "$1" == "-3" ];
54 if [ "$1" == "-2" -a -n "$2" ];
56 authority
=$v2authority;
58 elif [ "$1" == "-3" -a -n "$2" ];
60 authority
=$v3authority;
70 # Fetch it and decode the fingerprint
71 fp
=`wget -q -O - $authority | \
72 awk '$1 == "r" && $2 == "'$nickname'" {printf "%s===", $3}' | \
73 perl -MMIME::Base64 -e "print unpack(\"H*\", decode_base64(<>)),\"\n\"";`
75 # If we don't have a fingerprint, we don't have a match
78 wget
-q -O - http
://tor.noreply.org
:80/tor
/server
/fp
/$fp;
81 echo "It appears the nickname is not currently known by the directory" \