From 81ff898a64437a3abe76c0fa136b201083e54f27 Mon Sep 17 00:00:00 2001 From: Jian Chang Date: Mon, 5 Apr 2021 11:38:29 +0800 Subject: [PATCH] minor fix Signed-off-by: Jian Chang --- Makefile | 2 +- README.md | 53 +++++++++++-------- files/luci/i18n/shadowsocks.zh-cn.po | 3 -- files/luci/model/cbi/shadowsocks/general.lua | 39 +++++++++----- .../model/cbi/shadowsocks/subscription.lua | 7 +-- files/luci/view/shadowsocks/subscribe.htm | 37 ++++++++----- files/root/usr/bin/ss-subscribe | 1 + 7 files changed, 86 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index a7283cee..27b25a50 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-shadowsocks -PKG_VERSION:=2.0.0 +PKG_VERSION:=2.0.1 PKG_RELEASE:=1 PKG_LICENSE:=GPLv3 diff --git a/README.md b/README.md index 2ce40112..e84548d3 100644 --- a/README.md +++ b/README.md @@ -21,36 +21,47 @@ OpenWrt LuCI for Shadowsocks-libev │      └── luci-shadowsocks // uci-defaults 脚本 └── usr/ ├── bin/ - │   └── ss-rules // 生成代理转发规则的脚本 - └── lib/ - └── lua/ - └── luci/ // LuCI 部分 - ├── controller/ - │   └── shadowsocks.lua // LuCI 菜单配置 - ├── i18n/ // LuCI 语言文件目录 - │   └── shadowsocks.zh-cn.lmo - └── model/ - └── cbi/ - └── shadowsocks/ - ├── general.lua // LuCI 基本设置 - ├── servers.lua // LuCI 服务器列表 - ├── servers-details.lua // LuCI 服务器编辑 - └── access-control.lua // LuCI 访问控制 + │ ├── ss-rules // 生成代理转发规则的脚本 + │ └── ss-subscribe // 订阅脚本 + │── lib/ + │ └── lua/ + │ └── luci/ // LuCI 部分 + │ ├── controller/ + │ │   └── shadowsocks.lua // LuCI 菜单配置 + │ ├── i18n/ // LuCI 语言文件目录 + │ │   └── shadowsocks.zh-cn.lmo + │ │── model/ + │ │ └── cbi/ + │ │ └── shadowsocks/ + │ │ ├── general.lua // LuCI 基本设置 + │ │ ├── subscription.lua // LuCI 订阅管理 + │ │ ├── servers.lua // LuCI 服务器列表 + │ │ ├── servers-details.lua // LuCI 服务器编辑 + │ │ └── access-control.lua // LuCI 访问控制 + │ └── view + │ └── shadowsocks/ + │ ├── general.htm // LuCI View 基本设置 + │ ├── servers-details.htm // LuCI View 服务器编辑 + │ └── subscribe.htm // LuCI View 订阅管理 + └── share/ + └── rpcd/ + └── acl.d/ + └── luci-app-shadowsocks.json // UCI 访问控制列表 ``` 依赖 --- -软件包的正常使用需要依赖 `iptables` 和 `ipset`. +软件包的正常使用需要依赖 `wget`、`resolveip`、`iptables` 和 `ipset`. 软件包不显式依赖 `shadowsocks-libev`, 会根据用户添加的可执行文件启用相应的功能. 可执行文件可通过安装 [openwrt-shadowsocks][openwrt-shadowsocks] 中提供的 `shadowsocks-libev` 获得. 只有当文件存在时, 相应的功能才可被使用, 并显示相应的 LuCI 设置界面. - 可执行文件 | 可选 | 功能 | TCP协议 | UDP协议 - ------------|------|-------------|---------|----------------------------------- - `ss-redir` | 是 | 透明代理 | 支持 | 需安装 `iptables-mod-tproxy`, `ip` - `ss-local` | 是 | SOCKS5 代理 | 支持 | 支持 - `ss-tunnel` | 是 | 端口转发 | 支持 | 支持 + 可执行文件 | 可选 | 功能 | TCP协议 | UDP协议 + ---------------|------|-------------|---------|----------------------------------- + `ss(r)-redir` | 是 | 透明代理 | 支持 | 需安装 `iptables-mod-tproxy`, `ip` + `ss(r)-local` | 是 | SOCKS5 代理 | 支持 | 支持 + `ss(r)-tunnel` | 是 | 端口转发 | 支持 | 支持 注: 可执行文件在 `$PATH` 环境变量所表示的搜索路径中, 都可被正确调用. diff --git a/files/luci/i18n/shadowsocks.zh-cn.po b/files/luci/i18n/shadowsocks.zh-cn.po index 404525c4..03fd5d64 100644 --- a/files/luci/i18n/shadowsocks.zh-cn.po +++ b/files/luci/i18n/shadowsocks.zh-cn.po @@ -228,6 +228,3 @@ msgstr "更新完成" msgid "Update Failed" msgstr "更新失败" - -msgid "Update failed, need to save first" -msgstr "更新失败, 需要先保存" diff --git a/files/luci/model/cbi/shadowsocks/general.lua b/files/luci/model/cbi/shadowsocks/general.lua index 170d004d..26cba2d4 100644 --- a/files/luci/model/cbi/shadowsocks/general.lua +++ b/files/luci/model/cbi/shadowsocks/general.lua @@ -6,6 +6,8 @@ local shadowsocks = "shadowsocks" local uci = luci.model.uci.cursor() local servers = {} local cores = tonumber(luci.sys.exec("grep 'processor' /proc/cpuinfo | wc -l")) +local _max = math.max(math.min(cores * 2, 128), cores) +local _step = math.ceil(_max / 32) local function has_bin(name) return luci.sys.call("command -v %s >/dev/null" %{name}) == 0 @@ -68,9 +70,9 @@ end s = m:section(TypedSection, "general", translate("Global Settings")) s.anonymous = true -o = s:option(Value, "startup_delay", translate("Startup Delay")) +o = s:option(ListValue, "startup_delay", translate("Startup Delay")) o:value(0, translate("Not enabled")) -for _, v in ipairs({5, 10, 15, 25, 40}) do +for _, v in ipairs({5, 10, 15, 25, 40, 60, 90, 120}) do o:value(v, translatef("%u seconds", v)) end o.datatype = "uinteger" @@ -99,10 +101,13 @@ if has_ss_redir or has_ssr_redir then o.default = "nil" o.rmempty = false - o = s:option(Value, "processes", translate("Multiprocessing")) - o:value(0, translatef("Auto(%u processes)", cores)) - for v = 1, cores * 2 do - o:value(v, translatef("%u processes", v)) + o = s:option(ListValue, "processes", translate("Multiprocessing")) + for v = 0, _max, _step do + if v == 0 then + o:value(0, translatef("Auto(%u processes)", cores)) + else + o:value(v, translatef("%u processes", v)) + end end o.datatype = "uinteger" o.default = 0 @@ -130,10 +135,13 @@ if has_ss_local or has_ssr_local then o.default = "nil" o.rmempty = false - o = s:option(Value, "processes", translate("Multiprocessing")) - o:value(0, translatef("Auto(%u processes)", cores)) - for v = 1, cores * 2 do - o:value(v, translatef("%u processes", v)) + o = s:option(ListValue, "processes", translate("Multiprocessing")) + for v = 0, _max, _step do + if v == 0 then + o:value(0, translatef("Auto(%u processes)", cores)) + else + o:value(v, translatef("%u processes", v)) + end end o.datatype = "uinteger" o.default = 0 @@ -161,10 +169,13 @@ if has_ss_tunnel or has_ssr_tunnel then o.default = "nil" o.rmempty = false - o = s:option(Value, "processes", translate("Multiprocessing")) - o:value(0, translatef("Auto(%u processes)", cores)) - for v = 1, cores * 2 do - o:value(v, translatef("%u processes", v)) + o = s:option(ListValue, "processes", translate("Multiprocessing")) + for v = 0, _max, _step do + if v == 0 then + o:value(0, translatef("Auto(%u processes)", cores)) + else + o:value(v, translatef("%u processes", v)) + end end o.datatype = "uinteger" o.default = 0 diff --git a/files/luci/model/cbi/shadowsocks/subscription.lua b/files/luci/model/cbi/shadowsocks/subscription.lua index 14080617..3c666426 100644 --- a/files/luci/model/cbi/shadowsocks/subscription.lua +++ b/files/luci/model/cbi/shadowsocks/subscription.lua @@ -1,7 +1,7 @@ -- Copyright (C) 2021 Jian Chang -- Licensed to the public under the GNU General Public License v3. -local m, s, o +local m, s, o, u local shadowsocks = "shadowsocks" m = Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"), translate("Subscription Manage")}) @@ -13,8 +13,8 @@ s.anonymous = true o = s:option(Value, "name", translate("Subscription Name")) o.rmempty = false -o = s:option(Value, "subscription_url", translate("Subscription URL")) -o.rmempty = false +u = s:option(Value, "subscription_url", translate("Subscription URL")) +u.rmempty = false o = s:option(Value, "filter_words", translate("Filter Words")) o.description = translate("Splited by /. Server whose alias contain the above string will be filtered.") @@ -32,5 +32,6 @@ o.rmempty = false o = s:option(Button, "subscribe", translate("Update Now")) o.rawhtml = true o.template = "shadowsocks/subscribe" +o.url = u return m diff --git a/files/luci/view/shadowsocks/subscribe.htm b/files/luci/view/shadowsocks/subscribe.htm index 6c38868a..57b47d3d 100644 --- a/files/luci/view/shadowsocks/subscribe.htm +++ b/files/luci/view/shadowsocks/subscribe.htm @@ -4,20 +4,29 @@ -%> <%+cbi/valueheader%> + - <%+cbi/valuefooter%> diff --git a/files/root/usr/bin/ss-subscribe b/files/root/usr/bin/ss-subscribe index d46084ae..1f99d593 100644 --- a/files/root/usr/bin/ss-subscribe +++ b/files/root/usr/bin/ss-subscribe @@ -92,6 +92,7 @@ end function check_filter_words(words, str) for _, w in pairs(words) do + w = luci.util.trim(w) if #w > 0 and str:find(w) then return false end