#!/bin/sh -e
#
# curl-tor - curl over tor
# dependencies: tor (running daemon)

if pgrep -f /usr/bin/tor >/dev/null; then
  curl --socks5-hostname localhost:9050 "$@"
else
  if test -x /Applications/Tor Browser Alpha.app/Contents/MacOS/Tor/tor; then
    curl --socks5-hostname localhost:9050 "$@"
  elif command -v mullvad >/dev/null 2>&1; then
    # 10.64.0.1:1080
    curl --socks5-hostname 10.64.0.1:1080 "$@"
  else
    echo "Error: tor is not running" 1>&2
  fi
fi
