torify.in 890 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #! /bin/sh
  2. # This script used to call (the now deprecated) tsocks as a fallback in case
  3. # torsocks wasn't installed.
  4. # Now, it's just a backwards compatible shim around torsocks with reasonable
  5. # behavior if -v/--verbose or -h/--help arguments are passed.
  6. #
  7. # Copyright (c) 2004, 2006, 2009 Peter Palfrader
  8. # Modified by Jacob Appelbaum <jacob@appelbaum.net> April 16th 2006
  9. # Stripped of all the tsocks cruft by ugh on February 22nd 2012
  10. # May be distributed under the same terms as Tor itself
  11. compat() {
  12. echo "torify is now just a wrapper around torsocks(1) for backwards compatibility."
  13. }
  14. usage() {
  15. compat
  16. echo "Usage: $0 [-hv] <command> [<options>...]"
  17. }
  18. case $# in 0)
  19. usage >&2
  20. exit 1
  21. esac
  22. case $# in 1)
  23. case $1 in -h|--help)
  24. usage
  25. exit 0
  26. esac
  27. esac
  28. case $1 in -v|--verbose)
  29. compat >&2
  30. shift
  31. esac
  32. exec torsocks "$@"
  33. echo "$0: Failed to exec torsocks $@" >&2
  34. exit 1