From 276ce1aedc5a9c49caa83bf96a8f0f1600d2310d Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 7 Aug 2020 18:58:07 +0800 Subject: [PATCH] luci-app-passwall: bump to 3.9-31 --- package/lienol/luci-app-passwall/Makefile | 4 +- .../luasrc/model/cbi/passwall/api/api.lua | 8 + .../luasrc/model/cbi/passwall/global.lua | 30 +- .../luasrc/model/cbi/passwall/node_config.lua | 44 +- .../model/cbi/passwall/server/api/app.lua | 4 +- .../luasrc/model/cbi/passwall/server/user.lua | 30 +- .../luasrc/view/passwall/global/status.htm | 11 +- .../luasrc/view/passwall/global/status2.htm | 15 +- .../root/usr/share/passwall/app.sh | 512 +++++++++--------- 9 files changed, 322 insertions(+), 336 deletions(-) diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index d3eedc7121..0a3560566c 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=3.9 -PKG_RELEASE:=29 -PKG_DATE:=20200802 +PKG_RELEASE:=31 +PKG_DATE:=20200807 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua index 3ecc304853..6a44a4cf4b 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua @@ -43,6 +43,14 @@ function chmod_755(file) end end +function get_customed_path(e) + return uci_get_type("global_app", e .. "_file") +end + +function is_finded(e) + return luci.sys.exec('type -t -p "%s/%s" -p "/usr/bin/v2ray/%s" "%s"' % {get_customed_path(e), e, e, e}) ~= "" and true or false +end + function get_v2ray_path() local path = uci_get_type("global_app", "v2ray_file") return path .. "/v2ray" diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua index 22464db365..7fb2112806 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua @@ -1,18 +1,8 @@ local o = require "luci.dispatcher" -local sys = require "luci.sys" -local ipkg = require("luci.model.ipkg") local uci = require"luci.model.uci".cursor() -local _api = require "luci.model.cbi.passwall.api.api" +local api = require "luci.model.cbi.passwall.api.api" local appname = "passwall" -local function is_installed(e) return ipkg.installed(e) end - -local function is_finded(e) - return - sys.exec("find /usr/*bin -iname " .. e .. " -type f") ~= "" and true or - false -end - local nodes_table = {} uci:foreach(appname, "nodes", function(e) if e.type and e.remarks then @@ -127,20 +117,19 @@ o:value("210.2.4.8", "210.2.4.8 (CNNIC DNS)") o:value("180.76.76.76", "180.76.76.76 (" .. translate("Baidu") .. "DNS)") ---- DNS Forward Mode -o = s:taboption("DNS", ListValue, "dns_mode", translate("DNS Mode")) +o = s:taboption("DNS", Value, "dns_mode", translate("DNS Mode")) -- o.description = translate("if has problem, please try another mode.
if you use no patterns are used, DNS of wan will be used by default as upstream of dnsmasq.") o.rmempty = false o:reset_values() -if is_finded("chinadns-ng") then +if api.is_finded("chinadns-ng") then o:value("chinadns-ng", "ChinaDNS-NG") end -if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then +if api.is_finded("pdnsd") then o:value("pdnsd", "pdnsd") end -if is_finded("dns2socks") then +if api.is_finded("dns2socks") then o:value("dns2socks", "dns2socks") end -o:value("local_7913", translate("Use local port 7913 as DNS")) o:value("nonuse", translate("No patterns are used")) ---- Upstream trust DNS Server for ChinaDNS-NG @@ -148,17 +137,17 @@ o = s:taboption("DNS", ListValue, "up_trust_chinadns_ng_dns", translate("Upstream trust DNS Server for ChinaDNS-NG") .. "(UDP)") -- o.description = translate("You can use other resolving DNS services as trusted DNS, Example: dns2socks, dns-forwarder... 127.0.0.1#5353
Only use two at most, english comma separation, If you do not fill in the # and the following port, you are using port 53.") o.default = "pdnsd" -if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then +if api.is_finded("pdnsd") then o:value("pdnsd", "pdnsd + " .. translate("Use TCP Node Resolve DNS")) end -if is_finded("dns2socks") then +if api.is_finded("dns2socks") then o:value("dns2socks", "dns2socks") end o:value("udp", translate("Use UDP Node Resolve DNS")) o:depends("dns_mode", "chinadns-ng") ---- Use TCP Node Resolve DNS ---[[ if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then +--[[ if api.is_finded("pdnsd") then o = s:taboption("DNS", Flag, "use_tcp_node_resolve_dns", translate("Use TCP Node Resolve DNS")) o.description = translate("If checked, DNS is resolved using the TCP node.") o.default = 1 @@ -247,7 +236,7 @@ s.anonymous = true s.addremove = true s.template = "cbi/tblsection" function s.create(e, t) - TypedSection.create(e, _api.gen_uuid()) + TypedSection.create(e, api.gen_uuid()) end o = s:option(DummyValue, "status", translate("Status")) @@ -266,6 +255,7 @@ end for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end o = s:option(Value, "port", translate("Listen Port")) +o.default = 9050 o.datatype = "port" o.rmempty = false diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua index 76ed33680c..00110afd25 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua @@ -1,20 +1,8 @@ local d = require "luci.dispatcher" -local ipkg = require("luci.model.ipkg") local uci = require"luci.model.uci".cursor() local api = require "luci.model.cbi.passwall.api.api" - local appname = "passwall" -local function get_customed_path(e) - return api.uci_get_type("global_app", e .. "_file") -end - -local function is_finded(e) - return luci.sys.exec("find /usr/*bin %s -iname %s -type f" % {get_customed_path(e), e}) ~= "" and true or false -end - -local function is_installed(e) return ipkg.installed(e) end - local ss_encrypt_method_list = { "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", @@ -82,25 +70,25 @@ remarks.default = translate("Remarks") remarks.rmempty = false type = s:option(ListValue, "type", translate("Type")) -if is_installed("ipt2socks") or is_finded("ipt2socks") then +if api.is_finded("ipt2socks") then type:value("Socks", translate("Socks")) end -if is_finded("ss-redir") then +if api.is_finded("ss-redir") then type:value("SS", translate("Shadowsocks")) end -if is_finded("ssr-redir") then +if api.is_finded("ssr-redir") then type:value("SSR", translate("ShadowsocksR")) end -if is_installed("v2ray") or is_finded("v2ray") then +if api.is_finded("v2ray") then type:value("V2ray", translate("V2ray")) end -if is_installed("brook") or is_finded("brook") then +if api.is_finded("brook") then type:value("Brook", translate("Brook")) end -if is_installed("trojan-plus") or is_finded("trojan-plus") then - type:value("Trojan", translate("Trojan-Plus")) +if api.is_finded("trojan-plus") or api.is_finded("trojan") then + type:value("Trojan-Plus", translate("Trojan-Plus")) end -if is_installed("trojan-go") or is_finded("trojan-go") then +if api.is_finded("trojan-go") then type:value("Trojan-Go", translate("Trojan-Go")) end @@ -166,7 +154,7 @@ address:depends({ type = "V2ray", protocol = "http" }) address:depends({ type = "V2ray", protocol = "socks" }) address:depends({ type = "V2ray", protocol = "shadowsocks" }) address:depends("type", "Brook") -address:depends("type", "Trojan") +address:depends("type", "Trojan-Plus") address:depends("type", "Trojan-Go") --[[ @@ -180,7 +168,7 @@ use_ipv6:depends({ type = "V2ray", protocol = "http" }) use_ipv6:depends({ type = "V2ray", protocol = "socks" }) use_ipv6:depends({ type = "V2ray", protocol = "shadowsocks" }) use_ipv6:depends("type", "Brook") -use_ipv6:depends("type", "Trojan") +use_ipv6:depends("type", "Trojan-Plus") use_ipv6:depends("type", "Trojan-Go") --]] @@ -195,7 +183,7 @@ port:depends({ type = "V2ray", protocol = "http" }) port:depends({ type = "V2ray", protocol = "socks" }) port:depends({ type = "V2ray", protocol = "shadowsocks" }) port:depends("type", "Brook") -port:depends("type", "Trojan") +port:depends("type", "Trojan-Plus") port:depends("type", "Trojan-Go") username = s:option(Value, "username", translate("Username")) @@ -209,7 +197,7 @@ password:depends("type", "Socks") password:depends("type", "SS") password:depends("type", "SSR") password:depends("type", "Brook") -password:depends("type", "Trojan") +password:depends("type", "Trojan-Plus") password:depends("type", "Trojan-Go") password:depends("protocol", "http") password:depends("protocol", "socks") @@ -260,13 +248,13 @@ tcp_fast_open:value("false") tcp_fast_open:value("true") tcp_fast_open:depends("type", "SS") tcp_fast_open:depends("type", "SSR") -tcp_fast_open:depends("type", "Trojan") +tcp_fast_open:depends("type", "Trojan-Plus") tcp_fast_open:depends("type", "Trojan-Go") ss_plugin = s:option(ListValue, "ss_plugin", translate("plugin")) ss_plugin:value("none", translate("none")) -if is_finded("v2ray-plugin") then ss_plugin:value("v2ray-plugin") end -if is_finded("obfs-local") then ss_plugin:value("obfs-local") end +if api.is_finded("v2ray-plugin") then ss_plugin:value("v2ray-plugin") end +if api.is_finded("obfs-local") then ss_plugin:value("obfs-local") end ss_plugin:depends("type", "SS") ss_plugin_opts = s:option(Value, "ss_plugin_opts", translate("opts")) @@ -310,7 +298,7 @@ stream_security.default = "tls" stream_security:depends("protocol", "vmess") stream_security:depends("protocol", "socks") stream_security:depends("protocol", "shadowsocks") -stream_security:depends("type", "Trojan") +stream_security:depends("type", "Trojan-Plus") stream_security:depends("type", "Trojan-Go") stream_security.validate = function(self, value) if value == "none" and type:formvalue(arg[1]) == "Trojan" then diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/app.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/app.lua index 1c4948e388..dbb6b7622c 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/app.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/app.lua @@ -79,7 +79,7 @@ local function start() elseif type == "V2ray" then config = require("luci.model.cbi.passwall.server.api.v2ray").gen_config(user) bin = ln_start(_api.get_v2ray_path(), "v2ray", "-config=" .. config_file) - elseif type == "Trojan" then + elseif type == "Trojan-Plus" then config = require("luci.model.cbi.passwall.server.api.trojan").gen_config(user) bin = ln_start("/usr/sbin/trojan-plus", "trojan-plus", "-c " .. config_file) elseif type == "Trojan-Go" then @@ -130,4 +130,4 @@ if action then elseif action == "stop" then stop() end -end +end \ No newline at end of file diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua index eca29b7291..4b8613b241 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua @@ -1,17 +1,7 @@ local d = require "luci.dispatcher" -local ipkg = require("luci.model.ipkg") local uci = require"luci.model.uci".cursor() local api = require "luci.model.cbi.passwall.api.api" -local function is_finded(e) - local function get_customed_path(e) - return api.uci_get_type("global_app", e .. "_file") - end - return luci.sys.exec("find /usr/*bin %s -iname %s -type f" % {get_customed_path(e), e}) ~= "" and true or false -end - -local function is_installed(e) return ipkg.installed(e) end - local ssr_encrypt_method_list = { "none", "table", "rc2-cfb", "rc4", "rc4-md5", "rc4-md5-6", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", @@ -70,19 +60,19 @@ remarks.default = translate("Remarks") remarks.rmempty = false type = s:option(ListValue, "type", translate("Type")) -if is_finded("ssr-server") then +if api.is_finded("ssr-server") then type:value("SSR", translate("ShadowsocksR")) end -if is_installed("v2ray") or is_finded("v2ray") then +if api.is_finded("v2ray") then type:value("V2ray", translate("V2ray")) end -if is_installed("brook") or is_finded("brook") then +if api.is_finded("brook") then type:value("Brook", translate("Brook")) end -if is_installed("trojan-plus") or is_finded("trojan-plus") then - type:value("Trojan", translate("Trojan-Plus")) +if api.is_finded("trojan-plus") or api.is_finded("trojan") then + type:value("Trojan-Plus", translate("Trojan-Plus")) end -if is_installed("trojan-go") or is_finded("trojan-go") then +if api.is_finded("trojan-go") then type:value("Trojan-Go", translate("Trojan-Go")) end @@ -115,7 +105,7 @@ password = s:option(Value, "password", translate("Password")) password.password = true password:depends("type", "SSR") password:depends("type", "Brook") -password:depends("type", "Trojan") +password:depends("type", "Trojan-Plus") password:depends({ type = "V2ray", protocol = "http" }) password:depends({ type = "V2ray", protocol = "socks" }) password:depends({ type = "V2ray", protocol = "shadowsocks" }) @@ -170,7 +160,7 @@ tcp_fast_open = s:option(ListValue, "tcp_fast_open", translate("TCP Fast Open"), tcp_fast_open:value("false") tcp_fast_open:value("true") tcp_fast_open:depends("type", "SSR") -tcp_fast_open:depends("type", "Trojan") +tcp_fast_open:depends("type", "Trojan-Plus") tcp_fast_open:depends("type", "Trojan-Go") udp_forward = s:option(Flag, "udp_forward", translate("UDP Forward")) @@ -203,7 +193,7 @@ stream_security:depends({ type = "V2ray", protocol = "vmess", transport = "ws" } stream_security:depends({ type = "V2ray", protocol = "vmess", transport = "h2" }) stream_security:depends({ type = "V2ray", protocol = "socks" }) stream_security:depends({ type = "V2ray", protocol = "shadowsocks" }) -stream_security:depends("type", "Trojan") +stream_security:depends("type", "Trojan-Plus") stream_security:depends("type", "Trojan-Go") stream_security.validate = function(self, value) if value == "none" and type:formvalue(arg[1]) == "Trojan" then @@ -373,7 +363,7 @@ quic_guise:depends("transport", "quic") remote_enable = s:option(Flag, "remote_enable", translate("Enable Remote"), translate("You can forward to Nginx/Caddy/V2ray WebSocket and more.")) remote_enable.default = "1" remote_enable.rmempty = false -remote_enable:depends("type", "Trojan") +remote_enable:depends("type", "Trojan-Plus") remote_enable:depends("type", "Trojan-Go") remote_address = s:option(Value, "remote_address", translate("Remote Address")) diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm index c1e00c144b..8364ac0c18 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm @@ -1,15 +1,6 @@ <% -local api = require "luci.model.cbi.passwall.api.api" local dsp = require "luci.dispatcher" -local ipkg = require "luci.model.ipkg" - -local function is_finded(e) - local result=luci.sys.exec("find /usr/*bin -iname "..e.." -type f") - if result~="" then - return true - end - return false -end +local api = require "luci.model.cbi.passwall.api.api" local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1) local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1) diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm index 722531d294..2bb7e3715d 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm @@ -1,15 +1,6 @@ <% -local api = require "luci.model.cbi.passwall.api.api" local dsp = require "luci.dispatcher" -local ipkg = require "luci.model.ipkg" - -local function is_finded(e) - local result=luci.sys.exec("find /usr/*bin -iname "..e.." -type f") - if result~="" then - return true - end - return false -end +local api = require "luci.model.cbi.passwall.api.api" local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1) local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1) @@ -81,7 +72,7 @@ local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111", - <% if ipkg.installed("kcptun") or is_finded("kcptun*") then %> + <% if api.is_finded("kcptun-client") then %>
<% end %> - <% if ipkg.installed("haproxy") or is_finded("haproxy*") then %> + <% if api.is_finded("haproxy") then %>