Skip to content

Instantly share code, notes, and snippets.

@jsyqrt
Last active August 11, 2018 12:19
Show Gist options
  • Save jsyqrt/336ed4769380650deac730ed1db5f347 to your computer and use it in GitHub Desktop.
Save jsyqrt/336ed4769380650deac730ed1db5f347 to your computer and use it in GitHub Desktop.
#!/bin/bash
function launchProxy {
ip=127.0.0.1
port=8118
proxy="http://$ip:$port"
# launch shadowsocks local daemon and privoxy service.
sudo sslocal -c .shadowsocks.json -d start
sudo service privoxy start
# set global variables.
fish -c "set -Ux http_proxy $proxy"
fish -c "set -Ux https_proxy $proxy"
fish -c "set -Ux ftp_proxy $proxy"
# set gnome settings.
gsettings set org.gnome.system.proxy.socks host "$ip"
gsettings set org.gnome.system.proxy.socks port $port
gsettings set org.gnome.system.proxy mode 'manual'
# set applications settings.
git config --global http.proxy "$proxy"
}
function stopProxy {
# stop shadowsocks local daemon and privoxy service.
sudo pkill sslocal
sudo service privoxy stop
# set global variables.
fish -c "set -Ux http_proxy ''"
fish -c "set -Ux https_proxy ''"
fish -c "set -Ux ftp_proxy ''"
# set gnome settings.
gsettings set org.gnome.system.proxy mode 'none'
# set applications settings.
git config --global http.proxy ""
}
function helpInfo {
echo "usage: ./proxy.sh [on|off]"
}
function main {
if [ ${BASH_ARGV[0]} = "on" ]
then
launchProxy
echo "now on."
elif [ ${BASH_ARGV[0]} = "off" ]
then
stopProxy
echo "now off."
else
helpInfo
fi
}
main
@jsyqrt
Copy link
Author

jsyqrt commented Aug 11, 2018

shadowsocks in linux:

  1. install shadowsocks via pip.
  2. install privoxy via apt.
  3. add .shadowsocks.json config file in ~.
  4. config /etc/privoxy/config file.
  5. add this proxy.sh file in ~.

done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment