Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Chang <[email protected]>
  • Loading branch information
aa65535 committed Apr 5, 2021
1 parent 435dc72 commit 81ff898
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 环境变量所表示的搜索路径中, 都可被正确调用.

Expand Down
3 changes: 0 additions & 3 deletions files/luci/i18n/shadowsocks.zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,3 @@ msgstr "更新完成"

msgid "Update Failed"
msgstr "更新失败"

msgid "Update failed, need to save first"
msgstr "更新失败, 需要先保存"
39 changes: 25 additions & 14 deletions files/luci/model/cbi/shadowsocks/general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions files/luci/model/cbi/shadowsocks/subscription.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Copyright (C) 2021 Jian Chang <[email protected]>
-- 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")})
Expand All @@ -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 <code style='color:red'>/</code>. Server whose alias contain the above string will be filtered.")
Expand All @@ -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
37 changes: 23 additions & 14 deletions files/luci/view/shadowsocks/subscribe.htm
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@
-%>

<%+cbi/valueheader%>
<input type="button" id="<%=cbid%>" class="cbi-button cbi-input-apply" value="<%:Update Now%>" />
<script type="text/javascript">//<![CDATA[
function subscribe(btn, section) {
btn.disabled = true;
btn.value = "<%:Updating...%>";
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocks","subscribe")%>', { section }, function(x, resp) {
if (resp.code) {
btn.value = "<%:Update Failed%>";
alert("<%:Update failed, need to save first%>")
} else {
btn.value = "<%:Update Completed%>";
}
});
return false;
}
(function($) {
$("<%=cbid%>").onclick = function() {
var btn = this;
var section = '<%=section%>';
btn.disabled = true;
btn.value = '<%:Updating...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocks", "subscribe")%>', { section }, function(x, resp) {
if (resp.code) {
btn.value = '<%:Update Failed%>';
} else {
btn.value = '<%:Update Completed%>';
}
});
return false;
};
if (!'<%=self.url:cfgvalue(section)%>') {
var wrap = $('<%=cbid%>'.replaceAll('.', '-').replace('cbid', 'cbi'));
wrap.parentNode.removeChild(wrap);
}
}(function(id) {
return document.getElementById(id);
}));
//]]></script>
<input type="button" class="cbi-button cbi-input-apply" value="<%:Update Now%>" onclick="return subscribe(this,'<%=section%>')" />
<%+cbi/valuefooter%>
1 change: 1 addition & 0 deletions files/root/usr/bin/ss-subscribe
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 81ff898

Please sign in to comment.