-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
627 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
@@ -8,6 +8,8 @@ function index() | |
return | ||
end | ||
|
||
local page | ||
|
||
page = entry({"admin", "services", "shadowsocks"}, | ||
alias("admin", "services", "shadowsocks", "general"), | ||
_("ShadowSocks"), 10) | ||
|
@@ -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 | ||
|
||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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) | ||
|
@@ -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 | ||
|
||
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
Oops, something went wrong.