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

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

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

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

准备工作

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

install

    brew install polipo

config

    # 设置每次登陆启动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

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

setting profile

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

test

    ~/Documents ⮀ hp curl ip.gs
    当前 IP:49.213.9.87 来自:中国香港 hdcdatacentre.com
    ~/Documents ⮀
Mac