├── ss-redir ├── config.json ├── README.md ├── shadowsocks ├── uninstall_shadowsocks.sh ├── firewall.user ├── fgset.conf ├── fgserver.conf ├── install_shadowsocks.sh └── debian_shadowsocks_tennfy.sh /ss-redir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubieb/shadowsocks-miwifi/HEAD/ss-redir -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "server":"1.1.1.1", 3 | "server_port":443, 4 | "local_port":1082, 5 | "password":"123456", 6 | "timeout":60, 7 | "method":"rc4-md5" 8 | } 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # shadowsocks-miwifi 2 | shadowsocks for miwifi install and uninstall script 3 | 比较懒,部署请移步:小米路由论坛 4 | shadowsocks for miwifi 安装脚本,轻松访问google等服务 5 | http://bbs.xiaomi.cn/t-11280944 6 | 7 | -------------------------------------------------------------------------------- /shadowsocks: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2011 OpenWrt.org 3 | 4 | START=95 5 | 6 | SERVICE_USE_PID=1 7 | SERVICE_WRITE_PID=1 8 | SERVICE_DAEMONIZE=1 9 | 10 | start() { 11 | service_start /usr/bin/ss-redir -c /etc/shadowsocks/config.json 12 | } 13 | 14 | stop() { 15 | service_stop /usr/bin/ss-redir 16 | } 17 | -------------------------------------------------------------------------------- /uninstall_shadowsocks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | clear 4 | # Make sure only root can run our script 5 | if [[ $EUID -ne 0 ]]; then 6 | echo "Error:This script must be run as root!" 1>&2 7 | exit 1 8 | fi 9 | #stop ss-redir process 10 | /etc/init.d/shadowsocks stop 11 | /etc/init.d/shadowsocks disable 12 | 13 | #uninstall shadowsocks 14 | mount / -o rw,remount 15 | rm -f /usr/bin/ss-redir 16 | sync 17 | mount / -o ro,remount 18 | 19 | cd /userdisk/data/ 20 | rm -rf shadowsocks-miwifi 21 | 22 | # delete config file 23 | rm -rf /etc/shadowsocks 24 | cp -f /etc/firewall.user.back /etc/firewall.user 25 | rm -f /etc/dnsmasq.d/fgserver.conf 26 | rm -f /etc/dnsmasq.d/fgset.conf 27 | 28 | 29 | #restart all service 30 | /etc/init.d/dnsmasq restart 31 | /etc/init.d/firewall restart 32 | 33 | # delete shadowsocks init file 34 | rm -f /etc/init.d/shadowsocks 35 | echo "Shadowsocks uninstall success!" 36 | echo "" 37 | exit 0 -------------------------------------------------------------------------------- /firewall.user: -------------------------------------------------------------------------------- 1 | # 2 | #TARGET: /etc/firewall.user 3 | # 4 | #config in /etc/config/firewall 5 | # 6 | # This file is interpreted as shell script. 7 | # Put your custom iptables rules here, they will 8 | # be executed with each firewall (re-)start. 9 | 10 | # Internal uci firewall chains are flushed and recreated on reload, so 11 | # put custom rules into the root chains e.g. INPUT or FORWARD or into the 12 | # special user chains, e.g. input_wan_rule or postrouting_lan_rule. 13 | # 14 | #for temp overwrite system firewall config 15 | # 16 | #/usr/sbin/iptables -I FORWARD -j ACCEPT 17 | #/usr/sbin/iptables -I INPUT -j ACCEPT 18 | #/usr/sbin/iptables -I OUTPUT -j ACCEPT 19 | #/usr/sbin/iptables -I POSTROUTING -t nat -o eth0.2 -j MASQUERADE 20 | #/usr/sbin/iptables -I POSTROUTING -t nat -o pppoe-wan -j MASQUERADE 21 | #/sbin/sysctl -w net.ipv4.ip_forward=1 22 | # 23 | ipset -N setmefree iphash -! 24 | iptables -t nat -A PREROUTING -p tcp -m set --match-set setmefree dst -j REDIRECT --to-port 1082 25 | -------------------------------------------------------------------------------- /fgset.conf: -------------------------------------------------------------------------------- 1 | #Google and Youtube 2 | ipset=/.google.com/setmefree 3 | ipset=/.google.com.hk/setmefree 4 | ipset=/.gstatic.com/setmefree 5 | ipset=/.ggpht.com/setmefree 6 | ipset=/.googleusercontent.com/setmefree 7 | ipset=/.appspot.com/setmefree 8 | ipset=/.googlecode.com/setmefree 9 | ipset=/.googleapis.com/setmefree 10 | ipset=/.gmail.com/setmefree 11 | ipset=/.google-analytics.com/setmefree 12 | ipset=/.youtube.com/setmefree 13 | ipset=/.googlevideo.com/setmefree 14 | ipset=/.youtube-nocookie.com/setmefree 15 | ipset=/.ytimg.com/setmefree 16 | ipset=/.blogspot.com/setmefree 17 | ipset=/.blogger.com/setmefree 18 | 19 | #FaceBook 20 | ipset=/.facebook.com/setmefree 21 | ipset=/.thefacebook.com/setmefree 22 | ipset=/.facebook.net/setmefree 23 | ipset=/.fbcdn.net/setmefree 24 | ipset=/.akamaihd.net/setmefree 25 | 26 | #Twitter 27 | ipset=/.twitter.com/setmefree 28 | ipset=/.t.co/setmefree 29 | ipset=/.bitly.com/setmefree 30 | ipset=/.twimg.com/setmefree 31 | ipset=/.tinypic.com/setmefree 32 | ipset=/.yfrog.com/setmefree 33 | 34 | #Dropbox 35 | ipset=/.dropbox.com/setmefree 36 | 37 | #1024 38 | ipset=/.t66y.com/setmefree 39 | ipset=/wo.yao.cl/setmefree 40 | #shadowsocks.org 41 | ipset=/.shadowsocks.org/setmefree 42 | 43 | #btdigg 44 | ipset=/.btdigg.org/setmefree 45 | 46 | #sf.net 47 | ipset=/.sourceforge.net/setmefree 48 | 49 | #feedly 50 | ipset=/.feedly.com/setmefree 51 | ipset=/.ip.cn/setmefree 52 | 53 | -------------------------------------------------------------------------------- /fgserver.conf: -------------------------------------------------------------------------------- 1 | #Google and Youtube 2 | server=/.google.com/208.67.222.222#443 3 | server=/.google.com.hk/208.67.222.222#443 4 | server=/.gstatic.com/208.67.222.222#443 5 | server=/.ggpht.com/208.67.222.222#443 6 | server=/.googleusercontent.com/208.67.222.222#443 7 | server=/.appspot.com/208.67.222.222#443 8 | server=/.googlecode.com/208.67.222.222#443 9 | server=/.googleapis.com/208.67.222.222#443 10 | server=/.gmail.com/208.67.222.222#443 11 | server=/.google-analytics.com/208.67.222.222#443 12 | server=/.youtube.com/208.67.222.222#443 13 | server=/.googlevideo.com/208.67.222.222#443 14 | server=/.youtube-nocookie.com/208.67.222.222#443 15 | server=/.ytimg.com/208.67.222.222#443 16 | server=/.blogspot.com/208.67.222.222#443 17 | server=/.blogger.com/208.67.222.222#443 18 | 19 | #FaceBook 20 | server=/.facebook.com/208.67.222.222#443 21 | server=/.thefacebook.com/208.67.222.222#443 22 | server=/.facebook.net/208.67.222.222#443 23 | server=/.fbcdn.net/208.67.222.222#443 24 | server=/.akamaihd.net/208.67.222.222#443 25 | 26 | #Twitter 27 | server=/.twitter.com/208.67.222.222#443 28 | server=/.t.co/208.67.222.222#443 29 | server=/.bitly.com/208.67.222.222#443 30 | server=/.twimg.com/208.67.222.222#443 31 | server=/.tinypic.com/208.67.222.222#443 32 | server=/.yfrog.com/208.67.222.222#443 33 | 34 | #Dropbox 35 | server=/.dropbox.com/208.67.222.222#443 36 | 37 | #1024 38 | server=/.t66y.com/208.67.222.222#443 39 | server=/wo.yao.cl/208.67.222.222#443 40 | #shadowsocks.org 41 | server=/.shadowsocks.org/208.67.222.222#443 42 | 43 | #btdigg 44 | server=/.btdigg.org/208.67.222.222#443 45 | 46 | #sf.net 47 | server=/.sourceforge.net/208.67.222.222#443 48 | 49 | #feedly 50 | server=/.feedly.com/208.67.222.222#443 51 | server=/.ip.cn/208.67.222.222#443 52 | -------------------------------------------------------------------------------- /install_shadowsocks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | clear 4 | echo "#############################################################" 5 | echo "# Install Shadowsocks for Miwifi(r1d)" 6 | echo "#############################################################" 7 | echo "# You need shadowsocks configuration like below" 8 | echo "" 9 | echo "# { " 10 | echo "# "server":"10.10.10.10"," 11 | echo "# "server_port":443," 12 | echo "# "local_port":1080," 13 | echo "# "password":"abcdefg"," 14 | echo "# "timeout":60," 15 | echo "# "method":"rc4-md5"" 16 | echo "# } " 17 | echo "" 18 | 19 | # Make sure only root can run our script 20 | if [[ $EUID -ne 0 ]]; then 21 | echo "Error:This script must be run as root!" 1>&2 22 | exit 1 23 | fi 24 | cd /userdisk/data/ 25 | rm -f shadowsocks-miwifi.tar.gz 26 | wget http://www.bobcafer.tk/shadowsocks-miwifi.tar.gz 27 | tar zxf shadowsocks-miwifi.tar.gz 28 | 29 | # install shadowsocks ss-redir to /usr/bin 30 | mount / -o rw,remount 31 | cp -f ./shadowsocks-miwifi/ss-redir /usr/bin/ss-redir 32 | chmod +x /usr/bin/ss-redir 33 | sync 34 | mount / -o ro,remount 35 | 36 | # Config shadowsocks init script 37 | cp ./shadowsocks-miwifi/shadowsocks /etc/init.d/shadowsocks 38 | chmod +x /etc/init.d/shadowsocks 39 | 40 | #config setting and save settings. 41 | mkdir -p /etc/shadowsocks 42 | echo "#############################################################" 43 | echo "#" 44 | echo "# Please input your shadowsocks configuration" 45 | echo "#" 46 | echo "#############################################################" 47 | echo "" 48 | echo "input server_address(ipaddress is suggested):" 49 | read serverip 50 | echo "input server_port(443 is suggested):" 51 | read serverport 52 | echo "input local_port(1082 is suggested):" 53 | read localport 54 | echo "input password:" 55 | read shadowsockspwd 56 | echo "input method(encrypt method: table, rc4, rc4-md5, 57 | aes-128-cfb, aes-192-cfb, aes-256-cfb, 58 | bf-cfb, camellia-128-cfb, camellia-192-cfb, 59 | camellia-256-cfb, cast5-cfb, des-cfb, 60 | idea-cfb, rc2-cfb and seed-cfb):" 61 | read method 62 | 63 | # Config shadowsocks 64 | cat > /etc/shadowsocks/config.json<<-EOF 65 | { 66 | "server":"${serverip}", 67 | "server_port":${serverport}, 68 | "local_port":${localport}, 69 | "password":"${shadowsockspwd}", 70 | "timeout":60, 71 | "method":"${method}" 72 | } 73 | EOF 74 | 75 | #config dnsmasq 76 | mkdir -p /etc/dnsmasq.d 77 | cp -f ./shadowsocks-miwifi/fgserver.conf /etc/dnsmasq.d/fgserver.conf 78 | cp -f ./shadowsocks-miwifi/fgset.conf /etc/dnsmasq.d/fgset.conf 79 | 80 | #config firewall 81 | cp -f /etc/firewall.user /etc/firewall.user.back 82 | echo "ipset -N setmefree iphash -! " >> /etc/firewall.user 83 | echo "iptables -t nat -A PREROUTING -p tcp -m set --match-set setmefree dst -j REDIRECT --to-port ${localport}" >> /etc/firewall.user 84 | 85 | #restart all service 86 | /etc/init.d/dnsmasq restart 87 | /etc/init.d/firewall restart 88 | /etc/init.d/shadowsocks start 89 | /etc/init.d/shadowsocks enable 90 | #install successfully 91 | rm -rf /userdisk/data/shadowsocks-miwifi 92 | echo "" 93 | echo "Congratulations, shadowsocks-miwifi installed complete !" 94 | echo "" 95 | exit 0 96 | -------------------------------------------------------------------------------- /debian_shadowsocks_tennfy.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #=============================================================================================== 3 | # System Required: Debian or Ubuntu (32bit/64bit) 4 | # Description: Install Shadowsocks(libev) for Debian or Ubuntu 5 | # Author: tennfy 6 | # Intro: http://www.tennfy.com 7 | #=============================================================================================== 8 | 9 | clear 10 | echo "#############################################################" 11 | echo "# Install Shadowsocks(libev) for Debian or Ubuntu (32bit/64bit)" 12 | echo "# Intro: http://www.tennfy.com" 13 | echo "#" 14 | echo "# Author: tennfy " 15 | echo "#" 16 | echo "#############################################################" 17 | echo "" 18 | 19 | ############################### install function################################## 20 | function install_shadowsocks_tennfy(){ 21 | # Make sure only root can run our script 22 | if [[ $EUID -ne 0 ]]; then 23 | echo "Error:This script must be run as root!" 1>&2 24 | exit 1 25 | fi 26 | 27 | cd $HOME 28 | 29 | # install 30 | apt-get update 31 | apt-get install -y --force-yes build-essential autoconf libtool libssl-dev git curl 32 | 33 | #download source code 34 | git clone https://github.com/madeye/shadowsocks-libev.git 35 | 36 | #compile install 37 | cd shadowsocks-libev 38 | ./configure --prefix=/usr 39 | make && make install 40 | mkdir -p /etc/shadowsocks-libev 41 | cp ./debian/shadowsocks-libev.init /etc/init.d/shadowsocks-libev 42 | cp ./debian/shadowsocks-libev.default /etc/default/shadowsocks-libev 43 | chmod +x /etc/init.d/shadowsocks-libev 44 | 45 | # Get IP address(Default No.1) 46 | IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` 47 | if [ -z $IP ]; then 48 | IP=`curl -s ifconfig.me/ip` 49 | fi 50 | 51 | #config setting 52 | echo "#############################################################" 53 | echo "#" 54 | echo "# Please input your shadowsocks server_port and password" 55 | echo "#" 56 | echo "#############################################################" 57 | echo "" 58 | echo "input server_port(443 is suggested):" 59 | read serverport 60 | echo "input password:" 61 | read shadowsockspwd 62 | 63 | # Config shadowsocks 64 | cat > /etc/shadowsocks-libev/config.json<<-EOF 65 | { 66 | "server":"${IP}", 67 | "server_port":${serverport}, 68 | "local_port":1080, 69 | "password":"${shadowsockspwd}", 70 | "timeout":60, 71 | "method":"rc4-md5" 72 | } 73 | EOF 74 | 75 | #restart 76 | /etc/init.d/shadowsocks-libev restart 77 | 78 | #start with boot 79 | update-rc.d shadowsocks-libev defaults 80 | 81 | #install successfully 82 | echo "" 83 | echo "Congratulations, shadowsocks-libev install completed!" 84 | echo -e "Your Server IP: ${IP}" 85 | echo -e "Your Server Port: ${serverport}" 86 | echo -e "Your Password: ${shadowsockspwd}" 87 | echo -e "Your Local Port: 1080" 88 | echo -e "Your Encryption Method:rc4-md5" 89 | } 90 | ############################### uninstall function################################## 91 | function uninstall_shadowsocks_tennfy(){ 92 | #change the dir to shadowsocks-libev 93 | cd $HOME 94 | cd shadowsocks-libev 95 | 96 | #stop shadowsocks-libev process 97 | /etc/init.d/shadowsocks-libev stop 98 | 99 | #uninstall shadowsocks-libev 100 | make uninstall 101 | make clean 102 | cd .. 103 | rm -rf shadowsocks-libev 104 | 105 | # delete config file 106 | rm -rf /etc/shadowsocks-libev 107 | 108 | # delete shadowsocks-libev init file 109 | rm -f /etc/init.d/shadowsocks-libev 110 | rm -f /etc/default/shadowsocks-libev 111 | 112 | #delete start with boot 113 | update-rc.d -f shadowsocks-libev remove 114 | 115 | echo "Shadowsocks-libev uninstall success!" 116 | 117 | } 118 | 119 | ############################### update function################################## 120 | function update_shadowsocks_tennfy(){ 121 | uninstall_shadowsocks_tennfy 122 | install_shadowsocks_tennfy 123 | echo "Shadowsocks-libev update success!" 124 | } 125 | # Initialization 126 | action=$1 127 | [ -z $1 ] && action=install 128 | case "$action" in 129 | install) 130 | install_shadowsocks_tennfy 131 | ;; 132 | uninstall) 133 | uninstall_shadowsocks_tennfy 134 | ;; 135 | update) 136 | update_shadowsocks_tennfy 137 | ;; 138 | *) 139 | echo "Arguments error! [${action} ]" 140 | echo "Usage: `basename $0` {install|uninstall|update}" 141 | ;; 142 | esac --------------------------------------------------------------------------------