diff options
author | Septs <github@septs.pw> | 2020-05-25 00:48:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 18:48:43 +0200 |
commit | 5ea25e6736430ab5b8439d11b2e9a837a803771b (patch) | |
tree | 745e632945649e7ae1f2728e64fe852f29732e04 /plugins/shell-proxy/ssh-proxy.py | |
parent | aada4d62bff3fc2e1720da1da4c54d47b5f86fa3 (diff) | |
download | zsh-5ea25e6736430ab5b8439d11b2e9a837a803771b.tar.gz zsh-5ea25e6736430ab5b8439d11b2e9a837a803771b.tar.bz2 zsh-5ea25e6736430ab5b8439d11b2e9a837a803771b.zip |
Add `shell-proxy` plugin (#8692)
Diffstat (limited to 'plugins/shell-proxy/ssh-proxy.py')
-rwxr-xr-x | plugins/shell-proxy/ssh-proxy.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/shell-proxy/ssh-proxy.py b/plugins/shell-proxy/ssh-proxy.py new file mode 100755 index 000000000..5efd5fd21 --- /dev/null +++ b/plugins/shell-proxy/ssh-proxy.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import os +import subprocess +import sys +import urllib.parse + +proxy = next(os.environ[_] for _ in ("HTTP_PROXY", "HTTPS_PROXY") if _ in os.environ) +argv = [ + "nc", + "-X", + "connect", + "-x", + urllib.parse.urlparse(proxy).netloc, # proxy-host:proxy-port + sys.argv[1], # host + sys.argv[2], # port +] + +subprocess.call(argv) |