1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #! /bin/sh
- pathfind() {
- OLDIFS="$IFS"
- IFS=:
- for p in $PATH; do
- if [ -x "$p/$*" ]; then
- IFS="$OLDIFS"
- return 0
- fi
- done
- IFS="$OLDIFS"
- return 1
- }
- if [ "$#" = 0 ]; then
- echo "Usage: $0 [-hv] <command> [<options>...]" >&2
- exit 1
- fi
- if [ "$#" = 1 ] && ( [ "$1" = "-h" ] || [ "$1" = "--help" ] ); then
- echo "Usage: $0 [-hv] <command> [<options>...]"
- exit 0
- fi
- if [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then
- verbose=1
- shift 1
- else
- verbose=0
- fi
- if pathfind torsocks; then
- ! [ "$verbose" -ge 1 ] || echo "Using torsocks as socksifier." >&2
- exec torsocks "$@"
- echo "$0: Failed to exec torsocks $@" >&2
- exit 1
- elif pathfind tsocks; then
- ! [ "$verbose" -ge 1 ] || echo "Using tsocks as socksifier." >&2
-
- TSOCKS_CONF_FILE="/etc/tor/tor-tsocks.conf"
- export TSOCKS_CONF_FILE
-
- if [ -r "$TSOCKS_CONF_FILE" ]
- then
- echo "WARNING: tsocks is known to leak DNS and UDP data. If you had torsocks we would use that." >&2
- exec tsocks "$@"
- echo "$0: Failed to exec tsocks $@" >&2
- exit 1
- else
- echo "$0: Missing tsocks configuration file \"$TSOCKS_CONF_FILE\"." >&2
- exit 1
- fi
- else
- echo "$0: Can't find either tsocks or torsocks in your PATH. Perhaps you haven't installed either?" >&2
- exit 1
- fi
|