ssh-proxy.py 364 B

123456789101112131415161718
  1. #!/usr/bin/env python3
  2. import os
  3. import subprocess
  4. import sys
  5. import urllib.parse
  6. proxy = next(os.environ[_] for _ in ("HTTP_PROXY", "HTTPS_PROXY") if _ in os.environ)
  7. argv = [
  8. "nc",
  9. "-X",
  10. "connect",
  11. "-x",
  12. urllib.parse.urlparse(proxy).netloc, # proxy-host:proxy-port
  13. sys.argv[1], # host
  14. sys.argv[2], # port
  15. ]
  16. subprocess.call(argv)