├── etc ├── rc.d │ └── S80gw-shadowsocks ├── config │ ├── dnscrypt-proxy │ └── shadowsocks ├── ss │ ├── ss-init │ └── ss-lib ├── gw-redsocks.conf ├── init.d │ ├── dnscrypt-proxy │ ├── gw-shadowsocks │ └── gw-redsocks └── firewall.d │ └── 10-shadowsocks ├── .github └── ISSUE_TEMPLATE.md ├── ss.tar.gz ├── ss-menu.png ├── ss-advance.png ├── lib ├── ss-test.lua └── gw-shadowsocks.sh ├── ss-settings.png ├── usr ├── bin │ ├── ss-local │ ├── ss-redir │ ├── gw_redsocks │ └── ss-tunnel ├── sbin │ ├── dns2socks │ └── ss-redir └── lib │ ├── lua │ ├── geewan.lua │ └── luci │ │ ├── controller │ │ ├── api │ │ │ └── geewan.lua │ │ └── admin_web │ │ │ └── shadowsocks.lua │ │ └── view │ │ └── admin_web │ │ └── network │ │ ├── ss_adv.htm │ │ ├── cfg_import.htm │ │ ├── index.htm │ │ └── shadowsocks.htm │ └── opkg │ └── info │ ├── geewan-ss.control │ └── geewan-ss.list ├── shadow.sh └── README.md /etc/rc.d/S80gw-shadowsocks: -------------------------------------------------------------------------------- 1 | ./../init.d/gw-shadowsocks -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### 问题描述 2 | 3 | #### 运行结果 4 | 5 | -------------------------------------------------------------------------------- /ss.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/ss.tar.gz -------------------------------------------------------------------------------- /ss-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/ss-menu.png -------------------------------------------------------------------------------- /ss-advance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/ss-advance.png -------------------------------------------------------------------------------- /lib/ss-test.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/lib/ss-test.lua -------------------------------------------------------------------------------- /ss-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/ss-settings.png -------------------------------------------------------------------------------- /usr/bin/ss-local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/bin/ss-local -------------------------------------------------------------------------------- /usr/bin/ss-redir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/bin/ss-redir -------------------------------------------------------------------------------- /usr/bin/gw_redsocks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/bin/gw_redsocks -------------------------------------------------------------------------------- /usr/bin/ss-tunnel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/bin/ss-tunnel -------------------------------------------------------------------------------- /usr/sbin/dns2socks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/sbin/dns2socks -------------------------------------------------------------------------------- /usr/sbin/ss-redir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/sbin/ss-redir -------------------------------------------------------------------------------- /usr/lib/lua/geewan.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/lib/lua/geewan.lua -------------------------------------------------------------------------------- /usr/lib/lua/luci/controller/api/geewan.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/lib/lua/luci/controller/api/geewan.lua -------------------------------------------------------------------------------- /usr/lib/lua/luci/controller/admin_web/shadowsocks.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cllu/hiwifi-ss/HEAD/usr/lib/lua/luci/controller/admin_web/shadowsocks.lua -------------------------------------------------------------------------------- /etc/config/dnscrypt-proxy: -------------------------------------------------------------------------------- 1 | config dnscrypt-proxy 2 | option address '127.0.0.1' 3 | option port '53535' 4 | # option resolver 'opendns' 5 | # option resolvers_list '/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv' 6 | -------------------------------------------------------------------------------- /etc/ss/ss-init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright hiwifi.com 3 | 4 | #should start before dnsmasq = 47 5 | START=46 6 | 7 | appname=SSAPPNAME 8 | ss_lib=/etc/ss/ss-lib 9 | 10 | source $ss_lib 11 | 12 | start() { 13 | ss_start 14 | } 15 | 16 | stop() { 17 | ss_stop 18 | } 19 | 20 | -------------------------------------------------------------------------------- /etc/gw-redsocks.conf: -------------------------------------------------------------------------------- 1 | base { 2 | daemon = on; 3 | redirector = iptables; 4 | } 5 | redsocks { 6 | local_ip = 0.0.0.0; 7 | local_port = 3088; 8 | 9 | ip = 127.0.0.1; 10 | port = 61080; 11 | 12 | type = socks5; 13 | } 14 | redudp {} 15 | dnstc { 16 | local_ip = 127.0.0.1; 17 | local_port = 5300; 18 | } 19 | -------------------------------------------------------------------------------- /lib/gw-shadowsocks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | status() { 4 | if [ `killall -0 ss-local >/dev/null 2>&1; echo $?` == 1 ] || [ `killall -0 gw_redsocks >/dev/null 2>&1; echo $?` == 1 ] 5 | then 6 | echo -n "stopped" 7 | else 8 | echo -n "running" 9 | fi 10 | } 11 | 12 | case "$1" in 13 | status) 14 | status 15 | ;; 16 | esac -------------------------------------------------------------------------------- /etc/config/shadowsocks: -------------------------------------------------------------------------------- 1 | config ssproxy 'shadowsocks' 2 | option enable '0' 3 | option server '' 4 | option rs_port '3088' 5 | option server_port '' 6 | option local_port '61080' 7 | option password '' 8 | option timeout '600' 9 | option method 'aes-256-cfb' 10 | option defaultroute '0' 11 | option dnsserver '8.8.4.4' 12 | 13 | config advance 'adv' 14 | -------------------------------------------------------------------------------- /usr/lib/opkg/info/geewan-ss.control: -------------------------------------------------------------------------------- 1 | Package: geewan-ss 2 | Version: master-20130924-eb9d31869e1d7590cd8c2fb1e7d226ac6cf32fad-20140618 3 | Depends: libc, libopenssl, libauth, libqos, libtw, libhwf-log 4 | Provides: 5 | Source: /ROOT/diskb/hiwifi/branch/release0.9006/HC5761/package/geewan-ss 6 | Section: net 7 | Status: unknown ok not-installed 8 | Essential: no 9 | Priority: optional 10 | Maintainer: OpenWrt Developers Team 11 | Architecture: ralink 12 | Installed-Size: 34919 13 | Description: Socks5 solution for VPN 14 | -------------------------------------------------------------------------------- /etc/init.d/dnscrypt-proxy: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | #START=50 4 | 5 | start_instance () { 6 | local section="$1" 7 | config_get address "$section" 'address' 8 | config_get port "$section" 'port' 9 | config_get resolver "$section" 'resolver' 10 | config_get resolvers_list "$section" 'resolvers_list' 11 | 12 | /usr/sbin/dnscrypt -d \ 13 | -a ${address}:${port} \ 14 | -u nobody \ 15 | -L ${resolvers_list:-'/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv'} \ 16 | -R ${resolver:-'opendns'} 17 | } 18 | 19 | start() { 20 | config_load 'dnscrypt-proxy' 21 | config_foreach start_instance 'dnscrypt-proxy' 22 | } 23 | 24 | stop() { 25 | killall dnscrypt 26 | } 27 | -------------------------------------------------------------------------------- /usr/lib/opkg/info/geewan-ss.list: -------------------------------------------------------------------------------- 1 | /etc/firewall.d/10-shadowsocks 2 | /etc/ss/ss-init 3 | /usr/sbin/ss-redir 4 | /usr/sbin/dns2socks 5 | /etc/ss/ss-lib 6 | /etc/config/dnscrypt-proxy 7 | /etc/config/shadowsocks 8 | /etc/gw-redsocks/gw-shadowsocks/gw-shadowsocks.dnslist 9 | /etc/gw-shadowsocks/gw-shadowsocks.dnslist 10 | /etc/init.d/dnscrypt-proxy 11 | /etc/init.d/gw-redsocks 12 | /etc/init.d/gw-shadowsocks 13 | /etc/rc.d/S80gw-shadowsocks 14 | /etc/gw-redsocks.conf 15 | /lib/gw-shadowsocks.sh 16 | /lib/ss-test.lua 17 | /usr/bin/gw_redsocks 18 | /usr/bin/ss-local 19 | /usr/bin/ss-redir 20 | /usr/bin/ss-tunnel 21 | /usr/lib/lua/geewan.lua 22 | /usr/lib/lua/luci/controller/admin_web/shadowsocks.lua 23 | /usr/lib/lua/luci/controller/api/geewan.lua 24 | /usr/lib/lua/luci/view/admin_web/menu/adv_menu.htm 25 | /usr/lib/lua/luci/view/admin_web/network/cfg_import.htm 26 | /usr/lib/lua/luci/view/admin_web/network/shadowsocks.htm 27 | /usr/lib/lua/luci/view/admin_web/network/ss_adv.htm 28 | -------------------------------------------------------------------------------- /etc/firewall.d/10-shadowsocks: -------------------------------------------------------------------------------- 1 | #root: output 2 | iptables -t nat -N ss-redir-output &>/dev/null 3 | [ $? -ne 0 ] && return 4 | iptables -t nat -A OUTPUT -j ss-redir-output 5 | #ssgoabroadng 6 | iptables -t nat -N ssgoabroadng-output 7 | iptables -t nat -A ss-redir-output -j ssgoabroadng-output 8 | 9 | # append new app's output hook point here. 10 | 11 | #root: prerouting 12 | iptables -t nat -N ss-redir-pre 13 | iptables -t nat -A ss-redir-pre -m salist --salist local --match-dip -j RETURN 14 | iptables -t nat -A ss-redir-pre -m salist --salist hiwifi --match-dip -j RETURN 15 | iptables -t nat -A PREROUTING -i br-lan -j ss-redir-pre 16 | #ssgoabroadng 17 | iptables -t nat -N ssgoabroadng-pre 18 | iptables -t nat -A ss-redir-pre -j ssgoabroadng-pre 19 | #ssbf3 20 | iptables -t nat -N ssbf3-pre 21 | iptables -t nat -A ss-redir-pre -j ssbf3-pre 22 | #lol 23 | iptables -t nat -N sslol-pre 24 | iptables -t nat -A ss-redir-pre -j sslol-pre 25 | 26 | # append new app's prerouting hook point here. 27 | 28 | -------------------------------------------------------------------------------- /etc/init.d/gw-shadowsocks: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2007-2011 OpenWrt.org 3 | 4 | START=80 5 | export SERVICE_DAEMONIZE=1 6 | export SERVICE_WRITE_PID=1 7 | 8 | start() { 9 | local server 10 | local server_port 11 | local local_port 12 | local password 13 | local timeout 14 | local method 15 | local enable 16 | local dnsserver 17 | 18 | local section='shadowsocks' 19 | 20 | config_load 'shadowsocks' 21 | 22 | config_get enable "$section" 'enable' 23 | if [ "$enable" == "1" ] 24 | then 25 | config_get server "$section" 'server' 26 | config_get server_port "$section" 'server_port' 27 | config_get local_port "$section" 'local_port' 28 | config_get password "$section" 'password' 29 | config_get timeout "$section" 'timeout' 30 | config_get method "$section" 'method' 31 | config_get dnsserver "$section" 'dnsserver' 32 | 33 | service_start /usr/bin/ss-local -s $server -p $server_port -l $local_port -k $password -t $timeout -m $method 34 | 35 | #/etc/init.d/dnscrypt-proxy start 36 | service_start /usr/sbin/dns2socks 127.0.0.1:$local_port $dnsserver 127.0.0.1:53535 -d -q 37 | /etc/init.d/gw-redsocks start 38 | fi 39 | } 40 | 41 | stop() { 42 | /etc/init.d/gw-redsocks stop 43 | #/etc/init.d/dnscrypt-proxy stop 44 | 45 | service_stop /usr/sbin/dns2socks 46 | service_stop /usr/bin/ss-local 47 | } 48 | 49 | restart() { 50 | stop 51 | start 52 | } 53 | -------------------------------------------------------------------------------- /shadow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | echo '' 4 | echo '/*教程请参考:极路由Shadowsocks家庭无痛翻墙实践*/' 5 | echo 'https://luolei.org/hiwifi-shadowsocks/' 6 | echo 'by @foru17' 7 | echo '' 8 | echo '' 9 | echo '那一天,' 10 | echo '人类终于回想起了,' 11 | echo '曾经一度被他们所支配的恐怖,' 12 | echo '还有被囚禁于鸟笼中的那份屈辱.' 13 | echo '' 14 | echo '進撃の巨人 諫山創' 15 | echo '' 16 | sleep 2 17 | echo 'Building environment... 创建临时目录ing' 18 | echo '' 19 | mkdir /tmp/geewan 20 | cd /tmp/geewan 21 | echo 'Done! 成功创建临时目录!' 22 | echo '' 23 | sleep 3 24 | echo 'Downloading files... 下载插件ing' 25 | echo '' 26 | curl -k https://raw.githubusercontent.com/qiwihui/hiwifi-ss/master/ss.tar.gz -o ss.tar.gz 27 | echo 'Done! 下载完成' 28 | echo '' 29 | sleep 3 30 | echo 'Installing... 安装ing' 31 | echo -n "备份系统文件...." 32 | if [ -f /usr/lib/lua/luci/view/admin_web/network/index.htm.ssbak ]; then 33 | echo -e "...[\e[31m备份文件已存在\e[37m]" 34 | else 35 | cp -a /usr/lib/lua/luci/view/admin_web/network/index.htm /usr/lib/lua/luci/view/admin_web/network/index.htm.ssbak 36 | echo -e "....[\e[32m完成\e[37m]" 37 | fi 38 | if test -e /usr/lib/lua/luci/view/admin_web/plugin/shadowsocks.htm; 39 | then echo 'Error,请备份并重命名之前的shadowsocks插件文件:/usr/lib/lua/luci/view/admin_web/plugin/shadowsocks.htm'&&rm -rf /tmp/geewan&&exit; 40 | else 41 | if test -e /etc/config/ss-redir; 42 | then echo 'Error,请备份并重命名/etc/config/ss-redir文件夹'&&rm -rf /tmp/geewan&&exit; 43 | else tar xzvf ss.tar.gz -C / >>/dev/null; 44 | fi 45 | fi 46 | echo 'Done! 插件安装成功!' 47 | echo '' 48 | sleep 3 49 | echo 'adding uninstall information... 准备删除临时文件...' 50 | echo '' 51 | echo '' >>/usr/lib/opkg/status 52 | echo 'Package: geewan-ss' >>/usr/lib/opkg/status 53 | echo 'Version: master-20130924-eb9d31869e1d7590cd8c2fb1e7d226ac6cf32fad-20141024' >>/usr/lib/opkg/status 54 | echo 'Provides:' >>/usr/lib/opkg/status 55 | echo 'Status: install hold installed' >>/usr/lib/opkg/status 56 | echo 'Architecture: ralink' >>/usr/lib/opkg/status 57 | echo 'Installed-Time: 1422509506' >>/usr/lib/opkg/status 58 | echo 'Auto-Installed: yes' >>/usr/lib/opkg/status 59 | echo '' >>/usr/lib/opkg/status 60 | echo 'cleanning temporary files... 清理临时文件ing' 61 | echo '' 62 | if test -e /var/run/luci-indexcache; 63 | then rm /var/run/luci-indexcache && echo 'Done! 清理完成 ' && echo ''; 64 | else echo 'luci-cache does not exist! 无法找到luci-cache,请确定是否是极路由环境' && echo '' 65 | fi 66 | rm -rf /tmp/geewan 67 | sleep 3 68 | echo 'the whole installation Success! 插件成功安装!' 69 | echo '1987年9月14日21时07分' 70 | echo '中国第一封电子邮件' 71 | echo '从北京发往德国' 72 | echo '越过长城,走向世界' 73 | echo 'Done! Hello World! 一切就绪,你好世界!' 74 | -------------------------------------------------------------------------------- /etc/init.d/gw-redsocks: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | #START=80 4 | APP=gw_redsocks 5 | PID_FILE=/var/run/$APP.pid 6 | 7 | #export SERVICE_DAEMONIZE=1 8 | #export SERVICE_WRITE_PID=1 9 | 10 | appname=gw-shadowsocks 11 | appdir=/etc/gw-redsocks/$appname 12 | 13 | rs_getconfig() { 14 | lan_ip=$(uci get network.lan.ipaddr) 15 | source /lib/functions/network.sh 16 | network_get_ipaddr wanip wan 17 | local_ip=127.0.0.1 18 | 19 | rs_port_tcp=$(uci get shadowsocks.shadowsocks.rs_port) 20 | mode=$(uci get shadowsocks.shadowsocks.defaultroute) 21 | server_ip=$(uci get shadowsocks.shadowsocks.server) 22 | user_urls=$(uci get shadowsocks.adv.url) 23 | } 24 | 25 | rs_iptables_add() { 26 | echo -n > /dev/null 27 | iptables -t nat -N $appname 28 | iptables -t nat -A PREROUTING -i br-lan -j $appname 29 | iptables -t nat -A OUTPUT -j $appname 30 | iptables -t nat -A $appname -m salist --salist local --match-dip -j RETURN 31 | iptables -t nat -A $appname -m salist --salist hiwifi --match-dip -j RETURN 32 | iptables -t nat -A $appname -d $lan_ip/24 -j RETURN 33 | iptables -t nat -A $appname -d $wanip/24 -j RETURN 34 | iptables -t nat -A $appname -d $server_ip/32 -j RETURN 35 | 36 | [ "$mode" != "1" ] && { 37 | iptables -t nat -A $appname -m salist --salist china --match-dip -j RETURN 38 | } 39 | 40 | iptables -t nat -A $appname -p tcp -j DNAT --to-destination $lan_ip:$rs_port_tcp 41 | } 42 | 43 | rs_iptables_del() { 44 | echo -n > /dev/null 45 | iptables -t nat -D PREROUTING -i br-lan -j $appname 46 | iptables -t nat -D OUTPUT -j $appname 47 | iptables -t nat -F $appname 48 | iptables -t nat -X $appname 49 | } 50 | 51 | rs_getconfig 52 | 53 | start() { 54 | service_start /usr/bin/$APP -c /etc/gw-redsocks.conf 55 | #start-stop-daemon -S -x $APP -p $PID_FILE -m -b -- -c /etc/redsocks.conf 56 | rs_iptables_add 57 | 58 | echo > /tmp/dnsmasq.d/$appname.usr.dnslist 59 | for url in $user_urls 60 | do 61 | echo "server=/$url/127.0.0.1#53535" >> /tmp/dnsmasq.d/$appname.usr.dnslist 62 | done 63 | 64 | cp $appdir/$appname.dnslist /tmp/dnsmasq.d/ 65 | [ "$mode" == "1" ] && { 66 | cat >> /tmp/dnsmasq.d/$appname.dnslist << EOF 67 | no-resolv 68 | server=127.0.0.1#53535 69 | EOF 70 | } 71 | 72 | /etc/init.d/dnsmasq restart 73 | } 74 | 75 | stop() { 76 | #start-stop-daemon -K -x $APP -s TERM 77 | rs_iptables_del 78 | 79 | rm /tmp/dnsmasq.d/$appname.dnslist 80 | rm /tmp/dnsmasq.d/$appname.usr.dnslist 81 | /etc/init.d/dnsmasq restart 82 | killall -q $APP 83 | } 84 | 85 | restart() { 86 | stop 87 | start 88 | } 89 | -------------------------------------------------------------------------------- /usr/lib/lua/luci/view/admin_web/network/ss_adv.htm: -------------------------------------------------------------------------------- 1 | <% 2 | --[[ 3 | Info shadowsocks 加速设置 4 | Author WangChao 5 | Copyright 2014 6 | --]] 7 | 8 | local ver = require "luci.version" 9 | local adv_menu = luci.util.get_adv_menu() 10 | local request_uri = luci.http.getenv("REQUEST_URI") 11 | %> 12 | 13 | 14 | 15 | 16 | 17 | 52 | 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hiwifi-ss 2 | 3 | 极路由+ss配置, 适应新版极路由,支持的极路由版本有(__因为没办法测试所有的极路由,所以你能运行的极路由不在这个列表,请在[issue#38](https://github.com/qiwihui/hiwifi-ss/issues/38)中回复,谢谢!__): 4 | 5 | 现在项目使用的是大陆白名单模式,关于适用大陆白名单和gfwlsit的处理,见[issue#37](https://github.com/qiwihui/hiwifi-ss/issues/37)。项目中的gfw规则使用项目 [cokebar/gfwlist2dnsmasq](https://github.com/cokebar/gfwlist2dnsmasq) 生成的规则修改而成,最后更新日期为2016.08.07。 6 | 7 | ### 安装方法 8 | 9 | 1. 旧版hiwifi => 请参见博客: [极路由Shadowsocks家庭无痛翻墙实践](https://luolei.org/hiwifi-shadowsocks/) 10 | 11 | 2. 新版hiwifi => 使用项目根目录下的 `shadow.sh` 脚本进行安装, 建议使用以下一键命令: 12 | 13 | ```sh 14 | cd /tmp && curl -k -o shadow.sh https://raw.githubusercontent.com/qiwihui/hiwifi-ss/master/shadow.sh && sh shadow.sh && rm shadow.sh 15 | ``` 16 | 17 | ### 如何在服务器端启用`chacha20`的支持: 18 | 19 | 1. 编译并安装libsodium: 20 | 21 | ``` 22 | apt-get update 23 | apt-get install build-essential 24 | wget https://github.com/jedisct1/libsodium/releases/download/1.0.3/libsodium-1.0.3.tar.gz 25 | tar xf libsodium-1.0.3.tar.gz && cd libsodium-1.0.3 26 | ./configure && make && make install 27 | ``` 28 | 29 | 2. 修复动态链接库: 30 | 然后编辑 `/etc/ld.so.conf` 文件, 加入一行 `/usr/local/lib` 并保存。运行命令 `ldconfig` 31 | 32 | 3. 在ss配置中修改为 `chacha20` 即可 33 | 34 | 备注: 参考[xqd的小站](https://php-rmcr7.rhcloud.com/chacha20/)整理,Thank you! 35 | 36 | ### 常见问题 37 | 38 | 0. 支持哪些加密方法? 39 | 40 | 理论上 ss-local 2.4.7 能支持的算法都支持。 41 | 42 | 1. 安装后显示`请求的接口不存在`? 43 | 44 | 请重启路由器. [issue#28](https://github.com/qiwihui/hiwifi-ss/issues/28) 45 | 46 | 2. 适用极路由版本有哪些? 47 | 48 | see [issue#38](https://github.com/qiwihui/hiwifi-ss/issues/38) 49 | 50 | 3. 如何卸载脚本?([issue#12](https://github.com/qiwihui/hiwifi-ss/issues/12)) 51 | 52 | 将`/usr/lib/lua/luci/view/admin_web/network/index.htm.ssbak` 重命名为 `/usr/lib/lua/luci/view/admin_web/network/index.htm`, 并移除ss: `opkg remove geewan-ss` 53 | 54 | 4. 如果出现类似下面的报错,请确保你是登录到极路由后台执行脚本: `ssh root@192.168.199.1 -p 1022`, 不要在自己的电脑上执行 :( 55 | 56 | ```sh 57 | x etc/: Could not remove symlink etc 58 | x etc/config/: Cannot extract through symlink etc 59 | x etc/firewall.d/: Cannot extract through symlink etc 60 | x etc/gw-redsocks/: Cannot extract through symlink etc 61 | x etc/gw-redsocks.conf: Cannot extract through symlink etc 62 | x etc/gw-shadowsocks/: Cannot extract through symlink etc 63 | x etc/init.d/: Cannot extract through symlink etc 64 | x etc/rc.d/: Cannot extract through symlink etc 65 | x etc/ss/: Cannot extract through symlink etc 66 | ...... 67 | ``` 68 | 69 | ### TODO 70 | 71 | - [x] 适应新版本界面 72 | 73 | - [x] 开关样式 74 | - [x] 增加"shadowsocks设置"按钮 75 | - [x] "shadowsocks设置"按钮功能修复 76 | - [x] 密码显示功能修复 77 | - [x] 弹出提示框修复 78 | - [x] 下拉框样式修复 79 | - [x] "导入配置文件(json格式)"界面修复; 界面修复了,但是底层功能有问题; 80 | - [x] "高级设置"界面修复 81 | 82 | - [x] release/v1.1.0 => 完成之前所有功能在新版下的界面适配 83 | - [x] 使用github作为文件存储, 既然能用 `raw.githubusercontent.com` 下脚本,下载 `ss.tar.gz` 应该也不成问题,只是慢些; 84 | - [x] 底层增加更多的路由规则 85 | - [ ] 关于底层源码开源的一些问题 86 | 87 | ### 贡献 88 | 89 | 1. 如果你在使用中有什么问题或者建议,请不要吝啬,给我提一个issue; 90 | 2. 如果你对代码有自己的想法并实现了,请给我一个Pull Request; 91 | 3. 不接收邮件了,问题大家都应该看到,这样减少重复回答,请提issue,谢谢~ 92 | 93 | ### 目前状态 94 | 95 | 1. 新版界面 96 | 97 | (1). ss子菜单在网络设置下: 98 | 99 | ![](./ss-menu.png) 100 | 101 | (2). ss账号设置 102 | 103 | ![](./ss-settings.png) 104 | 105 | (3). ss高级设置 106 | 107 | ![](./ss-advance.png) 108 | -------------------------------------------------------------------------------- /usr/lib/lua/luci/view/admin_web/network/cfg_import.htm: -------------------------------------------------------------------------------- 1 | <% 2 | local ver = require "luci.version" 3 | local request_uri = luci.http.getenv("REQUEST_URI") 4 | local step = 1 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 54 | 103 | -------------------------------------------------------------------------------- /etc/ss/ss-lib: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . /lib/functions/network.sh 4 | 5 | dnsdep=/var/run/ss-dnsmasq.appdep 6 | 7 | ss_log() { 8 | echo "`date` [log]<$$> $@" >>$applog 9 | } 10 | 11 | ss_err() { 12 | echo "`date` [err]<$$> $@" >>$applog 13 | } 14 | 15 | ss_stat() { 16 | echo $1 > $status_file 17 | echo "`date` [stat]<$$> *$1*" >>$applog 18 | } 19 | 20 | ss_set_server() { 21 | ss_log "set_server" 22 | [ ! -z "$1" ] && uci set ssvpn.$appname.server_ip=$1 23 | [ ! -z "$2" ] && uci set ssvpn.$appname.server_port=$2 24 | uci commit ssvpn 25 | } 26 | 27 | ss_setconfig() { 28 | ss_log "config: set" 29 | [ ! -e /etc/config/ssvpn ] && touch /etc/config/ssvpn 30 | 31 | #add interface and config to network 32 | uci set ssvpn.$appname=interface 33 | [ ! -z "$server_ip" ] && uci set ssvpn.$appname.server_ip=$server_ip 34 | [ ! -z "$server_port" ] && uci set ssvpn.$appname.server_port=$server_port 35 | 36 | [ ! -z "$redir_port" ] && uci set ssvpn.$appname.redir_port=$redir_port 37 | 38 | [ ! -z "$passwd" ] && uci set ssvpn.$appname.passwd=$passwd 39 | 40 | [ ! -z "$dns_server" ] && uci set ssvpn.$appname.dns_server=$dns_server 41 | [ ! -z "$dns_cb" ] && uci set ssvpn.$appname.dns_cb=$dns_cb 42 | [ ! -z "$dns_hosts" ] && uci set ssvpn.$appname.dns_hosts=$dns_hosts 43 | [ ! -z "$dns_list" ] && uci set ssvpn.$appname.dns_list=$dns_list 44 | 45 | [ ! -z "$auth_cb" ] && uci set ssvpn.$appname.auth_cb=$auth_cb 46 | 47 | [ ! -z "$ipt_cb" ] && uci set ssvpn.$appname.ipt_cb=$ipt_cb 48 | 49 | [ ! -z "$app_param_a" ] && uci set ssvpn.$appname.app_param_a=$app_param_a 50 | [ ! -z "$app_param_b" ] && uci set ssvpn.$appname.app_param_a=$app_param_b 51 | [ ! -z "$app_param_c" ] && uci set ssvpn.$appname.app_param_a=$app_param_c 52 | [ ! -z "$app_param_d" ] && uci set ssvpn.$appname.app_param_a=$app_param_d 53 | uci commit ssvpn 54 | } 55 | 56 | ss_getconfig () { 57 | uci get ssvpn.$appname &>/dev/null 58 | [ $? -ne 0 ] && { 59 | ss_err "config: get failed, ssvpn.$appname doesn't exist" 60 | return 61 | } 62 | 63 | server_ip=$(uci get ssvpn.$appname.server_ip 2>/dev/null) 64 | server_port=$(uci get ssvpn.$appname.server_port 2>/dev/null) 65 | 66 | lan_ip=$(uci get network.lan.ipaddr 2>/dev/null) 67 | network_get_ipaddr wanip wan 68 | 69 | redir_ip=$lan_ip 70 | redir_port=$(uci get ssvpn.$appname.redir_port 2>/dev/null) 71 | 72 | passwd=$(uci get ssvpn.$appname.passwd 2>/dev/null) 73 | 74 | dns_server=$(uci get ssvpn.$appname.dns_server 2>/dev/null) 75 | dns_cb=$(uci get ssvpn.$appname.dns_cb 2>/dev/null) 76 | dns_hosts=$(uci get ssvpn.$appname.dns_hosts 2>/dev/null) 77 | dns_list=$(uci get ssvpn.$appname.dns_list 2>/dev/null) 78 | 79 | auth_cb=$(uci get ssvpn.$appname.auth_cb 2>/dev/null) 80 | 81 | ipt_cb=$(uci get ssvpn.$appname.ipt_cb 2>/dev/null) 82 | 83 | app_param_a=$(uci get ssvpn.$appname.app_param_a 2>/dev/null) 84 | app_param_b=$(uci get ssvpn.$appname.app_param_b 2>/dev/null) 85 | app_param_c=$(uci get ssvpn.$appname.app_param_c 2>/dev/null) 86 | app_param_d=$(uci get ssvpn.$appname.app_param_d 2>/dev/null) 87 | } 88 | 89 | ss_delconfig() { 90 | ss_log "config: del" 91 | uci delete ssvpn.$appname 92 | uci commit ssvpn 93 | } 94 | 95 | ss_iptables_add() { 96 | [ ! -z "$ipt_cb" ] && { 97 | ss_log "iptables: $ipt_cb add" 98 | $ipt_cb add 99 | return 100 | } 101 | 102 | iptables -t nat -N ${appname} &>/dev/null 103 | [ $? -ne 0 ] && { 104 | ss_err "iptables: add failed, ${appname} exists" 105 | return 106 | } 107 | ss_log "iptables: add" 108 | 109 | iptables -t nat -N $appname 110 | iptables -t nat -A $appname -d $lan_ip/24 -j RETURN 111 | iptables -t nat -A $appname -d $wanip/24 -j RETURN 112 | [ ! -z "$server_ip" ] && iptables -t nat -A $appname -d $server_ip/32 -j RETURN 113 | 114 | iptables -t nat -N $appname-dynamic 115 | iptables -t nat -A $appname -j $appname-dynamic 116 | 117 | iptables -t nat -A $appname-pre -j $appname 118 | #iptables -t nat -A $appname-output -p udp -d $dns_server -j DNAT --to-destination $redir_ip:$redir_port 119 | [ "$appname" == "ssgoabroadng" -a ! -z "$server_ip" ] && { 120 | iptables -t nat -A $appname-output -p tcp --dport 80 -j $appname 121 | iptables -t nat -A $appname-output -p tcp --dport 443 -j $appname 122 | } 123 | } 124 | 125 | ss_iptables_del() { 126 | [ ! -z "$ipt_cb" ] && { 127 | ss_log "iptables: $ipt_cb del" 128 | $ipt_cb del 129 | return 130 | } 131 | 132 | ss_log "iptables: del" 133 | iptables -t nat -F $appname-output 134 | iptables -t nat -F $appname-pre 135 | iptables -t nat -F $appname 136 | iptables -t nat -X $appname 137 | iptables -t nat -F $appname-dynamic 138 | iptables -t nat -X $appname-dynamic 139 | } 140 | 141 | ss_up() { 142 | ss_log "ss_up: in" 143 | ss_iptables_add 144 | 145 | [ ! -z "$dns_cb" ] && { 146 | cp $dns_list $dnslist 147 | 148 | sed -i "/${appname}/d" $dnsdep 149 | echo "$appname $dns_cb $dns_hosts" >> $dnsdep 150 | 151 | ss_log "ss_up: dnsmasq restart" 152 | /etc/init.d/dnsmasq restart 153 | } 154 | 155 | ss_stat "running" 156 | ss_log "ss_up: out" 157 | } 158 | 159 | ss_down() { 160 | ss_log "ss_down: in" 161 | 162 | [ ! -z "$dns_cb" ] && { 163 | [ ! -e $dnslist ] && { 164 | ss_err "ss_down failed, $dnslist doesn't exist" 165 | return 166 | } 167 | rm $dnslist 168 | sed -i "/${appname}/d" $dnsdep 169 | /etc/init.d/dnsmasq restart 170 | } 171 | 172 | ss_iptables_del 173 | ss_stat "stopped" 174 | ss_log "ss_down: out" 175 | } 176 | 177 | ss_start() { 178 | echo >$applog 179 | ss_log "ss_start: in" 180 | 181 | enabled=$(uci get ssvpn.$appname.enabled) 182 | if [ "$enabled" -eq 0 ]; then 183 | ss_err "ss_start: failed, $appname was stopped in uci" 184 | return 1 185 | fi 186 | 187 | if [ -e $pidfile ]; then 188 | pid=$(cat $pidfile) 189 | num=$(ps www| grep $pid | grep $appname | wc -l ) 190 | if [ "$num" -eq 1 ]; then 191 | ss_err "ss_start: failed, $appname is running." 192 | return 2 193 | else 194 | ss_err "ss_start: $appname was stopped incidentally, re-stop it now" 195 | ss-stop 196 | fi 197 | fi 198 | 199 | ss_stat "dailing" 200 | 201 | if [ ! -z "$auth_cb" ]; then 202 | ss-redir -b $redir_ip -l $redir_port -k $passwd -u -h $auth_cb -f $pidfile 203 | else 204 | ss-redir -s $server_ip -p $server_port -b $redir_ip -l $redir_port -k $passwd -u -f $pidfile 205 | [ $? -eq 0 ] && { 206 | ss_up 207 | } 208 | fi 209 | ss_log "ss_start: out" 210 | } 211 | 212 | ss_stop() { 213 | ss_log "ss_stop: in" 214 | ss_down 215 | kill -9 `cat $pidfile` 216 | rm $pidfile 217 | ss_log "ss_stop: out" 218 | } 219 | 220 | [ -z "$appname" ] && { 221 | ss_err "ss-lib: sourced without appname" 222 | exit 1 223 | } 224 | 225 | applog=/tmp/data/$appname.log 226 | pidfile=/var/run/$appname.pid 227 | status_file=/var/run/$appname.status 228 | dnslist=/tmp/dnsmasq.d/$appname.dnslist 229 | 230 | ss_getconfig 231 | 232 | -------------------------------------------------------------------------------- /usr/lib/lua/luci/view/admin_web/network/index.htm: -------------------------------------------------------------------------------- 1 | <% 2 | --[[ 3 | Info 互联网首页 4 | Author peng.kang 5 | Copyright 2015 6 | ]]-- 7 | local ver = require "luci.version" 8 | local i18n = require "luci.i18n" 9 | %> 10 | <% include('admin_web/header') %> 11 | 12 |
13 |
14 |
15 |
16 | 17 |
18 | 34 |
35 |
36 | 37 | 38 |
39 |
40 |
41 | <% include('admin_web/menu/menu_left') %> 42 |
43 |
44 |
45 | 46 | 139 |
140 | 141 | 142 |
143 | <% include('admin_web/footer') %> 144 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /usr/lib/lua/luci/view/admin_web/network/shadowsocks.htm: -------------------------------------------------------------------------------- 1 | <% 2 | --[[ 3 | Info shadowsocks 加速设置 4 | Author WangChao 5 | Copyright 2014 6 | ]]-- 7 | 8 | local ver = require "luci.version" 9 | local adv_menu = luci.util.get_adv_menu() 10 | local request_uri = luci.http.getenv("REQUEST_URI") 11 | %> 12 | 13 | HiWiFi 路由器 14 | 15 | 16 | 17 | 18 | 45 | 164 | 165 | 166 | <% include('admin_web/network/cfg_import') %> 167 | 168 | <% include('admin_web/network/ss_adv') %> 169 | 311 | --------------------------------------------------------------------------------