Mac技巧:为终端设置Shadowsocks代理

准备工作

1
2
3
1.首先要有ShadowSocks
2.要有翻墙账号
3.安装配置自行Google

install

1
brew install polipo

config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 设置每次登陆启动polipo
ln -sfv /usr/local/opt/polipo/*.plist ~/Library/LaunchAgents
# 修改配置文件"homebrew.mxcl.polipo.plist"
~/Documents ⮀ cat /usr/local/opt/polipo/homebrew.mxcl.polipo.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.polipo</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/polipo/bin/polipo</string>
<string>socksParentProxy=127.0.0.1:1080</string> #### 需要添加的文件
</array>
<!-- Set `ulimit -n 65536`. The default macOS limit is 256, that's
not enough for Polipo (displays 'too many files open' errors).
It seems like you have no reason to lower this limit
(and unlikely will want to raise it). -->
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>65536</integer>
</dict>
</dict>
</plist>
~/Documents ⮀

start/stop

1
2
3
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist

setting profile

1
2
3
4
# 在bash_profile中添加如下文件,然后source
export http_proxy=http://localhost:8123
alias hp="http_proxy=http://localhost:8123"

test

1
2
3
~/Documents ⮀ hp curl ip.gs
当前 IP:49.213.9.87 来自:中国香港 hdcdatacentre.com
~/Documents ⮀
OpsNotes wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!