smart_switcher
Auto-detect proxy switcher in terminal. It supports many protocols and tools.
Overview
A smart proxy switcher wrapper, supports http, https, ftp, rsync, ssh(connect depended), git(connect depended) protocols.
It can automatically detect your network environment (in preset set) and fit proxy for you.
It supports multi-proxies.
If you usually switch the network environment (maybe home with no-proxy, workplace1 with proxy1, workplace2 with proxy2), it may help you a lot.
Tested in Zsh and Bash on Linux and Mac.
Protocols supported
-
http
-
https
-
ftp
-
rsync
-
ssh
-
git
Tools supported
-
wget
-
ftp
-
rsync
-
yum
-
brew
-
emerge
-
npm
-
pip
-
gopkg
-
git
-
hg
-
svn
-
cvs
Installation
- Download script (temply set your https proxy if necessary for installation)
export https_proxy={YOUR_PROXY_GATEWARY_IP}:{YOUR_PROXY_GATEWAY_PORT}
git clone https://github.com/springlie/smart_switcher.git /path/to/smart_switcher
-
Set proxies host/port in
$SMART_SWITCHER_DIR/gateway.ini
.[optional] Follow
gateway.ini
format and customize your multiple proxies.[optional] Note: the most common proxies should be set first in the value of "gateways"
-
Source it in your
.zshrc
(or any shell script resource file like.bashrc
):
export SMART_SWITCHER_DIR=/path/to/smart_switcher; source $SMART_SWITCHER_DIR/smart_switcher.sh
Usage
Execute antomatically when user login.
Use command sm_toggle
to toggle proxy status when you want.
What's more
cecho
smart_switcher
supports cecho, who will bring you some colors.
connect
connect is required to support ssh and git protocols.
Ensure proxy be set temply for installation ...
export http_proxy={YOUR_PROXY_GATEWARY_IP}:{YOUR_PROXY_GATEWAY_PORT}
- [for Mac]
brew install connect
- [for Gentoo]
emerge net-misc/connect
-
[for other]
download the source, make and install it easily in system path
Known issues
-
When $SHLVL > 1 (means in multi-layers sub-shell), the proxy setting is invalid
-
ssh can't distinguishes the destination sites before or behind proxy gateway
TODO
- add protocol header before proxy gateway
- add username & password
- add proxy for npm
- add toggle function
- specified ssh rule for sites
- add proxy for svn
- add automatical setup for connect package