diff --git a/luci-app-ssr-plus/Makefile b/luci-app-ssr-plus/Makefile index 6076f741..9e217090 100644 --- a/luci-app-ssr-plus/Makefile +++ b/luci-app-ssr-plus/Makefile @@ -1,14 +1,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus -PKG_VERSION:=181 -PKG_RELEASE:=4 - -include $(INCLUDE_DIR)/package.mk +PKG_VERSION:=182 +PKG_RELEASE:=1 define Package/$(PKG_NAME)/conffiles /etc/config/shadowsocksr -/etc/ssr/ +/etc/ssrplus/ endef define Package/$(PKG_NAME)/config @@ -46,17 +44,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server default y if i386||x86_64||arm||aarch64 endef -PKG_CONFIG_DEPENDS:= \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Redsocks2 \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server - -LUCI_TITLE:=SS/SSR/V2Ray/Xray/Trojan/NaiveProxy/Socks5/Tun LuCI interface +LUCI_TITLE:=SS/SSR/V2Ray/Trojan/NaiveProxy/Socks5/Tun LuCI interface LUCI_PKGARCH:=all LUCI_DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget +lua +libuci-lua \ +microsocks +dns2socks +shadowsocks-libev-ss-local +shadowsocksr-libev-ssr-local +shadowsocks-libev-ss-redir +simple-obfs +tcping +resolveip\ diff --git a/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua b/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua index 711c4627..61f44147 100644 --- a/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua +++ b/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua @@ -1,30 +1,30 @@ -- Copyright (C) 2017 yushi studio -- Licensed to the public under the GNU General Public License v3. - module("luci.controller.shadowsocksr", package.seeall) function index() if not nixio.fs.access("/etc/config/shadowsocksr") then return end - entry({"admin", "services", "shadowsocksr"}, alias("admin", "services", "shadowsocksr", "client"),_("ShadowSocksR Plus+"), 10).dependent = true - entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true - entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply = true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true - entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true - entry({"admin", "services", "shadowsocksr", "advanced"},cbi("shadowsocksr/advanced"),_("Advanced Settings"), 50).leaf = true - entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true - entry({"admin", "services", "shadowsocksr", "status"},form("shadowsocksr/status"),_("Status"), 70).leaf = true + entry({"admin", "services", "shadowsocksr"}, alias("admin", "services", "shadowsocksr", "client"), _("ShadowSocksR Plus+"), 10).dependent = true + entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"), _("SSR Client"), 10).leaf = true + entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply = true}), cbi("shadowsocksr/client-config")), _("Severs Nodes"), 20).leaf = true + entry({"admin", "services", "shadowsocksr", "control"}, cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true + entry({"admin", "services", "shadowsocksr", "advanced"}, cbi("shadowsocksr/advanced"), _("Advanced Settings"), 50).leaf = true + entry({"admin", "services", "shadowsocksr", "server"}, arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")), _("SSR Server"), 60).leaf = true + entry({"admin", "services", "shadowsocksr", "status"}, form("shadowsocksr/status"), _("Status"), 70).leaf = true entry({"admin", "services", "shadowsocksr", "check"}, call("check_status")) entry({"admin", "services", "shadowsocksr", "refresh"}, call("refresh_data")) entry({"admin", "services", "shadowsocksr", "subscribe"}, call("subscribe")) entry({"admin", "services", "shadowsocksr", "checkport"}, call("check_port")) - entry({"admin", "services", "shadowsocksr", "log"},form("shadowsocksr/log"),_("Log"), 80).leaf = true - entry({"admin", "services", "shadowsocksr","run"},call("act_status")).leaf = true + entry({"admin", "services", "shadowsocksr", "log"}, form("shadowsocksr/log"), _("Log"), 80).leaf = true + entry({"admin", "services", "shadowsocksr", "run"}, call("act_status")).leaf = true entry({"admin", "services", "shadowsocksr", "ping"}, call("act_ping")).leaf = true + entry({"admin", "services", "shadowsocksr", "reset"}, call("act_reset")) end function subscribe() - luci.sys.call("/usr/bin/lua /usr/share/shadowsocksr/subscribe.lua >> /tmp/ssrplus.log 2>&1") + luci.sys.call("/usr/bin/lua /usr/share/shadowsocksr/subscribe.lua >>/var/log/ssrplus.log") luci.http.prepare_content("application/json") luci.http.write_json({ret = 1}) end @@ -41,16 +41,16 @@ function act_ping() local domain = luci.http.formvalue("domain") local port = luci.http.formvalue("port") e.index = luci.http.formvalue("index") - local iret = luci.sys.call(" ipset add ss_spec_wan_ac " .. domain .. " 2>/dev/null") + local iret = luci.sys.call("ipset add ss_spec_wan_ac " .. domain .. " 2>/dev/null") local socket = nixio.socket("inet", "stream") socket:setopt("socket", "rcvtimeo", 3) socket:setopt("socket", "sndtimeo", 3) e.socket = socket:connect(domain, port) socket:close() --- e.ping = luci.sys.exec("ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'" % domain) --- if (e.ping == "") then - e.ping = luci.sys.exec(string.format("echo -n $(tcping -q -c 1 -i 1 -t 2 -p %s %s 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print $2}') 2>/dev/null",port, domain)) --- end + -- e.ping = luci.sys.exec("ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'" % domain) + -- if (e.ping == "") then + e.ping = luci.sys.exec(string.format("echo -n $(tcping -q -c 1 -i 1 -t 2 -p %s %s 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print $2}') 2>/dev/null", port, domain)) + -- end if (iret == 0) then luci.sys.call(" ipset del ss_spec_wan_ac " .. domain) end @@ -72,55 +72,9 @@ end function refresh_data() local set = luci.http.formvalue("set") - local uci = luci.model.uci.cursor() - local icount = 0 - local retstring = 0 - local function update(url, file, type, file2) - local Num = 1 - refresh_cmd = "wget-ssl --no-check-certificate -t 3 -T 10 -O- " .. url .. " > /tmp/ssr-update." .. type - sret = luci.sys.call(refresh_cmd .. " 2>/dev/null") - if sret == 0 then - if type == "gfw_data" then - luci.sys.call("/usr/bin/ssr-gfw " .. type) - Num = 2 - end - if type == "ad_data" then - luci.sys.call("/usr/bin/ssr-ad " .. type) - end - local new_md5 = luci.sys.exec("echo -n $([ -f '/tmp/ssr-update." .. type .. "' ] && md5sum /tmp/ssr-update." .. type .. " | awk '{print $1}')") - local old_md5 = luci.sys.exec("echo -n $([ -f '" .. file .. "' ] && md5sum " .. file .. " | awk '{print $1}')") - if new_md5 == old_md5 then - retstring = "0" - else - icount = luci.sys.exec("cat /tmp/ssr-update." .. type .. " | wc -l") - luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file) - if file2 then luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file2) end - retstring = tostring(tonumber(icount)/Num) - if type == "gfw_data" or type == "ad_data" then - luci.sys.exec("/usr/share/shadowsocksr/gfw2ipset.sh") - else - luci.sys.exec("/usr/share/shadowsocksr/chinaipset.sh /tmp/etc/china_ssr.txt") - end - end - else - retstring = "-1" - end - luci.sys.exec("rm -f /tmp/ssr-update." .. type) - end - if set == "gfw_data" then - update(uci:get_first("shadowsocksr", "global", "gfwlist_url", "https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt"), "/etc/ssr/gfw_list.conf", set, "/tmp/dnsmasq.ssr/gfw_list.conf") - end - if set == "ip_data" then - update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", set, "/tmp/etc/china_ssr.txt") - end - if set == "ad_data" then - update(uci:get_first("shadowsocksr", "global", "adblock_url","https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"), "/etc/ssr/ad.conf", set, "/tmp/dnsmasq.ssr/ad.conf") - end - if set == "nfip_data" then - update(uci:get_first("shadowsocksr", "global", "nfip_url","https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt"), "/etc/ssr/netflixip.list", set) - end + local retstring = luci.sys.exec("/usr/bin/lua /usr/share/shadowsocksr/update.lua " .. set) luci.http.prepare_content("application/json") - luci.http.write_json({ret = retstring,retcount = icount}) + luci.http.write_json({ret = tonumber(retstring)}) end function check_port() @@ -134,13 +88,13 @@ function check_port() if s.alias then server_name = s.alias elseif s.server and s.server_port then - server_name = "%s:%s" %{s.server, s.server_port} + server_name = "%s:%s" % {s.server, s.server_port} end iret = luci.sys.call("ipset add ss_spec_wan_ac " .. s.server .. " 2>/dev/null") socket = nixio.socket("inet", "stream") socket:setopt("socket", "rcvtimeo", 3) socket:setopt("socket", "sndtimeo", 3) - ret = socket:connect(s.server,s.server_port) + ret = socket:connect(s.server, s.server_port) if tostring(ret) == "true" then socket:close() retstring = retstring .. "[" .. server_name .. "] OK.
" @@ -154,3 +108,9 @@ function check_port() luci.http.prepare_content("application/json") luci.http.write_json({ret = retstring}) end + +function act_reset() + nixio.exec("/etc/init.d/shadowsocksr", "reset") + http.redirect(luci.dispatcher.build_url('admin/services/shadowsocksr')) + return +end diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index 8db33642..02d156f3 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -1,19 +1,18 @@ -local shadowsocksr = "shadowsocksr" local uci = luci.model.uci.cursor() local server_table = {} -uci:foreach(shadowsocksr, "servers", function(s) +uci:foreach("shadowsocksr", "servers", function(s) if s.alias then - server_table[s[".name"]] = "[%s]:%s" %{string.upper(s.type), s.alias} + server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.type), s.alias} elseif s.server and s.server_port then - server_table[s[".name"]] = "[%s]:%s:%s" %{string.upper(s.type), s.server, s.server_port} + server_table[s[".name"]] = "[%s]:%s:%s" % {string.upper(s.type), s.server, s.server_port} end end) -local key_table = {} -for key,_ in pairs(server_table) do - table.insert(key_table,key) -end +local key_table = {} +for key, _ in pairs(server_table) do + table.insert(key_table, key) +end table.sort(key_table) @@ -49,9 +48,10 @@ o = s:option(Flag, "adblock", translate("Enable adblock")) o.rmempty = false o = s:option(Value, "adblock_url", translate("adblock_url")) +o:value("https://neodev.team/lite_host_dnsmasq.conf", translate("NEO DEV HOST Lite")) +o:value("https://neodev.team/host_dnsmasq.conf", translate("NEO DEV HOST Full")) o:value("https://anti-ad.net/anti-ad-for-dnsmasq.conf", translate("anti-AD")) -o:value("https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt", translate("Easylist China")) -o.default = "https://anti-ad.net/anti-ad-for-dnsmasq.conf" +o.default = "https://neodev.team/lite_host_dnsmasq.conf" o:depends("adblock", "1") o.description = translate("Support AdGuardHome and DNSMASQ format list") @@ -73,6 +73,10 @@ o:value("https://cdn.jsdelivr.net/gh/QiuSimons/Netflix_IP/getflix.txt", translat o.default = "https://cdn.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt" o.description = translate("Customize Netflix IP Url") +o = s:option(Button, "reset", translate("Reset to defaults")) +o.rawhtml = true +o.template = "shadowsocksr/reset" + -- [[ SOCKS5 Proxy ]]-- s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server")) s.anonymous = true @@ -80,7 +84,9 @@ s.anonymous = true o = s:option(ListValue, "server", translate("Server")) o:value("nil", translate("Disable")) o:value("same", translate("Same as Global Server")) -for _,key in pairs(key_table) do o:value(key,server_table[key]) end +for _, key in pairs(key_table) do + o:value(key, server_table[key]) +end o.default = "nil" o.rmempty = false diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua index 73d5a52f..39c609ac 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua @@ -1,118 +1,121 @@ -- Copyright (C) 2017 yushi studio github.com/ywb94 -- Licensed to the public under the GNU General Public License v3. - require "nixio.fs" require "luci.sys" require "luci.http" local m, s, o, kcp_enable -local shadowsocksr = "shadowsocksr" local sid = arg[1] local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid") local function isKcptun(file) -if not nixio.fs.access(file, "rwx", "rx", "rx") then -nixio.fs.chmod(file, 755) -end -local str = luci.sys.exec(file .. " -v | awk '{printf $1}'") -return (str:lower() == "kcptun") + if not nixio.fs.access(file, "rwx", "rx", "rx") then + nixio.fs.chmod(file, 755) + end + local str = luci.sys.exec(file .. " -v | awk '{printf $1}'") + return (str:lower() == "kcptun") end local server_table = {} local encrypt_methods = { -"none", -"table", -"rc4", -"rc4-md5-6", -"rc4-md5", -"aes-128-cfb", -"aes-192-cfb", -"aes-256-cfb", -"aes-128-ctr", -"aes-192-ctr", -"aes-256-ctr", -"bf-cfb", -"camellia-128-cfb", -"camellia-192-cfb", -"camellia-256-cfb", -"cast5-cfb", -"des-cfb", -"idea-cfb", -"rc2-cfb", -"seed-cfb", -"salsa20", -"chacha20", -"chacha20-ietf", + -- ssr + "none", + "table", + "rc4", + "rc4-md5-6", + "rc4-md5", + "aes-128-cfb", + "aes-192-cfb", + "aes-256-cfb", + "aes-128-ctr", + "aes-192-ctr", + "aes-256-ctr", + "bf-cfb", + "camellia-128-cfb", + "camellia-192-cfb", + "camellia-256-cfb", + "cast5-cfb", + "des-cfb", + "idea-cfb", + "rc2-cfb", + "seed-cfb", + "salsa20", + "chacha20", + "chacha20-ietf" } local encrypt_methods_ss = { --- aead -"aes-128-gcm", -"aes-192-gcm", -"aes-256-gcm", -"chacha20-ietf-poly1305", -"xchacha20-ietf-poly1305", --- stream -"table", -"rc4", -"rc4-md5", -"aes-128-cfb", -"aes-192-cfb", -"aes-256-cfb", -"aes-128-ctr", -"aes-192-ctr", -"aes-256-ctr", -"bf-cfb", -"camellia-128-cfb", -"camellia-192-cfb", -"camellia-256-cfb", -"salsa20", -"chacha20", -"chacha20-ietf", + -- aead + "aes-128-gcm", + "aes-192-gcm", + "aes-256-gcm", + "chacha20-ietf-poly1305", + "xchacha20-ietf-poly1305", + -- stream + "table", + "rc4", + "rc4-md5", + "aes-128-cfb", + "aes-192-cfb", + "aes-256-cfb", + "aes-128-ctr", + "aes-192-ctr", + "aes-256-ctr", + "bf-cfb", + "camellia-128-cfb", + "camellia-192-cfb", + "camellia-256-cfb", + "salsa20", + "chacha20", + "chacha20-ietf" } local protocol = { -"origin", -"verify_deflate", -"auth_sha1_v4", -"auth_aes128_sha1", -"auth_aes128_md5", -"auth_chain_a", -"auth_chain_b", -"auth_chain_c", -"auth_chain_d", -"auth_chain_e", -"auth_chain_f", + -- ssr + "origin", + "verify_deflate", + "auth_sha1_v4", + "auth_aes128_sha1", + "auth_aes128_md5", + "auth_chain_a", + "auth_chain_b", + "auth_chain_c", + "auth_chain_d", + "auth_chain_e", + "auth_chain_f" } obfs = { -"plain", -"http_simple", -"http_post", -"random_head", -"tls1.2_ticket_auth", + -- ssr + "plain", + "http_simple", + "http_post", + "random_head", + "tls1.2_ticket_auth" } local securitys = { -"auto", -"none", -"aes-128-gcm", -"chacha20-poly1305" + -- vmess + "auto", + "none", + "aes-128-gcm", + "chacha20-poly1305" } local flows = { -"xtls-rprx-origin", -"xtls-rprx-origin-udp443", -"xtls-rprx-direct", -"xtls-rprx-direct-udp443", -"xtls-rprx-splice", -"xtls-rprx-splice-udp443" + -- xlts + "xtls-rprx-origin", + "xtls-rprx-origin-udp443", + "xtls-rprx-direct", + "xtls-rprx-direct-udp443", + "xtls-rprx-splice", + "xtls-rprx-splice-udp443" } -m = Map(shadowsocksr, translate("Edit ShadowSocksR Server")) +m = Map("shadowsocksr", translate("Edit ShadowSocksR Server")) m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/servers") -if m.uci:get(shadowsocksr, sid) ~= "servers" then -luci.http.redirect(m.redirect) -return +if m.uci:get("shadowsocksr", sid) ~= "servers" then + luci.http.redirect(m.redirect) + return end -- [[ Servers Setting ]]-- @@ -126,30 +129,36 @@ o.template = "shadowsocksr/ssrurl" o.value = sid o = s:option(ListValue, "type", translate("Server Node Type")) -o:value("ssr", translate("ShadowsocksR")) -if nixio.fs.access("/usr/bin/ss-redir") then -o:value("ss", translate("Shadowsocks New Version")) +if nixio.fs.access("/usr/bin/ssr-redir") then + o:value("ssr", translate("ShadowsocksR")) end -if nixio.fs.access("/usr/bin/xray") or nixio.fs.access("/usr/bin/xray/xray") or nixio.fs.access("/usr/bin/v2ray/v2ray") or nixio.fs.access("/usr/bin/v2ray") then -o:value("vmess", translate("Vmess")) -o:value("vless", translate("VLESS")) +if nixio.fs.access("/usr/bin/ss-redir") then + o:value("ss", translate("Shadowsocks New Version")) +end +if nixio.fs.access("/usr/bin/xray") or nixio.fs.access("/usr/bin/v2ray") then + o:value("vmess", translate("Vmess")) + o:value("vless", translate("VLESS")) end if nixio.fs.access("/usr/sbin/trojan") then -o:value("trojan", translate("Trojan")) + o:value("trojan", translate("Trojan")) end if nixio.fs.access("/usr/bin/naive") then -o:value("naiveproxy", translate("NaiveProxy")) + o:value("naiveproxy", translate("NaiveProxy")) end if nixio.fs.access("/usr/sbin/redsocks2") then -o:value("socks5", translate("Socks5")) -o:value("tun", translate("Network Tunnel")) + o:value("socks5", translate("Socks5")) + o:value("tun", translate("Network Tunnel")) end o.description = translate("Using incorrect encryption mothod may causes service fail to start") o = s:option(Value, "alias", translate("Alias(optional)")) o = s:option(ListValue, "iface", translate("Network interface to use")) -for _, e in ipairs(luci.sys.net.devices()) do if e ~= "lo" then o:value(e) end end +for _, e in ipairs(luci.sys.net.devices()) do + if e ~= "lo" then + o:value(e) + end +end o:depends("type", "tun") o.description = translate("Redirect traffic to this network interface") @@ -195,26 +204,54 @@ o:depends("type", "naiveproxy") o:depends({type = "socks5", auth_enable = true}) o = s:option(ListValue, "encrypt_method", translate("Encrypt Method")) -for _, v in ipairs(encrypt_methods) do o:value(v) end +for _, v in ipairs(encrypt_methods) do + o:value(v) +end o.rmempty = true o:depends("type", "ssr") o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method")) -for _, v in ipairs(encrypt_methods_ss) do o:value(v) end +for _, v in ipairs(encrypt_methods_ss) do + o:value(v) +end o.rmempty = true o:depends("type", "ss") -- Shadowsocks Plugin -o = s:option(Value, "plugin", translate("Plugin")) +o = s:option(ListValue, "plugin", translate("Obfs")) +o:value("", translate("None")) +if nixio.fs.access("/usr/bin/obfs-local") then + o:value("obfs-local", translate("simple-obfs")) +end +if nixio.fs.access("/usr/bin/v2ray-plugin") then + o:value("v2ray-plugin", translate("v2ray-plugin")) +end o.rmempty = true o:depends("type", "ss") -o = s:option(Value, "plugin_opts", translate("Plugin Opts")) +o = s:option(ListValue, "simple_obfs", translate("Plugin Opts")) +o:value("obfs=tls;obfs-host=", translate("TLS")) +o:value("obfs=http;obfs-host=", translate("HTTP")) +o:depends("plugin", "obfs-local") o.rmempty = true -o:depends("type", "ss") + +o = s:option(ListValue, "v2ray_plugin", translate("Plugin Opts")) +o:value("tls;host=", translate("TLS")) +o:value("mode=quic;host=", translate("QUIC")) +o:value("none", translate("HTTP")) +o:depends("plugin", "v2ray-plugin") +o.rmempty = true + +o = s:option(Value, "plugin_opts", translate("Plugin Opts"), translate("Please fill in the Host, for example: www.baidu.com")) +o.rmempty = true +o:depends({type = "ss", plugin = "obfs-local"}) +o:depends({type = "ss", v2ray_plugin = "tls;host="}) +o:depends({type = "ss", v2ray_plugin = "mode=quic;host="}) o = s:option(ListValue, "protocol", translate("Protocol")) -for _, v in ipairs(protocol) do o:value(v) end +for _, v in ipairs(protocol) do + o:value(v) +end o.rmempty = true o:depends("type", "ssr") @@ -222,7 +259,9 @@ o = s:option(Value, "protocol_param", translate("Protocol param(optional)")) o:depends("type", "ssr") o = s:option(ListValue, "obfs", translate("Obfs")) -for _, v in ipairs(obfs) do o:value(v) end +for _, v in ipairs(obfs) do + o:value(v) +end o.rmempty = true o:depends("type", "ssr") @@ -251,7 +290,9 @@ o:depends("type", "vless") -- 加密方式 o = s:option(ListValue, "security", translate("Encrypt Method")) -for _, v in ipairs(securitys) do o:value(v, v:upper()) end +for _, v in ipairs(securitys) do + o:value(v, v:upper()) +end o.rmempty = true o:depends("type", "vmess") @@ -267,7 +308,6 @@ o:depends("type", "vmess") o:depends("type", "vless") -- [[ TCP部分 ]]-- - -- TCP伪装 o = s:option(ListValue, "tcp_guise", translate("Camouflage Type")) o:depends("transport", "tcp") @@ -286,7 +326,6 @@ o:depends("tcp_guise", "http") o.rmempty = true -- [[ WS部分 ]]-- - -- WS域名 o = s:option(Value, "ws_host", translate("WebSocket Host")) o:depends({transport = "ws", tls = false}) @@ -310,7 +349,6 @@ o:depends("transport", "h2") o.rmempty = true -- [[ QUIC部分 ]]-- - o = s:option(ListValue, "quic_security", translate("QUIC Security")) o:depends("transport", "quic") o:value("none", translate("None")) @@ -329,19 +367,18 @@ o:value("none", translate("None")) o:value("srtp", translate("VideoCall (SRTP)")) o:value("utp", translate("BitTorrent (uTP)")) o:value("wechat-video", translate("WechatVideo")) -o:value("dtls", "DTLS 1.2") -o:value("wireguard", "WireGuard") +o:value("dtls", translate("DTLS 1.2")) +o:value("wireguard", translate("WireGuard")) -- [[ mKCP部分 ]]-- - o = s:option(ListValue, "kcp_guise", translate("Camouflage Type")) o:depends("transport", "kcp") o:value("none", translate("None")) o:value("srtp", translate("VideoCall (SRTP)")) o:value("utp", translate("BitTorrent (uTP)")) o:value("wechat-video", translate("WechatVideo")) -o:value("dtls", "DTLS 1.2") -o:value("wireguard", "WireGuard") +o:value("dtls", translate("DTLS 1.2")) +o:value("wireguard", translate("WireGuard")) o.rmempty = true o = s:option(Value, "mtu", translate("MTU")) @@ -397,16 +434,18 @@ o:depends({type = "vless", xtls = false}) o:depends("type", "trojan") -- XTLS -if nixio.fs.access("/usr/bin/xray") or nixio.fs.access("/usr/bin/xray/xray") then -o = s:option(Flag, "xtls", translate("XTLS")) -o.rmempty = true -o.default = "0" -o:depends({type = "vless", transport = "tcp", tls = false}) +if nixio.fs.access("/usr/bin/xray") then + o = s:option(Flag, "xtls", translate("XTLS")) + o.rmempty = true + o.default = "0" + o:depends({type = "vless", transport = "tcp", tls = false}) end -- Flow o = s:option(Value, "vless_flow", translate("Flow")) -for _, v in ipairs(flows) do o:value(v, v) end +for _, v in ipairs(flows) do + o:value(v, v) +end o.rmempty = true o.default = "xtls-rprx-splice" o:depends("xtls", true) @@ -453,24 +492,30 @@ cert_dir = "/etc/ssl/private/" local path luci.http.setfilehandler(function(meta, chunk, eof) -if not fd then -if (not meta) or (not meta.name) or (not meta.file) then return end -fd = nixio.open(cert_dir .. meta.file, "w") -if not fd then -path = translate("Create upload file error.") -return -end -end -if chunk and fd then fd:write(chunk) end -if eof and fd then -fd:close() -fd = nil -path = '/etc/ssl/private/' .. meta.file .. '' -end + if not fd then + if (not meta) or (not meta.name) or (not meta.file) then + return + end + fd = nixio.open(cert_dir .. meta.file, "w") + if not fd then + path = translate("Create upload file error.") + return + end + end + if chunk and fd then + fd:write(chunk) + end + if eof and fd then + fd:close() + fd = nil + path = '/etc/ssl/private/' .. meta.file .. '' + end end) if luci.http.formvalue("upload") then -local f = luci.http.formvalue("ulfile") -if #f <= 0 then path = translate("No specify upload file.") end + local f = luci.http.formvalue("ulfile") + if #f <= 0 then + path = translate("No specify upload file.") + end end o = s:option(Value, "certpath", translate("Current Certificate Path")) @@ -496,40 +541,40 @@ o.default = 1234 o.rmempty = false if nixio.fs.access("/usr/bin/kcptun-client") then -kcp_enable = s:option(Flag, "kcp_enable", translate("KcpTun Enable"), translate("bin:/usr/bin/kcptun-client")) -kcp_enable.rmempty = true -kcp_enable.default = "0" -kcp_enable:depends("type", "ssr") -kcp_enable:depends("type", "ss") + kcp_enable = s:option(Flag, "kcp_enable", translate("KcpTun Enable"), translate("bin:/usr/bin/kcptun-client")) + kcp_enable.rmempty = true + kcp_enable.default = "0" + kcp_enable:depends("type", "ssr") + kcp_enable:depends("type", "ss") -o = s:option(Value, "kcp_port", translate("KcpTun Port")) -o.datatype = "port" -o.default = 4000 -function o.validate(self, value, section) -local kcp_file = "/usr/bin/kcptun-client" -local enable = kcp_enable:formvalue(section) or kcp_enable.disabled -if enable == kcp_enable.enabled then -if not nixio.fs.access(kcp_file) then -return nil, translate("Haven't a Kcptun executable file") -elseif not isKcptun(kcp_file) then -return nil, translate("Not a Kcptun executable file") -end -end + o = s:option(Value, "kcp_port", translate("KcpTun Port")) + o.datatype = "port" + o.default = 4000 + function o.validate(self, value, section) + local kcp_file = "/usr/bin/kcptun-client" + local enable = kcp_enable:formvalue(section) or kcp_enable.disabled + if enable == kcp_enable.enabled then + if not nixio.fs.access(kcp_file) then + return nil, translate("Haven't a Kcptun executable file") + elseif not isKcptun(kcp_file) then + return nil, translate("Not a Kcptun executable file") + end + end -return value -end -o:depends("type", "ssr") -o:depends("type", "ss") + return value + end + o:depends("type", "ssr") + o:depends("type", "ss") -o = s:option(Value, "kcp_password", translate("KcpTun Password")) -o.password = true -o:depends("type", "ssr") -o:depends("type", "ss") + o = s:option(Value, "kcp_password", translate("KcpTun Password")) + o.password = true + o:depends("type", "ssr") + o:depends("type", "ss") -o = s:option(Value, "kcp_param", translate("KcpTun Param")) -o.default = "--nocomp" -o:depends("type", "ssr") -o:depends("type", "ss") + o = s:option(Value, "kcp_param", translate("KcpTun Param")) + o.default = "--nocomp" + o:depends("type", "ssr") + o:depends("type", "ss") end return m diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua index b2e67608..eb7831e2 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua @@ -1,27 +1,24 @@ -- Copyright (C) 2017 yushi studio github.com/ywb94 -- Copyright (C) 2018 lean github.com/coolsnowwolf -- Licensed to the public under the GNU General Public License v3. - local m, s, sec, o, kcp_enable -local shadowsocksr = "shadowsocksr" local uci = luci.model.uci.cursor() -m = Map(shadowsocksr, translate("ShadowSocksR Plus+ Settings"), - translate("

Support SS/SSR/V2RAY/TROJAN/NAIVEPROXY/SOCKS5/TUN etc.

")) +m = Map("shadowsocksr", translate("ShadowSocksR Plus+ Settings"), translate("

Support SS/SSR/V2RAY/TROJAN/NAIVEPROXY/SOCKS5/TUN etc.

")) m:section(SimpleSection).template = "shadowsocksr/status" local server_table = {} -uci:foreach(shadowsocksr, "servers", function(s) +uci:foreach("shadowsocksr", "servers", function(s) if s.alias then - server_table[s[".name"]] = "[%s]:%s" %{string.upper(s.type), s.alias} + server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.type), s.alias} elseif s.server and s.server_port then - server_table[s[".name"]] = "[%s]:%s:%s" %{string.upper(s.type), s.server, s.server_port} + server_table[s[".name"]] = "[%s]:%s:%s" % {string.upper(s.type), s.server, s.server_port} end end) local key_table = {} -for key,_ in pairs(server_table) do - table.insert(key_table,key) +for key, _ in pairs(server_table) do + table.insert(key_table, key) end table.sort(key_table) @@ -32,26 +29,32 @@ s.anonymous = true o = s:option(ListValue, "global_server", translate("Main Server")) o:value("nil", translate("Disable")) -for _,key in pairs(key_table) do o:value(key,server_table[key]) end +for _, key in pairs(key_table) do + o:value(key, server_table[key]) +end o.default = "nil" o.rmempty = false o = s:option(ListValue, "udp_relay_server", translate("Game Mode UDP Server")) o:value("", translate("Disable")) o:value("same", translate("Same as Global Server")) -for _,key in pairs(key_table) do o:value(key,server_table[key]) end +for _, key in pairs(key_table) do + o:value(key, server_table[key]) +end o = s:option(ListValue, "netflix_server", translate("Netflix Node")) o:value("nil", translate("Disable")) o:value("same", translate("Same as Global Server")) -for _,key in pairs(key_table) do o:value(key,server_table[key]) end +for _, key in pairs(key_table) do + o:value(key, server_table[key]) +end o.default = "nil" o.rmempty = false o = s:option(Flag, "netflix_proxy", translate("External Proxy Mode")) o.rmempty = false o.description = translate("Forward Netflix Proxy through Main Proxy") -o.default="0" +o.default = "0" o = s:option(ListValue, "threads", translate("Multi Threads Option")) o:value("0", translate("Auto Threads")) diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua index 22443d08..fca98cc6 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua @@ -36,7 +36,7 @@ o.rmempty = false o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Host List")) o.datatype = "ipaddr" -luci.ip.neighbors({ family = 4 }, function(entry) +luci.ip.neighbors({family = 4}, function(entry) if entry.reachable then o:value(entry.dest:string()) end @@ -46,7 +46,7 @@ o:depends("lan_ac_mode", "b") o = s:taboption("lan_ac", DynamicList, "lan_bp_ips", translate("LAN Bypassed Host List")) o.datatype = "ipaddr" -luci.ip.neighbors({ family = 4 }, function(entry) +luci.ip.neighbors({family = 4}, function(entry) if entry.reachable then o:value(entry.dest:string()) end @@ -54,7 +54,7 @@ end) o = s:taboption("lan_ac", DynamicList, "lan_fp_ips", translate("LAN Force Proxy Host List")) o.datatype = "ipaddr" -luci.ip.neighbors({ family = 4 }, function(entry) +luci.ip.neighbors({family = 4}, function(entry) if entry.reachable then o:value(entry.dest:string()) end @@ -62,7 +62,7 @@ end) o = s:taboption("lan_ac", DynamicList, "lan_gm_ips", translate("Game Mode Host List")) o.datatype = "ipaddr" -luci.ip.neighbors({ family = 4 }, function(entry) +luci.ip.neighbors({family = 4}, function(entry) if entry.reachable then o:value(entry.dest:string()) end @@ -77,7 +77,7 @@ end) -- o.rmempty = false s:tab("esc", translate("Bypass Domain List")) -local escconf = "/etc/ssr/white.list" +local escconf = "/etc/ssrplus/white.list" o = s:taboption("esc", TextValue, "escconf") o.rows = 13 o.wrap = "off" @@ -93,7 +93,7 @@ o.remove = function(self, section, value) end s:tab("block", translate("Black Domain List")) -local blockconf = "/etc/ssr/black.list" +local blockconf = "/etc/ssrplus/black.list" o = s:taboption("block", TextValue, "blockconf") o.rows = 13 o.wrap = "off" @@ -109,7 +109,7 @@ o.remove = function(self, section, value) end s:tab("denydomain", translate("Deny Domain List")) -local denydomainconf = "/etc/ssr/deny.list" +local denydomainconf = "/etc/ssrplus/deny.list" o = s:taboption("denydomain", TextValue, "denydomainconf") o.rows = 13 o.wrap = "off" @@ -125,7 +125,7 @@ o.remove = function(self, section, value) end s:tab("netflix", translate("Netflix Domain List")) -local netflixconf = "/etc/ssr/netflix.list" +local netflixconf = "/etc/ssrplus/netflix.list" o = s:taboption("netflix", TextValue, "netflixconf") o.rows = 13 o.wrap = "off" diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua index a71d0003..fdf9e59f 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua @@ -7,8 +7,8 @@ t = f:field(TextValue, "conf") t.rmempty = true t.rows = 20 function t.cfgvalue() - if nixio.fs.access("/tmp/ssrplus.log") then - local logs = luci.util.execi("cat /tmp/ssrplus.log") + if nixio.fs.access("/var/log/ssrplus.log") then + local logs = luci.util.execi("cat /var/log/ssrplus.log") local s = "" for line in logs do s = line .. "\n" .. s @@ -16,5 +16,5 @@ function t.cfgvalue() return s end end -t.readonly="readonly" +t.readonly = "readonly" return f diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua index 3361f7c3..1fe01f51 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua @@ -5,48 +5,41 @@ require "luci.dispatcher" require "nixio.fs" local m, s, o -local shadowsocksr = "shadowsocksr" local sid = arg[1] local encrypt_methods = { -"rc4-md5", -"rc4-md5-6", -"rc4", -"table", -"aes-128-cfb", -"aes-192-cfb", -"aes-256-cfb", -"aes-128-ctr", -"aes-192-ctr", -"aes-256-ctr", -"bf-cfb", -"camellia-128-cfb", -"camellia-192-cfb", -"camellia-256-cfb", -"cast5-cfb", -"des-cfb", -"idea-cfb", -"rc2-cfb", -"seed-cfb", -"salsa20", -"chacha20", -"chacha20-ietf", + "rc4-md5", + "rc4-md5-6", + "rc4", + "table", + "aes-128-cfb", + "aes-192-cfb", + "aes-256-cfb", + "aes-128-ctr", + "aes-192-ctr", + "aes-256-ctr", + "bf-cfb", + "camellia-128-cfb", + "camellia-192-cfb", + "camellia-256-cfb", + "cast5-cfb", + "des-cfb", + "idea-cfb", + "rc2-cfb", + "seed-cfb", + "salsa20", + "chacha20", + "chacha20-ietf" } -local protocol = { -"origin", -} +local protocol = {"origin"} -obfs = { -"plain", -"http_simple", -"http_post", -} +obfs = {"plain", "http_simple", "http_post"} -m = Map(shadowsocksr, translate("Edit ShadowSocksR Server")) +m = Map("shadowsocksr", translate("Edit ShadowSocksR Server")) m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/server") -if m.uci:get(shadowsocksr, sid) ~= "server_config" then +if m.uci:get("shadowsocksr", sid) ~= "server_config" then luci.http.redirect(m.redirect) return end @@ -70,7 +63,7 @@ o.default = "socks5" o = s:option(Value, "server_port", translate("Server Port")) o.datatype = "port" math.randomseed(tostring(os.time()):reverse():sub(1, 7)) -o.default = math.random(10240,20480) +o.default = math.random(10240, 20480) o.rmempty = false o.description = translate("warning! Please do not reuse the port!") @@ -89,17 +82,23 @@ o.password = true o.rmempty = false o = s:option(ListValue, "encrypt_method", translate("Encrypt Method")) -for _, v in ipairs(encrypt_methods) do o:value(v) end +for _, v in ipairs(encrypt_methods) do + o:value(v) +end o.rmempty = false o:depends("type", "ssr") o = s:option(ListValue, "protocol", translate("Protocol")) -for _, v in ipairs(protocol) do o:value(v) end +for _, v in ipairs(protocol) do + o:value(v) +end o.rmempty = false o:depends("type", "ssr") o = s:option(ListValue, "obfs", translate("Obfs")) -for _, v in ipairs(obfs) do o:value(v) end +for _, v in ipairs(obfs) do + o:value(v) +end o.rmempty = false o:depends("type", "ssr") diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua index a41163e1..d8c3565d 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua @@ -3,51 +3,50 @@ require "luci.http" require "luci.dispatcher" local m, sec, o -local shadowsocksr = "shadowsocksr" local encrypt_methods = { -"table", -"rc4", -"rc4-md5", -"rc4-md5-6", -"aes-128-cfb", -"aes-192-cfb", -"aes-256-cfb", -"aes-128-ctr", -"aes-192-ctr", -"aes-256-ctr", -"bf-cfb", -"camellia-128-cfb", -"camellia-192-cfb", -"camellia-256-cfb", -"cast5-cfb", -"des-cfb", -"idea-cfb", -"rc2-cfb", -"seed-cfb", -"salsa20", -"chacha20", -"chacha20-ietf", + "table", + "rc4", + "rc4-md5", + "rc4-md5-6", + "aes-128-cfb", + "aes-192-cfb", + "aes-256-cfb", + "aes-128-ctr", + "aes-192-ctr", + "aes-256-ctr", + "bf-cfb", + "camellia-128-cfb", + "camellia-192-cfb", + "camellia-256-cfb", + "cast5-cfb", + "des-cfb", + "idea-cfb", + "rc2-cfb", + "seed-cfb", + "salsa20", + "chacha20", + "chacha20-ietf" } local protocol = { -"origin", -"verify_deflate", -"auth_sha1_v4", -"auth_aes128_sha1", -"auth_aes128_md5", -"auth_chain_a", + "origin", + "verify_deflate", + "auth_sha1_v4", + "auth_aes128_sha1", + "auth_aes128_md5", + "auth_chain_a" } obfs = { -"plain", -"http_simple", -"http_post", -"random_head", -"tls1.2_ticket_auth", -"tls1.2_ticket_fastauth", + "plain", + "http_simple", + "http_post", + "random_head", + "tls1.2_ticket_auth", + "tls1.2_ticket_fastauth" } -m = Map(shadowsocksr) +m = Map("shadowsocksr") -- [[ Global Setting ]]-- sec = m:section(TypedSection, "server_global", translate("Global Setting")) sec.anonymous = true diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua index 28b3b9fc..f7cad174 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua @@ -3,17 +3,15 @@ require "luci.http" require "luci.dispatcher" require "luci.model.uci" local m, s, o -local shadowsocksr = "shadowsocksr" local uci = luci.model.uci.cursor() local server_count = 0 uci:foreach("shadowsocksr", "servers", function(s) server_count = server_count + 1 end) -m = Map(shadowsocksr, translate("Servers subscription and manage")) +m = Map("shadowsocksr", translate("Servers subscription and manage")) -- Server Subscribe - s = m:section(TypedSection, "server_subscribe") s.anonymous = true @@ -21,12 +19,11 @@ o = s:option(Flag, "auto_update", translate("Auto Update")) o.rmempty = false o.description = translate("Auto Update Server subscription, GFW list and CHN route") - o = s:option(ListValue, "auto_update_time", translate("Update time (every day)")) -for t = 0,23 do - o:value(t, t..":00") +for t = 0, 23 do + o:value(t, t .. ":00") end -o.default=2 +o.default = 2 o.rmempty = false o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL")) @@ -36,28 +33,28 @@ o = s:option(Value, "filter_words", translate("Subscribe Filter Words")) o.rmempty = true o.description = translate("Filter Words splited by /") -o = s:option(Button,"update_Sub",translate("Update Subscribe List")) +o = s:option(Button, "update_Sub", translate("Update Subscribe List")) o.inputstyle = "reload" o.description = translate("Update subscribe url list first") o.write = function() + uci:commit("shadowsocksr") luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) end o = s:option(Flag, "switch", translate("Subscribe Default Auto-Switch")) o.rmempty = false o.description = translate("Subscribe new add server default Auto-Switch on") -o.default="1" +o.default = "1" o = s:option(Flag, "proxy", translate("Through proxy update")) o.rmempty = false o.description = translate("Through proxy update list, Not Recommended ") - -o = s:option(Button,"subscribe", translate("Update All Subscribe Severs")) +o = s:option(Button, "subscribe", translate("Update All Subscribe Severs")) o.rawhtml = true o.template = "shadowsocksr/subscribe" -o = s:option(Button,"delete",translate("Delete All Subscribe Severs")) +o = s:option(Button, "delete", translate("Delete All Subscribe Severs")) o.inputstyle = "reset" o.description = string.format(translate("Server Count") .. ": %d", server_count) o.write = function() @@ -69,9 +66,7 @@ o.write = function() end end) uci:save("shadowsocksr") - uci:commit("shadowsocksr") - luci.sys.exec("/etc/init.d/shadowsocksr restart &") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) + m.uci:commit("shadowsocksr") return end @@ -106,21 +101,19 @@ function o.cfgvalue(...) end o = s:option(DummyValue, "server_port", translate("Socket Connected")) -o.template="shadowsocksr/socket" -o.width="10%" +o.template = "shadowsocksr/socket" +o.width = "10%" o = s:option(DummyValue, "server", translate("Ping Latency")) -o.template="shadowsocksr/ping" -o.width="10%" +o.template = "shadowsocksr/ping" +o.width = "10%" -node = s:option(Button,"apply_node",translate("Apply")) +node = s:option(Button, "apply_node", translate("Apply")) node.inputstyle = "apply" node.write = function(self, section) uci:set("shadowsocksr", '@global[0]', 'global_server', section) uci:save("shadowsocksr") - uci:commit("shadowsocksr") - luci.sys.exec("/etc/init.d/shadowsocksr restart &") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "client")) + m.uci:commit("shadowsocksr") end o = s:option(Flag, "switch_enable", translate("Auto Switch")) diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua index c12fd5e2..1b99e546 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua @@ -4,177 +4,184 @@ require "nixio.fs" require "luci.sys" require "luci.model.uci" local m, s, o -local redir_run=0 -local reudp_run=0 -local sock5_run=0 -local server_run=0 -local kcptun_run=0 -local tunnel_run=0 -local gfw_count=0 -local ad_count=0 -local ip_count=0 -local nfip_count=0 +local redir_run = 0 +local reudp_run = 0 +local sock5_run = 0 +local server_run = 0 +local kcptun_run = 0 +local tunnel_run = 0 +local gfw_count = 0 +local ad_count = 0 +local ip_count = 0 +local nfip_count = 0 +local Process_list = luci.sys.exec("busybox ps -w") local uci = luci.model.uci.cursor() -local shadowsocksr = "shadowsocksr" -- html constants font_blue = [[]] font_off = [[]] bold_on = [[]] bold_off = [[]] -local kcptun_version=translate("Unknown") -local kcp_file="/usr/bin/kcptun-client" +local kcptun_version = translate("Unknown") +local kcp_file = "/usr/bin/kcptun-client" if not nixio.fs.access(kcp_file) then - kcptun_version=translate("Not exist") + kcptun_version = translate("Not exist") else if not nixio.fs.access(kcp_file, "rwx", "rx", "rx") then nixio.fs.chmod(kcp_file, 755) end - kcptun_version=luci.sys.exec(kcp_file .. " -v | awk '{printf $3}'") + kcptun_version = luci.sys.exec(kcp_file .. " -v | awk '{printf $3}'") if not kcptun_version or kcptun_version == "" then kcptun_version = translate("Unknown") end end -if nixio.fs.access("/etc/ssr/gfw_list.conf") then - gfw_count = tonumber(luci.sys.exec("cat /etc/ssr/gfw_list.conf | wc -l"))/2 +if nixio.fs.access("/etc/ssrplus/gfw_list.conf") then + gfw_count = tonumber(luci.sys.exec("cat /etc/ssrplus/gfw_list.conf | wc -l")) / 2 end -if nixio.fs.access("/etc/ssr/ad.conf") then - ad_count = tonumber(luci.sys.exec("cat /etc/ssr/ad.conf | wc -l")) +if nixio.fs.access("/etc/ssrplus/ad.conf") then + ad_count = tonumber(luci.sys.exec("cat /etc/ssrplus/ad.conf | wc -l")) end -if nixio.fs.access("/etc/ssr/china_ssr.txt") then - ip_count = tonumber(luci.sys.exec("cat /etc/ssr/china_ssr.txt | wc -l")) +if nixio.fs.access("/etc/ssrplus/china_ssr.txt") then + ip_count = tonumber(luci.sys.exec("cat /etc/ssrplus/china_ssr.txt | wc -l")) end -if nixio.fs.access("/etc/ssr/netflixip.list") then - nfip_count = tonumber(luci.sys.exec("cat /etc/ssr/netflixip.list | wc -l")) +if nixio.fs.access("/etc/ssrplus/netflixip.list") then + nfip_count = tonumber(luci.sys.exec("cat /etc/ssrplus/netflixip.list | wc -l")) end -local icount=luci.sys.exec("busybox ps -w | grep ssr-reudp |grep -v grep| wc -l") -if tonumber(icount)>0 then - reudp_run=1 -else - icount=luci.sys.exec("busybox ps -w | grep ssr-retcp |grep \"\\-u\"|grep -v grep| wc -l") - if tonumber(icount)>0 then - reudp_run=1 - end +if Process_list:find("udp.only.ssr.reudp") then + reudp_run = 1 end -if luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null") == 0 then - redir_run=1 +if Process_list:find("tcp.only.ssr.retcp") then + redir_run = 1 end -if luci.sys.call("busybox ps -w | grep ssr-local | grep -v ssr-socksdns |grep -v grep >/dev/null") == 0 then - sock5_run=1 +if Process_list:find("tcp.udp.ssr.local") then + sock5_run = 1 end -if luci.sys.call("pidof kcptun-client >/dev/null") == 0 then - kcptun_run=1 +if Process_list:find("tcp.udp.ssr.retcp") then + redir_run = 1 + reudp_run = 1 end -if luci.sys.call("busybox ps -w | grep ssr-server | grep -v grep >/dev/null") == 0 then - server_run=1 +if Process_list:find("local.ssr.retcp") then + redir_run = 1 + sock5_run = 1 end --- if luci.sys.call("busybox ps -w | grep ssr-tunnel |grep -v grep >/dev/null") == 0 then --- tunnel_run=1 --- end -if luci.sys.call("pidof pdnsd >/dev/null") == 0 or (luci.sys.call("busybox ps -w | grep ssr-dns |grep -v grep >/dev/null") == 0 and luci.sys.call("pidof dns2socks >/dev/null") == 0)then - pdnsd_run=1 +if Process_list:find("local.udp.ssr.retcp") then + reudp_run = 1 + redir_run = 1 + sock5_run = 1 +end + +if Process_list:find("kcptun.client") then + kcptun_run = 1 +end + +if Process_list:find("ssr.server") then + server_run = 1 +end + +if Process_list:find("ssrplus/bin/pdnsd") or (Process_list:find("ssrplus.dns") and Process_list:find("dns2socks 127.0.0.1:.*127.0.0.1:5335")) then + pdnsd_run = 1 end m = SimpleForm("Version") m.reset = false m.submit = false -s=m:field(DummyValue,"redir_run",translate("Global Client")) +s = m:field(DummyValue, "redir_run", translate("Global Client")) s.rawhtml = true if redir_run == 1 then - s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off + s.value = font_blue .. bold_on .. translate("Running") .. bold_off .. font_off else s.value = translate("Not Running") end -s=m:field(DummyValue,"reudp_run",translate("Game Mode UDP Relay")) +s = m:field(DummyValue, "reudp_run", translate("Game Mode UDP Relay")) s.rawhtml = true if reudp_run == 1 then - s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off + s.value = font_blue .. bold_on .. translate("Running") .. bold_off .. font_off else s.value = translate("Not Running") end -if uci:get_first(shadowsocksr, 'global', 'pdnsd_enable', '0') ~= '0' then - s=m:field(DummyValue,"pdnsd_run",translate("DNS Anti-pollution")) +if uci:get_first("shadowsocksr", 'global', 'pdnsd_enable', '0') ~= '0' then + s = m:field(DummyValue, "pdnsd_run", translate("DNS Anti-pollution")) s.rawhtml = true if pdnsd_run == 1 then - s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off + s.value = font_blue .. bold_on .. translate("Running") .. bold_off .. font_off else s.value = translate("Not Running") end end -s=m:field(DummyValue,"sock5_run",translate("Global SOCKS5 Proxy Server")) +s = m:field(DummyValue, "sock5_run", translate("Global SOCKS5 Proxy Server")) s.rawhtml = true if sock5_run == 1 then - s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off + s.value = font_blue .. bold_on .. translate("Running") .. bold_off .. font_off else s.value = translate("Not Running") end -s=m:field(DummyValue,"server_run",translate("Local Servers")) +s = m:field(DummyValue, "server_run", translate("Local Servers")) s.rawhtml = true if server_run == 1 then - s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off + s.value = font_blue .. bold_on .. translate("Running") .. bold_off .. font_off else s.value = translate("Not Running") end if nixio.fs.access("/usr/bin/kcptun-client") then - s=m:field(DummyValue,"kcp_version",translate("KcpTun Version")) + s = m:field(DummyValue, "kcp_version", translate("KcpTun Version")) s.rawhtml = true - s.value =kcptun_version - s=m:field(DummyValue,"kcptun_run",translate("KcpTun")) + s.value = kcptun_version + s = m:field(DummyValue, "kcptun_run", translate("KcpTun")) s.rawhtml = true if kcptun_run == 1 then - s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off + s.value = font_blue .. bold_on .. translate("Running") .. bold_off .. font_off else s.value = translate("Not Running") end end -s=m:field(DummyValue,"google",translate("Google Connectivity")) +s = m:field(DummyValue, "google", translate("Google Connectivity")) s.value = translate("No Check") s.template = "shadowsocksr/check" -s=m:field(DummyValue,"baidu",translate("Baidu Connectivity")) +s = m:field(DummyValue, "baidu", translate("Baidu Connectivity")) s.value = translate("No Check") s.template = "shadowsocksr/check" -s=m:field(DummyValue,"gfw_data",translate("GFW List Data")) +s = m:field(DummyValue, "gfw_data", translate("GFW List Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" s.value = gfw_count .. " " .. translate("Records") -s=m:field(DummyValue,"ip_data",translate("China IP Data")) +s = m:field(DummyValue, "ip_data", translate("China IP Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" s.value = ip_count .. " " .. translate("Records") -s=m:field(DummyValue,"nfip_data",translate("Netflix IP Data")) +s = m:field(DummyValue, "nfip_data", translate("Netflix IP Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" s.value = nfip_count .. " " .. translate("Records") -if uci:get_first(shadowsocksr, 'global', 'adblock', '0') == '1' then - s=m:field(DummyValue,"ad_data",translate("Advertising Data")) +if uci:get_first("shadowsocksr", 'global', 'adblock', '0') == '1' then + s = m:field(DummyValue, "ad_data", translate("Advertising Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" s.value = ad_count .. " " .. translate("Records") end -s=m:field(DummyValue,"check_port",translate("Check Server Port")) +s = m:field(DummyValue, "check_port", translate("Check Server Port")) s.template = "shadowsocksr/checkport" -s.value =translate("No Check") +s.value = translate("No Check") return m diff --git a/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm b/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm index c75056a8..7383a589 100644 --- a/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm @@ -26,5 +26,4 @@ //]]> <%=self.value%> - <%+cbi/valuefooter%> diff --git a/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm b/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm index ed91a2f2..71381488 100644 --- a/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm @@ -1,7 +1,5 @@ <%+cbi/valueheader%> - <%=self.value%> - - - -<%+cbi/valuefooter%> \ No newline at end of file +<%+cbi/valuefooter%> diff --git a/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm b/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm index 3e610d9e..3ce4e1f9 100644 --- a/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm @@ -12,16 +12,18 @@ var s = document.getElementById(dataname+'-status'); if (s) { - if (rv.ret=="0") - s.innerHTML =""+"<%:No new data!%> "+""; - else if(rv.ret=="-1") + if(rv.ret=="-1") { s.innerHTML =""+"<%:Refresh Error!%> "+""; } + if (rv.ret=="0") + { + s.innerHTML =""+"<%:No new data!%> "+""; + } else - { - s.innerHTML =""+"<%:Refresh OK!%> "+"<%:Total Records:%>"+rv.ret+""; - } + { + s.innerHTML =""+"<%:Refresh OK!%> "+"<%:Total Records:%>"+rv.ret+""; + } } btn.disabled = false; btn.value = '<%:Refresh Data %>'; diff --git a/luci-app-ssr-plus/luasrc/view/shadowsocksr/reset.htm b/luci-app-ssr-plus/luasrc/view/shadowsocksr/reset.htm new file mode 100644 index 00000000..15b3927b --- /dev/null +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/reset.htm @@ -0,0 +1,25 @@ +<%+cbi/valueheader%> + + + +<%+cbi/valuefooter%> diff --git a/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm b/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm index 9c5ba66a..047043b3 100644 --- a/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm @@ -2,9 +2,6 @@ Copyright 2018-2019 Lienol Licensed to the public under the Apache License 2.0. -%> -<% -local dsp = require "luci.dispatcher" --%>