Total Pageviews

Friday 1 July 2016

如何在终端设置socks代理?(彻底抛弃在终端设置http代理的做法)

在此文http://briteming.blogspot.com/2016/04/linux.html和此文http://briteming.blogspot.com/2016/03/linuxhttp.html中说过“替终端设置http代理的方法”,不过要先利用privoxy或polipo把socks代理转换为http代理,但是“转换”势必会降低效率(我用转换而成的http代理翻墙比用转换之前的socks代理翻墙,翻墙速度慢多了。所以还不如不转换
其实,在终端中所运行的命令(curl命令,wget命令,git clone命令,mac下的brew install命令)的前面加上ALL_PROXY=socks5://localhost:1080即可。比如:

ALL_PROXY=socks5://localhost:1080 git clone https://git.torproject.org/pluggable-transports/obfsproxy
可以把被封的obfsproxy源码克隆下来。这里的localhost:1080是一个在本地运行的socks代理,比如ss或ssh tunnel。直接克隆被封的obfsproxy源码会失败。

在http://briteming.blogspot.com/2015/09/homebrew.html中,也说到过ALL_PROXY=socks5://127.0.0.1:1080 
 
http://briteming.blogspot.com/2016/03/obfsproxysockshttp.html的附录里也说到ALL_PROXY=socks5://localhost:1080
在http://briteming.blogspot.com/2016/04/linux.html中,也说到过ALL_PROXY=socks5://localhost:8800
 
当然也可先在终端中运行export ALL_PROXY=socks5://localhost:1080
然后即可顺利地运行curl命令,wget命令,git clone命令,mac下的brew install命令。
如果想取消终端的代理,则运行unset ALL_PROXY.