torify 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. if command -v torsocks > /dev/null; then
  33. exec torsocks "$@"
  34. else
  35. echo "$0: torsocks not found in your PATH. Perhaps it isn't installed? (tsocks is no longer supported, for security reasons.)" >&2
  36. fi