luci: update api finded_com func
This commit is contained in:
parent
83f5115cb7
commit
56157adaf1
@ -1,8 +1,8 @@
|
||||
local api = require "luci.passwall.api"
|
||||
local appname = api.appname
|
||||
local sys = api.sys
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist")
|
||||
|
||||
m = Map(appname)
|
||||
|
@ -2,8 +2,8 @@ local api = require "luci.passwall.api"
|
||||
local appname = api.appname
|
||||
local uci = api.uci
|
||||
local datatypes = api.datatypes
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist")
|
||||
|
||||
m = Map(appname)
|
||||
|
@ -3,9 +3,9 @@ local appname = api.appname
|
||||
local has_ss = api.is_finded("ss-redir")
|
||||
local has_ss_rust = api.is_finded("sslocal")
|
||||
local has_trojan_plus = api.is_finded("trojan-plus")
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_trojan_go = api.is_finded("trojan-go")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
local has_trojan_go = api.finded_com("trojan-go")
|
||||
local ss_aead_type = {}
|
||||
local trojan_type = {}
|
||||
if has_ss then
|
||||
|
@ -4,9 +4,9 @@ local sys = api.sys
|
||||
local has_ss = api.is_finded("ss-redir")
|
||||
local has_ss_rust = api.is_finded("sslocal")
|
||||
local has_trojan_plus = api.is_finded("trojan-plus")
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_trojan_go = api.is_finded("trojan-go")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
local has_trojan_go = api.finded_com("trojan-go")
|
||||
local ss_aead_type = {}
|
||||
local trojan_type = {}
|
||||
if has_ss then
|
||||
|
@ -1,8 +1,8 @@
|
||||
local api = require "luci.passwall.api"
|
||||
local appname = api.appname
|
||||
local fs = api.fs
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
local has_fw3 = api.is_finded("fw3")
|
||||
local has_fw4 = api.is_finded("fw4")
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
local api = require "luci.passwall.api"
|
||||
local appname = api.appname
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
|
||||
m = Map(appname)
|
||||
-- [[ Rule Settings ]]--
|
||||
|
@ -1,8 +1,8 @@
|
||||
local api = require "luci.passwall.api"
|
||||
local appname = api.appname
|
||||
local uci = api.uci
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
|
||||
m = Map(appname)
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("brook") then
|
||||
if not api.finded_com("brook") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("hysteria") then
|
||||
if not api.finded_com("hysteria") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("xray") and not api.is_finded("v2ray") then
|
||||
if not api.finded_com("xray") and not api.finded_com("v2ray") then
|
||||
return
|
||||
end
|
||||
|
||||
@ -79,10 +79,10 @@ local header_type_list = {
|
||||
|
||||
-- [[ Xray ]]
|
||||
|
||||
if api.is_finded("xray") then
|
||||
if api.finded_com("xray") then
|
||||
s.fields["type"]:value("Xray", translate("Xray"))
|
||||
end
|
||||
if api.is_finded("v2ray") then
|
||||
if api.finded_com("v2ray") then
|
||||
s.fields["type"]:value("V2ray", translate("V2ray"))
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("trojan-go") then
|
||||
if not api.finded_com("trojan-go") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("brook") then
|
||||
if not api.finded_com("brook") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("hysteria") then
|
||||
if not api.finded_com("hysteria") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("xray") and not api.is_finded("v2ray")then
|
||||
if not api.finded_com("xray") and not api.finded_com("v2ray")then
|
||||
return
|
||||
end
|
||||
|
||||
@ -74,10 +74,10 @@ local header_type_list = {
|
||||
|
||||
-- [[ Xray ]]
|
||||
|
||||
if api.is_finded("v2ray") then
|
||||
if api.finded_com("v2ray") then
|
||||
s.fields["type"]:value("V2ray", translate("V2ray"))
|
||||
end
|
||||
if api.is_finded("xray") then
|
||||
if api.finded_com("xray") then
|
||||
s.fields["type"]:value("Xray", translate("Xray"))
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ local m, s = ...
|
||||
|
||||
local api = require "luci.passwall.api"
|
||||
|
||||
if not api.is_finded("trojan-go") then
|
||||
if not api.finded_com("trojan-go") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -397,8 +397,14 @@ function get_customed_path(e)
|
||||
return uci_get_type("global_app", e .. "_file")
|
||||
end
|
||||
|
||||
function finded_com(e)
|
||||
local bin = get_app_path(e)
|
||||
if not bin then return end
|
||||
return luci.sys.exec('echo -n $(type -t -p "%s" | head -n1)' % { bin })
|
||||
end
|
||||
|
||||
function finded(e)
|
||||
return luci.sys.exec('echo -n $(type -t -p "/bin/%s" -p "/usr/bin/%s" -p "%s" "%s" | head -n1)' % {e, e, get_customed_path(e), e})
|
||||
return luci.sys.exec('echo -n $(type -t -p "/bin/%s" -p "/usr/bin/%s" "%s" | head -n1)' % {e, e, e})
|
||||
end
|
||||
|
||||
function is_finded(e)
|
||||
@ -441,10 +447,12 @@ local function get_bin_version_cache(file, cmd)
|
||||
end
|
||||
|
||||
function get_app_path(app_name)
|
||||
local def_path = com[app_name].default_path
|
||||
local path = uci_get_type("global_app", app_name:gsub("%-","_") .. "_file")
|
||||
path = path and (#path>0 and path or def_path) or def_path
|
||||
return path
|
||||
if com[app_name] then
|
||||
local def_path = com[app_name].default_path
|
||||
local path = uci_get_type("global_app", app_name:gsub("%-","_") .. "_file")
|
||||
path = path and (#path>0 and path or def_path) or def_path
|
||||
return path
|
||||
end
|
||||
end
|
||||
|
||||
function get_app_version(app_name, file)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<%+cbi/valueheader%>
|
||||
<%
|
||||
local api = require "luci.passwall.api"
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
-%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function padright(str, cnt, pad) {
|
||||
|
@ -24,9 +24,9 @@ uci:revert(appname)
|
||||
local has_ss = api.is_finded("ss-redir")
|
||||
local has_ss_rust = api.is_finded("sslocal")
|
||||
local has_trojan_plus = api.is_finded("trojan-plus")
|
||||
local has_v2ray = api.is_finded("v2ray")
|
||||
local has_xray = api.is_finded("xray")
|
||||
local has_trojan_go = api.is_finded("trojan-go")
|
||||
local has_v2ray = api.finded_com("v2ray")
|
||||
local has_xray = api.finded_com("xray")
|
||||
local has_trojan_go = api.finded_com("trojan-go")
|
||||
local allowInsecure_default = nil
|
||||
local ss_aead_type_default = uci:get(appname, "@global_subscribe[0]", "ss_aead_type") or "shadowsocks-libev"
|
||||
local trojan_type_default = uci:get(appname, "@global_subscribe[0]", "trojan_type") or "trojan-plus"
|
||||
|
Loading…
Reference in New Issue
Block a user