Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为终端设置 SS 代理 #4

Open
chantzekin opened this issue Mar 13, 2019 · 0 comments
Open

为终端设置 SS 代理 #4

chantzekin opened this issue Mar 13, 2019 · 0 comments

Comments

@chantzekin
Copy link
Owner

chantzekin commented Mar 13, 2019

首先安装 polipo 程序

$ brew install polipo

设置 polipo 程序开机自启动

$ vim /usr/local/opt/polipo/homebrew.mxcl.polipo.plist

需要给 polipo 程序走 ss 客户端的代理,配置如下

<?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=localhost:1080</string>
      </array>
  </dict>
</plist>

接着执行命令

$ ln -sfv /usr/local/opt/polipo/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist

并且启动

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist

shell 设置别名以简短命令执行

macOS 用户修改 ~/.bash_profile,用 zsh 的话就编辑 ~/.zshrc

$ vim ~/.bash_profile # 或 vim ~/.zshrc

尾部追加

# Polipo proxy
alias proxy="export http_proxy=http://localhost:8123; export https_proxy=http://localhost:8123"
alias unproxy="unset http_proxy; unset https_proxy"

重新读取配置

$ source ~/.bash_profile # 或 source ~/.zshrc 或直接 zsh

此后,需要走代理的时候执行 proxy 即可,取消的话就 unproxy

参考资料:
为终端设置Shadowsocks代理, 解决golang dep ensure依赖包安装被墙 - 作者:Quinton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant