Fix typo in man page
[tor/rransom.git] / contrib / torify.in
blobd430da8ce7454b7bd4d8ff5cbb0c8cc58767e81a
1 #! /bin/sh
3 # Wrapper script for use of the tsocks(8) transparent socksification library
4 # See the tsocks(1) and torify(1) manpages.
6 # Copyright (c) 2004, 2006, 2009 Peter Palfrader
7 # Modified by Jacob Appelbaum <jacob@appelbaum.net> April 16th 2006
8 # May be distributed under the same terms as Tor itself
10 # taken from Debian's Developer's Reference, 6.4
11 pathfind() {
12 OLDIFS="$IFS"
13 IFS=:
14 for p in $PATH; do
15 if [ -x "$p/$*" ]; then
16 IFS="$OLDIFS"
17 return 0
19 done
20 IFS="$OLDIFS"
21 return 1
24 # Check for any argument list
25 if [ "$#" = 0 ]; then
26 echo "Usage: $0 [-hv] <command> [<options>...]" >&2
27 exit 1
30 if [ "$#" = 1 ] && ( [ "$1" = "-h" ] || [ "$1" = "--help" ] ); then
31 echo "Usage: $0 [-hv] <command> [<options>...]"
32 exit 0
35 if [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then
36 verbose=1
37 shift 1
38 else
39 verbose=0
42 if pathfind torsocks; then
43 ! [ "$verbose" -ge 1 ] || echo "Using torsocks as socksifier." >&2
45 exec torsocks "$@"
46 echo "$0: Failed to exec torsocks $@" >&2
47 exit 1
49 elif pathfind tsocks; then
50 ! [ "$verbose" -ge 1 ] || echo "Using tsocks as socksifier." >&2
52 # Define our tsocks config file
53 TSOCKS_CONF_FILE="/etc/tor/tor-tsocks.conf"
54 export TSOCKS_CONF_FILE
56 # Check that we've got a tsocks config file
57 if [ -r "$TSOCKS_CONF_FILE" ]
58 then
59 echo "WARNING: tsocks is known to leak DNS and UDP data. If you had torsocks we would use that." >&2
60 exec tsocks "$@"
61 echo "$0: Failed to exec tsocks $@" >&2
62 exit 1
63 else
64 echo "$0: Missing tsocks configuration file \"$TSOCKS_CONF_FILE\"." >&2
65 exit 1
68 else
69 echo "$0: Can't find either tsocks or torsocks in your PATH. Perhaps you haven't installed either?" >&2
70 exit 1