Skip to content

Commit

Permalink
update to 2.0.0
Browse files Browse the repository at this point in the history
close #257 #235 #254 #246 #234

Signed-off-by: Jian Chang <[email protected]>
  • Loading branch information
aa65535 committed Apr 3, 2021
1 parent 3c90d2b commit 435dc72
Show file tree
Hide file tree
Showing 14 changed files with 627 additions and 140 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2016-2018 Jian Chang <[email protected]>
# Copyright (C) 2016-2021 Jian Chang <[email protected]>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
Expand All @@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-shadowsocks
PKG_VERSION:=1.9.1
PKG_VERSION:=2.0.0
PKG_RELEASE:=1

PKG_LICENSE:=GPLv3
Expand All @@ -25,7 +25,7 @@ define Package/luci-app-shadowsocks/Default
SUBMENU:=3. Applications
TITLE:=LuCI Support for shadowsocks-libev
PKGARCH:=all
DEPENDS:=+iptables $(1)
DEPENDS:=+iptables +wget +resolveip $(1)
endef

Package/luci-app-shadowsocks = $(call Package/luci-app-shadowsocks/Default,+ipset)
Expand Down Expand Up @@ -87,6 +87,7 @@ define Package/luci-app-shadowsocks/install
$(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-shadowsocks $(1)/etc/uci-defaults/luci-shadowsocks
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/root/usr/bin/ss-rules$(2) $(1)/usr/bin/ss-rules
$(INSTALL_BIN) ./files/root/usr/bin/ss-subscribe $(1)/usr/bin/ss-subscribe
endef

Package/luci-app-shadowsocks-without-ipset/install = $(call Package/luci-app-shadowsocks/install,$(1),-without-ipset)
Expand Down
31 changes: 26 additions & 5 deletions files/luci/controller/shadowsocks.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Copyright (C) 2014-2017 Jian Chang <[email protected]>
-- Copyright (C) 2014-2021 Jian Chang <[email protected]>
-- Licensed to the public under the GNU General Public License v3.

module("luci.controller.shadowsocks", package.seeall)
Expand All @@ -8,6 +8,8 @@ function index()
return
end

local page

page = entry({"admin", "services", "shadowsocks"},
alias("admin", "services", "shadowsocks", "general"),
_("ShadowSocks"), 10)
Expand All @@ -25,13 +27,25 @@ function index()
page.leaf = true
page.acl_depends = { "luci-app-shadowsocks" }

page = entry({"admin", "services", "shadowsocks", "subscription"},
cbi("shadowsocks/subscription"),
_("Subscription Manage"), 15)
page.leaf = true
page.acl_depends = { "luci-app-shadowsocks" }

page = entry({"admin", "services", "shadowsocks", "subscribe"},
call("action_subscribe"))
page.leaf = true
page.acl_depends = { "luci-app-shadowsocks" }

page = entry({"admin", "services", "shadowsocks", "servers"},
arcombine(cbi("shadowsocks/servers"), cbi("shadowsocks/servers-details")),
_("Servers Manage"), 20)
page.leaf = true
page.acl_depends = { "luci-app-shadowsocks" }

if luci.sys.call("command -v ss-redir >/dev/null") ~= 0 then
if luci.sys.call("command -v ss-redir >/dev/null") ~= 0
and luci.sys.call("command -v ssr-redir >/dev/null") ~= 0 then
return
end

Expand All @@ -49,8 +63,15 @@ end
function action_status()
luci.http.prepare_content("application/json")
luci.http.write_json({
ss_redir = is_running("ss-redir"),
ss_local = is_running("ss-local"),
ss_tunnel = is_running("ss-tunnel")
ss_redir = (is_running("ss-redir") or is_running("ssr-redir")),
ss_local = (is_running("ss-local") or is_running("ssr-local")),
ss_tunnel = (is_running("ss-tunnel") or is_running("ssr-tunnel"))
})
end

function action_subscribe()
local section = luci.http.formvalue("section")
local code = luci.sys.call("/usr/bin/lua /usr/bin/ss-subscribe %s >/tmp/sub.log" %{section})
luci.http.prepare_content("application/json")
luci.http.write_json({code = code})
end
66 changes: 66 additions & 0 deletions files/luci/i18n/shadowsocks.zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,69 @@ msgstr "内网区域"

msgid "Zone WAN"
msgstr "外网区域"

msgid "Group Name"
msgstr "分组名称"

msgid "Server Type"
msgstr "服务器类型"

msgid "Server Host"
msgstr "服务器域名"

msgid "Protocol"
msgstr "协议"

msgid "Protocol Param"
msgstr "协议参数"

msgid "Obfuscation"
msgstr "混淆"

msgid "Obfuscation Param"
msgstr "混淆参数"

msgid "Multiprocessing"
msgstr "多进程"

msgid "Auto(%u processes)"
msgstr "自动(%u个进程)"

msgid "%u processes"
msgstr "%u个进程"

msgid "Subscription Manage"
msgstr "订阅管理"

msgid "Subscription Name"
msgstr "订阅名称"

msgid "Subscription URL"
msgstr "订阅链接"

msgid "Filter Words"
msgstr "过滤字符"

msgid "Splited by <code style='color:red'>/</code>. Server whose alias contain the above string will be filtered."
msgstr "多个字符使用 <code style='color:red'>/</code> 隔开,别名包含以上字符的的节点将被过滤。"

msgid "Auto Update"
msgstr "自动更新"

msgid "Update Hour"
msgstr "更新时间"

msgid "Update Now"
msgstr "立即更新"

msgid "Updating..."
msgstr "更新中……"

msgid "Update Completed"
msgstr "更新完成"

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

msgid "Update failed, need to save first"
msgstr "更新失败, 需要先保存"
4 changes: 1 addition & 3 deletions files/luci/model/cbi/shadowsocks/access-control.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
-- Copyright (C) 2016-2017 Jian Chang <[email protected]>
-- Copyright (C) 2016-2021 Jian Chang <[email protected]>
-- Licensed to the public under the GNU General Public License v3.

local m, s, o
local shadowsocks = "shadowsocks"
local uci = luci.model.uci.cursor()
local nwm = require("luci.model.network").init()
local chnroute = uci:get_first("chinadns", "chinadns", "chnroute")
local lan_ifaces = {}
local io = require "io"

Expand Down Expand Up @@ -49,7 +48,6 @@ s.anonymous = true

o = s:option(Value, "wan_bp_list", translate("Bypassed IP List"))
o:value("/dev/null", translate("NULL - As Global Proxy"))
if chnroute then o:value(chnroute, translate("ChinaDNS CHNRoute")) end
o.datatype = "or(file, '/dev/null')"
o.default = "/dev/null"
o.rmempty = false
Expand Down
64 changes: 46 additions & 18 deletions files/luci/model/cbi/shadowsocks/general.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
-- Copyright (C) 2014-2018 Jian Chang <[email protected]>
-- Copyright (C) 2014-2021 Jian Chang <[email protected]>
-- Licensed to the public under the GNU General Public License v3.

local m, s, o
local shadowsocks = "shadowsocks"
local uci = luci.model.uci.cursor()
local servers = {}
local cores = tonumber(luci.sys.exec("grep 'processor' /proc/cpuinfo | wc -l"))

local function has_bin(name)
return luci.sys.call("command -v %s >/dev/null" %{name}) == 0
end

local function has_ss_bin()
return has_bin("ss-redir"), has_bin("ss-local"), has_bin("ss-tunnel")
local function has_bins()
return has_bin("ss-redir"), has_bin("ssr-redir"), has_bin("ss-local"), has_bin("ssr-local"), has_bin("ss-tunnel"), has_bin("ssr-tunnel")
end

local function has_udp_relay()
return luci.sys.call("lsmod | grep -q TPROXY && command -v ip >/dev/null") == 0
end

local has_redir, has_local, has_tunnel = has_ss_bin()
local has_ss_redir, has_ssr_redir, has_ss_local, has_ssr_local, has_ss_tunnel, has_ssr_tunnel = has_bins()

if not has_redir and not has_local and not has_tunnel then
if not has_ss_redir and not has_ssr_redir and not has_ss_local and not has_ssr_local and not has_ss_tunnel and not has_ssr_tunnel then
return Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"),
translate("General Settings")}, '<b style="color:red">shadowsocks-libev binary file not found.</b>')
end
Expand All @@ -30,7 +31,7 @@ local function is_running(name)
end

local function get_status(name)
return is_running(name) and translate("RUNNING") or translate("NOT RUNNING")
return (is_running(name %{"ss"}) or is_running(name %{"ssr"})) and translate("RUNNING") or translate("NOT RUNNING")
end

uci:foreach(shadowsocks, "servers", function(s)
Expand All @@ -46,21 +47,21 @@ m.template = "shadowsocks/general"
s = m:section(TypedSection, "general", translate("Running Status"))
s.anonymous = true

if has_redir then
if has_ss_redir or has_ssr_redir then
o = s:option(DummyValue, "_redir_status", translate("Transparent Proxy"))
o.value = "<span id=\"_redir_status\">%s</span>" %{get_status("ss-redir")}
o.value = "<span id=\"_redir_status\">%s</span>" %{get_status("%s-redir")}
o.rawhtml = true
end

if has_local then
if has_ss_local or has_ssr_local then
o = s:option(DummyValue, "_local_status", translate("SOCKS5 Proxy"))
o.value = "<span id=\"_local_status\">%s</span>" %{get_status("ss-local")}
o.value = "<span id=\"_local_status\">%s</span>" %{get_status("%s-local")}
o.rawhtml = true
end

if has_tunnel then
if has_ss_tunnel or has_ssr_tunnel then
o = s:option(DummyValue, "_tunnel_status", translate("Port Forward"))
o.value = "<span id=\"_tunnel_status\">%s</span>" %{get_status("ss-tunnel")}
o.value = "<span id=\"_tunnel_status\">%s</span>" %{get_status("%s-tunnel")}
o.rawhtml = true
end

Expand All @@ -77,11 +78,11 @@ o.default = 0
o.rmempty = false

-- [[ Transparent Proxy ]]--
if has_redir then
if has_ss_redir or has_ssr_redir then
s = m:section(TypedSection, "transparent_proxy", translate("Transparent Proxy"))
s.anonymous = true

o = s:option(DynamicList, "main_server", translate("Main Server"))
o = s:option(ListValue, "main_server", translate("Main Server"))
o:value("nil", translate("Disable"))
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
o.default = "nil"
Expand All @@ -98,6 +99,15 @@ if has_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))
end
o.datatype = "uinteger"
o.default = 0
o.rmempty = false

o = s:option(Value, "local_port", translate("Local Port"))
o.datatype = "port"
o.default = 1234
Expand All @@ -110,16 +120,25 @@ if has_redir then
end

-- [[ SOCKS5 Proxy ]]--
if has_local then
if has_ss_local or has_ssr_local then
s = m:section(TypedSection, "socks5_proxy", translate("SOCKS5 Proxy"))
s.anonymous = true

o = s:option(DynamicList, "server", translate("Server"))
o = s:option(ListValue, "server", translate("Server"))
o:value("nil", translate("Disable"))
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
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))
end
o.datatype = "uinteger"
o.default = 0
o.rmempty = false

o = s:option(Value, "local_port", translate("Local Port"))
o.datatype = "port"
o.default = 1080
Expand All @@ -132,16 +151,25 @@ if has_local then
end

-- [[ Port Forward ]]--
if has_tunnel then
if has_ss_tunnel or has_ssr_tunnel then
s = m:section(TypedSection, "port_forward", translate("Port Forward"))
s.anonymous = true

o = s:option(DynamicList, "server", translate("Server"))
o = s:option(ListValue, "server", translate("Server"))
o:value("nil", translate("Disable"))
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
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))
end
o.datatype = "uinteger"
o.default = 0
o.rmempty = false

o = s:option(Value, "local_port", translate("Local Port"))
o.datatype = "port"
o.default = 5300
Expand Down
Loading

0 comments on commit 435dc72

Please sign in to comment.