From 715088d0140669a097500b1cc4002305dad2c983 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Wed, 23 May 2018 22:12:40 +0800 Subject: [PATCH] update luci-ssr-pro to fit in new luci --- feeds.conf.default | 2 +- include/target.mk | 2 +- .../luasrc/controller/shadowsocksr.lua | 9 -- .../root/etc/uci-defaults/shadowsocksr | 16 --- .../Makefile | 6 +- .../luasrc/controller/ssrpro.lua | 9 ++ .../luasrc/model/cbi/ssrpro.lua} | 12 +- .../po/zh-cn/ssrpro.po | 0 .../root/etc/config/ssrpro} | 11 +- .../root/etc/init.d/ssrpro | 111 ++++++++++-------- .../root/etc/shadowsocksr/addinip.txt | 0 .../root/etc/shadowsocksr/base-gfwlist.txt | 0 .../root/etc/shadowsocksr/gen-gfwlist.sh | 0 .../root/etc/shadowsocksr/ssr-watchdog | 0 .../root/etc/shadowsocksr/up-gfwlist.sh | 0 .../root/etc/ssrpro.include} | 4 +- .../root/etc/uci-defaults/ssrpro | 20 ++++ 17 files changed, 108 insertions(+), 94 deletions(-) delete mode 100644 package/lean/luci-app-shadowsocksr-pro/luasrc/controller/shadowsocksr.lua delete mode 100755 package/lean/luci-app-shadowsocksr-pro/root/etc/uci-defaults/shadowsocksr rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/Makefile (84%) create mode 100644 package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua rename package/lean/{luci-app-shadowsocksr-pro/luasrc/model/cbi/shadowsocksr.lua => luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua} (97%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/po/zh-cn/ssrpro.po (100%) rename package/lean/{luci-app-shadowsocksr-pro/root/etc/config/shadowsocksr => luci-app-ssr-pro/root/etc/config/ssrpro} (65%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/root/etc/init.d/ssrpro (81%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/root/etc/shadowsocksr/addinip.txt (100%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/root/etc/shadowsocksr/base-gfwlist.txt (100%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/root/etc/shadowsocksr/gen-gfwlist.sh (100%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/root/etc/shadowsocksr/ssr-watchdog (100%) rename package/lean/{luci-app-shadowsocksr-pro => luci-app-ssr-pro}/root/etc/shadowsocksr/up-gfwlist.sh (100%) rename package/lean/{luci-app-shadowsocksr-pro/root/etc/shadowsocksr.include => luci-app-ssr-pro/root/etc/ssrpro.include} (55%) create mode 100755 package/lean/luci-app-ssr-pro/root/etc/uci-defaults/ssrpro diff --git a/feeds.conf.default b/feeds.conf.default index f1dec71765973c..5a08c39fa32859 100644 --- a/feeds.conf.default +++ b/feeds.conf.default @@ -1,7 +1,7 @@ #src-git packages https://git.openwrt.org/feed/packages.git^1b73f267eae2dedc18969b70ed7c5d9b02288bac src-git packages https://github.com/openwrt/packages.git #src-git luci https://git.openwrt.org/project/luci.git^7d55be315d758b2a40494e732d7bdc300ee15c00 -src-git luci https://github.com/openwrt/luci.git^80cb4fef8c7db0dadc373fef122d7abb092a7191 +src-git luci https://github.com/openwrt/luci.git #src-git luci https://github.com/openwrt/luci.git;openwrt-18.06 src-git routing https://git.openwrt.org/feed/routing.git;openwrt-18.06 src-git telephony https://github.com/openwrt/telephony.git;openwrt-18.06 diff --git a/include/target.mk b/include/target.mk index efdcd7fc20fa87..0615ad3a3c560f 100644 --- a/include/target.mk +++ b/include/target.mk @@ -16,7 +16,7 @@ DEVICE_TYPE?=router DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd \ iptables-mod-nat-extra kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw kmod-macvlan kmod-nft-offload block-mount automount \ default-settings ipset-lists luci luci-app-ddns luci-app-sqm luci-app-upnp luci-app-adbyby-plus luci-app-autoreboot \ -luci-app-filetransfer luci-app-shadowsocksr-pro luci-app-usb-printer luci-app-vsftpd ddns-scripts_aliyun luci-app-xlnetacc \ +luci-app-filetransfer luci-app-ssr-pro luci-app-usb-printer luci-app-vsftpd ddns-scripts_aliyun luci-app-xlnetacc \ luci-app-pptp-server luci-app-ipsec-vpnd luci-app-vlmcsd luci-app-wifischedule luci-app-wol luci-app-sfe luci-app-flowoffload luci-app-nlbwmon # For nas targets DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm diff --git a/package/lean/luci-app-shadowsocksr-pro/luasrc/controller/shadowsocksr.lua b/package/lean/luci-app-shadowsocksr-pro/luasrc/controller/shadowsocksr.lua deleted file mode 100644 index cb035a53a8afef..00000000000000 --- a/package/lean/luci-app-shadowsocksr-pro/luasrc/controller/shadowsocksr.lua +++ /dev/null @@ -1,9 +0,0 @@ -module("luci.controller.shadowsocksr", package.seeall) -function index() - if not nixio.fs.access("/etc/config/shadowsocksr") then - return - end - local page - page = entry({"admin", "services", "shadowsocksr"}, cbi("shadowsocksr"), _("ShadowsocksR Pro")) - page.dependent = true -end diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/uci-defaults/shadowsocksr b/package/lean/luci-app-shadowsocksr-pro/root/etc/uci-defaults/shadowsocksr deleted file mode 100755 index 86b57ce08f19d3..00000000000000 --- a/package/lean/luci-app-shadowsocksr-pro/root/etc/uci-defaults/shadowsocksr +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete firewall.shadowsocksr - set firewall.shadowsocksr=include - set firewall.shadowsocksr.type=script - set firewall.shadowsocksr.path=/etc/shadowsocksr.include - set firewall.shadowsocksr.reload=1 - commit firewall -EOF - -/etc/init.d/shadowsocksr stop -/etc/init.d/shadowsocksr disable - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/package/lean/luci-app-shadowsocksr-pro/Makefile b/package/lean/luci-app-ssr-pro/Makefile similarity index 84% rename from package/lean/luci-app-shadowsocksr-pro/Makefile rename to package/lean/luci-app-ssr-pro/Makefile index 4d18872ca469c7..108210d34aadf8 100644 --- a/package/lean/luci-app-shadowsocksr-pro/Makefile +++ b/package/lean/luci-app-ssr-pro/Makefile @@ -5,11 +5,11 @@ include $(TOPDIR)/rules.mk -LUCI_TITLE:=LuCI support for Shadowsocksr +LUCI_TITLE:=LuCI support for SSR Pro LUCI_DEPENDS:=+iptables-mod-tproxy +kmod-ipt-tproxy +ip +ipset-lists +shadowsocksr-libev-alt +pdnsd-alt +coreutils +coreutils-base64 +coreutils-nohup +dnsmasq-full LUCI_PKGARCH:=all -PKG_VERSION:=2.0 -PKG_RELEASE:=21 +PKG_VERSION:=2 +PKG_RELEASE:=22 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua b/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua new file mode 100644 index 00000000000000..324c266a4fc086 --- /dev/null +++ b/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua @@ -0,0 +1,9 @@ +module("luci.controller.ssrpro", package.seeall) +function index() + if not nixio.fs.access("/etc/config/ssrpro") then + return + end + local page + page = entry({"admin", "services", "ssrpro"}, cbi("ssrpro"), _("ShadowsocksR Pro")) + page.dependent = true +end diff --git a/package/lean/luci-app-shadowsocksr-pro/luasrc/model/cbi/shadowsocksr.lua b/package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua similarity index 97% rename from package/lean/luci-app-shadowsocksr-pro/luasrc/model/cbi/shadowsocksr.lua rename to package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua index a04b42bfdc5067..dfbca61e164628 100644 --- a/package/lean/luci-app-shadowsocksr-pro/luasrc/model/cbi/shadowsocksr.lua +++ b/package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua @@ -16,11 +16,11 @@ else Status = translate("ShadowsocksR is Not Running") end -m = Map("shadowsocksr") +m = Map("ssrpro") m.title = translate("Shadowsocksr Transparent Proxy") m.description = translate("A fast secure tunnel proxy that help you get through firewalls on your router") -s = m:section(TypedSection, "shadowsocksr") +s = m:section(TypedSection, "ssrpro") s.anonymous = true s.description = translate(string.format("%s

", Status)) @@ -223,9 +223,9 @@ e:value("global",translate("Global Proxy")) e:value("game",translate("Game Mode")) -- --------------------------------------------------- -local apply = luci.http.formvalue("cbi.apply") -if apply then - os.execute("/etc/init.d/ssrpro restart >/dev/null 2>&1 &") -end +-- local apply = luci.http.formvalue("cbi.apply") +-- if apply then +-- os.execute("/etc/init.d/ssrpro restart >/dev/null 2>&1 &") +-- end return m diff --git a/package/lean/luci-app-shadowsocksr-pro/po/zh-cn/ssrpro.po b/package/lean/luci-app-ssr-pro/po/zh-cn/ssrpro.po similarity index 100% rename from package/lean/luci-app-shadowsocksr-pro/po/zh-cn/ssrpro.po rename to package/lean/luci-app-ssr-pro/po/zh-cn/ssrpro.po diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/config/shadowsocksr b/package/lean/luci-app-ssr-pro/root/etc/config/ssrpro similarity index 65% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/config/shadowsocksr rename to package/lean/luci-app-ssr-pro/root/etc/config/ssrpro index 35ed7e5aad252a..eb8939f8c5bb30 100644 --- a/package/lean/luci-app-shadowsocksr-pro/root/etc/config/shadowsocksr +++ b/package/lean/luci-app-ssr-pro/root/etc/config/ssrpro @@ -1,13 +1,14 @@ -config shadowsocksr +config ssrpro option gfwlist 'china-banned' - option server 'serv-ro.ddns.info' option server_port '23143' option password 'test.TEST' - option method 'aes-256-cfb' option protocol 'origin' option obfs 'plain' - option enabled '0' option proxy_mode 'M' option safe_dns_tcp '1' - option cron_mode '1' + option cron_mode '1' + option method 'none' + option server '4.4.4.4' + option enabled '0' + diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/init.d/ssrpro b/package/lean/luci-app-ssr-pro/root/etc/init.d/ssrpro similarity index 81% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/init.d/ssrpro rename to package/lean/luci-app-ssr-pro/root/etc/init.d/ssrpro index 2242798567998a..e6f35c4b22edb6 100755 --- a/package/lean/luci-app-shadowsocksr-pro/root/etc/init.d/ssrpro +++ b/package/lean/luci-app-ssr-pro/root/etc/init.d/ssrpro @@ -3,25 +3,51 @@ # START=99 +STOP=10 + +EXTRA_COMMANDS="reload_rule" SS_REDIR_PORT=7070 SS_REDIR_PIDFILE=/var/run/ssr-redir-go.pid PDNSD_LOCAL_PORT=7453 SSRCONF=/etc/shadowsocksr.json CRON_FILE=/etc/crontabs/root -CONFIG=shadowsocksr +CONFIG=ssrpro +KEEP_GFWLIST=Y +vt_np_ipset="china" + +get_config() +{ + config_get_bool vt_enabled $1 enabled 0 + config_get vt_server_addr $1 server + config_get vt_server_port $1 server_port + config_get vt_password $1 password + config_get vt_method $1 method + config_get vt_protocol $1 protocol + config_get vt_protoparam $1 protoparam + config_get vt_obfs $1 obfs + config_get obfs_param $1 obfs_param + config_get vt_proxy_mode $1 proxy_mode + config_get vt_timeout $1 timeout + config_get vt_safe_dns $1 safe_dns + config_get vt_timeout $1 timeout + config_get vt_safe_dns $1 safe_dns + config_get vt_safe_dns_port $1 safe_dns_port + config_get vt_safe_dns_tcp $1 safe_dns_tcp + config_get cron_mode $1 cron_mode 1 +} + + # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # $covered_subnets, $local_addresses are not required -covered_subnets=`uci get shadowsocksr.@shadowsocksr[0].covered_subnets 2>/dev/null` -local_addresses=`uci get shadowsocksr.@shadowsocksr[0].local_addresses 2>/dev/null` # Get LAN settings as default parameters [ -f /lib/functions/network.sh ] && . /lib/functions/network.sh - [ -z "$covered_subnets" ] && network_get_subnet covered_subnets lan - [ -z "$local_addresses" ] && network_get_ipaddr local_addresses lan -vt_np_ipset="china" # Must be global variable + network_get_subnet covered_subnets lan + network_get_ipaddr local_addresses lan + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- __gfwlist_by_mode() { @@ -31,42 +57,24 @@ __gfwlist_by_mode() esac } - - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - start() -{ - local vt_enabled=`uci get shadowsocksr.@shadowsocksr[0].enabled 2>/dev/null` - local vt_server_addr=`uci get shadowsocksr.@shadowsocksr[0].server` - local vt_server_port=`uci get shadowsocksr.@shadowsocksr[0].server_port` - local vt_password=`uci get shadowsocksr.@shadowsocksr[0].password 2>/dev/null` - local vt_method=`uci get shadowsocksr.@shadowsocksr[0].method` - local vt_protocol=`uci get shadowsocksr.@shadowsocksr[0].protocol` - local vt_protoparam=`uci get shadowsocksr.@shadowsocksr[0].protoparam 2>/dev/null` - local vt_obfs=`uci get shadowsocksr.@shadowsocksr[0].obfs` - local vt_timeout=`uci get shadowsocksr.@shadowsocksr[0].timeout 2>/dev/null` - local vt_safe_dns=`uci get shadowsocksr.@shadowsocksr[0].safe_dns 2>/dev/null` - local vt_safe_dns_port=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_port 2>/dev/null` - local vt_safe_dns_tcp=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_tcp 2>/dev/null` - local vt_proxy_mode=`uci get shadowsocksr.@shadowsocksr[0].proxy_mode` - local obfs_param=`uci get shadowsocksr.@shadowsocksr[0].obfs_param 2>/dev/null` - local cron_mode=`uci get shadowsocksr.@shadowsocksr[0].cron_mode 2>/dev/null` - local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode` - +{ + config_load ssrpro + config_foreach get_config ssrpro + [ -f /etc/init.d/pdnsd ] && /etc/init.d/pdnsd disable 2>/dev/null - - # ----------------------------------------------------------------- + if [ "$vt_enabled" = 0 ]; then echo "WARNING: Shadowsocksr is disabled." - return 1 + exit 0 fi if [ -z "$vt_server_addr" -o -z "$vt_server_port" ]; then echo "WARNING: Shadowsocksr not fully configured, not starting." - return 1 + exit 0 fi - + + local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode` [ -z "$vt_proxy_mode" ] && vt_proxy_mode=M [ -z "$vt_method" ] && vt_method=table [ -z "$vt_timeout" ] && vt_timeout=60 @@ -96,6 +104,7 @@ start() "fast_open": false } EOF + /usr/bin/ssr-redir -u -c $SSRCONF -f $SS_REDIR_PIDFILE || return 1 # IPv4 firewall rules @@ -133,12 +142,12 @@ EOF conf-dir=/var/etc/dnsmasq-go.d EOF /etc/init.d/dnsmasq restart - - fi + add_cron } + stop() { @@ -163,23 +172,14 @@ stop() del_cron } -restart() -{ - KEEP_GFWLIST=Y - stop - start -} -reload() +reload_rule() { - local vt_enabled=`uci get shadowsocksr.@shadowsocksr[0].enabled 2>/dev/null` - local vt_server_addr=`uci get shadowsocksr.@shadowsocksr[0].server` - local vt_server_port=`uci get shadowsocksr.@shadowsocksr[0].server_port` - local vt_safe_dns=`uci get shadowsocksr.@shadowsocksr[0].safe_dns 2>/dev/null` - local vt_safe_dns_port=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_port 2>/dev/null` - local vt_safe_dns_tcp=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_tcp 2>/dev/null` - local vt_proxy_mode=`uci get shadowsocksr.@shadowsocksr[0].proxy_mode` - local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode` + config_load ssrpro + config_foreach get_config ssrpro + + local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode` + KEEP_GFWLIST=Y del_rule add_rule @@ -189,6 +189,14 @@ reload() fi } +restart() +{ + KEEP_GFWLIST=Y + stop + start +} + + # $1: upstream DNS server start_pdnsd() { @@ -384,3 +392,4 @@ del_rule() # ----------------------------------------------------------------- [ "$KEEP_GFWLIST" = Y ] || ipset destroy "$vt_gfwlist" 2>/dev/null } + diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/addinip.txt b/package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/addinip.txt similarity index 100% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/addinip.txt rename to package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/addinip.txt diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/base-gfwlist.txt b/package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/base-gfwlist.txt similarity index 100% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/base-gfwlist.txt rename to package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/base-gfwlist.txt diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/gen-gfwlist.sh b/package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/gen-gfwlist.sh similarity index 100% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/gen-gfwlist.sh rename to package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/gen-gfwlist.sh diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/ssr-watchdog b/package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/ssr-watchdog similarity index 100% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/ssr-watchdog rename to package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/ssr-watchdog diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/up-gfwlist.sh b/package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/up-gfwlist.sh similarity index 100% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr/up-gfwlist.sh rename to package/lean/luci-app-ssr-pro/root/etc/shadowsocksr/up-gfwlist.sh diff --git a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr.include b/package/lean/luci-app-ssr-pro/root/etc/ssrpro.include similarity index 55% rename from package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr.include rename to package/lean/luci-app-ssr-pro/root/etc/ssrpro.include index 1e270c09cf5e20..140adc7472582e 100755 --- a/package/lean/luci-app-shadowsocksr-pro/root/etc/shadowsocksr.include +++ b/package/lean/luci-app-ssr-pro/root/etc/ssrpro.include @@ -1,10 +1,10 @@ #!/bin/sh -ssr_enable=$(uci get shadowsocksr.@shadowsocksr[0].enabled 2>/dev/null) +ssr_enable=$(uci get ssrpro.@ssrpro[0].enabled 2>/dev/null) if [ $ssr_enable -eq 1 ]; then if pidof ssr-redir>/dev/null; then - /etc/init.d/ssrpro reload + /etc/init.d/ssrpro reload_rule else /etc/init.d/ssrpro restart fi diff --git a/package/lean/luci-app-ssr-pro/root/etc/uci-defaults/ssrpro b/package/lean/luci-app-ssr-pro/root/etc/uci-defaults/ssrpro new file mode 100755 index 00000000000000..8aa2c71cc1eea6 --- /dev/null +++ b/package/lean/luci-app-ssr-pro/root/etc/uci-defaults/ssrpro @@ -0,0 +1,20 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@ssrpro[-1] + add ucitrack ssrpro + set ucitrack.@ssrpro[-1].init=ssrpro + commit ucitrack + delete firewall.ssrpro + set firewall.ssrpro=include + set firewall.ssrpro.type=script + set firewall.ssrpro.path=/etc/ssrpro.include + set firewall.ssrpro.reload=1 + commit firewall +EOF + +/etc/init.d/ssrpro stop +/etc/init.d/ssrpro enable + +rm -f /tmp/luci-indexcache +exit 0