diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile
index 09dc5b527e..53472767eb 100644
--- a/package/lienol/luci-app-passwall/Makefile
+++ b/package/lienol/luci-app-passwall/Makefile
@@ -1,5 +1,5 @@
# Copyright (C) 2018-2020 L-WRT Team
-#
+# Copyright (C) 2021 xiaorouji
# This is free software, licensed under the GNU General Public License v3.
#
@@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4
-PKG_RELEASE:=10
-PKG_DATE:=20210122
+PKG_RELEASE:=12
+PKG_DATE:=20210127
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
diff --git a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua
index 8731d7d906..48bf69e309 100644
--- a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua
+++ b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua
@@ -1,18 +1,20 @@
-- Copyright (C) 2018-2020 L-WRT Team
+-- Copyright (C) 2021 xiaorouji
+
module("luci.controller.passwall", package.seeall)
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
local ucic = luci.model.uci.cursor()
local http = require "luci.http"
local util = require "luci.util"
local i18n = require "luci.i18n"
-local api = require "luci.model.cbi.passwall.api.api"
-local kcptun = require "luci.model.cbi.passwall.api.kcptun"
-local brook = require "luci.model.cbi.passwall.api.brook"
-local xray = require "luci.model.cbi.passwall.api.xray"
-local trojan_go = require "luci.model.cbi.passwall.api.trojan_go"
+local kcptun = require("luci.model.cbi." .. appname ..".api.kcptun")
+local brook = require("luci.model.cbi." .. appname ..".api.brook")
+local xray = require("luci.model.cbi." .. appname ..".api.xray")
+local trojan_go = require("luci.model.cbi." .. appname ..".api.trojan_go")
function index()
- appname = "passwall"
+ appname = require "luci.model.cbi.passwall.api.api".appname
entry({"admin", "services", appname}).dependent = true
entry({"admin", "services", appname, "reset_config"}, call("reset_config")).leaf = true
entry({"admin", "services", appname, "show"}, call("show_menu")).leaf = true
@@ -82,12 +84,12 @@ end
function reset_config()
luci.sys.call('[ -f "/usr/share/passwall/config.default" ] && cp -f /usr/share/passwall/config.default /etc/config/passwall && /etc/init.d/passwall reload')
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname))
+ luci.http.redirect(api.url())
end
function show_menu()
luci.sys.call("touch /etc/config/passwall_show")
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname))
+ luci.http.redirect(api.url())
end
function hide_menu()
@@ -170,14 +172,14 @@ function status()
-- local dns_mode = ucic:get(appname, "@global[0]", "dns_mode")
local e = {}
e.dns_mode_status = luci.sys.call("netstat -apn | grep ':7913 ' >/dev/null") == 0
- e.haproxy_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
- e["kcptun_tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp' >/dev/null", appname)) == 0
- e["tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP' >/dev/null", appname)) == 0
+ e.haproxy_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
+ e["kcptun_tcp_node_status"] = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp' >/dev/null", appname)) == 0
+ e["tcp_node_status"] = luci.sys.call(string.format("top -bn1 | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP' >/dev/null", appname)) == 0
if (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" then
e["udp_node_status"] = e["tcp_node_status"]
else
- e["udp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep -i 'UDP' >/dev/null", appname)) == 0
+ e["udp_node_status"] = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep -i 'UDP' >/dev/null", appname)) == 0
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)
@@ -188,12 +190,12 @@ function socks_status()
local index = luci.http.formvalue("index")
local id = luci.http.formvalue("id")
e.index = index
- e.socks_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep '%s' | grep 'SOCKS_' > /dev/null", appname, id)) == 0
+ e.socks_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep '%s' | grep 'SOCKS_' > /dev/null", appname, id)) == 0
local use_http = ucic:get(appname, id, "http_port") or 0
e.use_http = 0
if tonumber(use_http) > 0 then
e.use_http = 1
- e.http_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", appname, id)) == 0
+ e.http_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", appname, id)) == 0
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)
@@ -241,7 +243,7 @@ function set_node()
ucic:set(appname, "@global[0]", protocol .. "_node", section)
ucic:commit(appname)
luci.sys.call("/etc/init.d/passwall restart > /dev/null 2>&1 &")
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
+ luci.http.redirect(api.url("log"))
end
function copy_node()
@@ -260,7 +262,7 @@ function copy_node()
end
end
ucic:commit(appname)
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "node_config", uuid))
+ luci.http.redirect(api.url("node_config", uuid))
end
function clear_all_nodes()
@@ -332,7 +334,7 @@ end
function server_user_status()
local e = {}
e.index = luci.http.formvalue("index")
- e.status = luci.sys.call(string.format("ps -w | grep -v 'grep' | grep '%s/bin/' | grep -i '%s' >/dev/null", appname .. "_server", luci.http.formvalue("id"))) == 0
+ e.status = luci.sys.call(string.format("top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep -i '%s' >/dev/null", appname .. "_server", luci.http.formvalue("id"))) == 0
http_write_json(e)
end
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 7df868e616..3c04024cbd 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
@@ -9,12 +9,25 @@ local i18n = require "luci.i18n"
appname = "passwall"
curl = "/usr/bin/curl"
curl_args = {"-skL", "--connect-timeout 3", "--retry 3", "-m 60"}
-wget = "/usr/bin/wget"
-wget_args = {"--no-check-certificate", "--quiet", "--timeout=100", "--tries=3"}
command_timeout = 300
LEDE_BOARD = nil
DISTRIB_TARGET = nil
+function url(...)
+ local url = string.format("admin/services/%s", appname)
+ local args = { ... }
+ for i, v in pairs(args) do
+ if v ~= "" then
+ url = url .. "/" .. v
+ end
+ end
+ return require "luci.dispatcher".build_url(url)
+end
+
+function trim(s)
+ return (s:gsub("^%s*(.-)%s*$", "%1"))
+end
+
function is_exist(table, value)
for index, k in ipairs(table) do
if k == value then
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/app_update.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/app_update.lua
index d7f7e7e2db..ca697b3cf8 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/app_update.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/app_update.lua
@@ -1,4 +1,3 @@
-local d = require "luci.dispatcher"
local appname = "passwall"
m = Map(appname)
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua
index e17aa025d8..ab048d5eeb 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua
@@ -1,6 +1,5 @@
-local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
-local appname = "passwall"
+local appname = api.appname
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do
@@ -23,12 +22,7 @@ o.rmempty = false
---- Testing Time
o = s:option(Value, "testing_time", translate("How often is a diagnosis made"), translate("Units:minutes"))
-o.default = "3"
-
-o = s:option(ListValue, "tcp_main", "TCP " .. translate("Main node"))
-for k, v in pairs(nodes_table) do
- o:value(v.id, v.remarks)
-end
+o.default = "1"
o = s:option(DynamicList, "tcp_node", "TCP " .. translate("List of backup nodes"))
for k, v in pairs(nodes_table) do
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
index 19e65ce419..f0dda34455 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
@@ -1,7 +1,6 @@
-local d = require "luci.dispatcher"
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
-local appname = "passwall"
+local appname = api.appname
local has_xray = api.is_finded("xray")
m = Map(appname)
@@ -95,7 +94,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
if n then
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
local remarks = api.get_full_node_remarks(n)
- local url = d.build_url("admin", "services", appname, "node_config", current_node)
+ local url = api.url("node_config", current_node)
tcp_node.description = tcp_node.description .. translatef("Current node: %s", string.format('%s', url, remarks)) .. "
"
end
if n.protocol and n.protocol == "_shunt" then
@@ -103,7 +102,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
local id = e[".name"]
local remarks = translate(e.remarks)
if n[id] and n[id] ~= "nil" then
- local url = d.build_url("admin", "services", appname, "node_config", n[id])
+ local url = api.url("node_config", n[id])
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('%s', url, r) .. "
"
end
@@ -111,7 +110,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
local id = "default_node"
local remarks = translate("Default")
if n[id] and n[id] ~= "nil" then
- local url = d.build_url("admin", "services", appname, "node_config", n[id])
+ local url = api.url("node_config", n[id])
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('%s', url, r) .. "
"
end
@@ -371,8 +370,12 @@ end
for k, v in pairs(nodes_table) do
tcp_node:value(v.id, v.remarks)
tcp_node_socks:depends("tcp_node", v.id)
- if has_xray then
- tcp_node_http:depends("tcp_node", v.id)
+ if v.type == "Xray" then
+ if has_xray then
+ tcp_node_http:depends("tcp_node", v.id)
+ end
+ else
+ tcp_node_http:depends("tcp_node_socks", true)
end
udp_node:value(v.id, v.remarks)
if v.type == "Socks" then
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua
index fc4c4ae011..0d4a61beb9 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua
@@ -1,7 +1,7 @@
local e = require "luci.sys"
local net = require "luci.model.network".init()
local api = require "luci.model.cbi.passwall.api.api"
-local appname = "passwall"
+local appname = api.appname
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua
index 859079e9a1..5580e17aab 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua
@@ -1,5 +1,8 @@
-f = SimpleForm("passwall")
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
+
+f = SimpleForm(appname)
f.reset = false
f.submit = false
-f:append(Template("passwall/log/log"))
+f:append(Template(appname .. "/log/log"))
return f
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua
index 61186e3ce3..3f5be4a493 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua
@@ -1,7 +1,6 @@
-local d = require "luci.dispatcher"
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
-local appname = "passwall"
+local appname = api.appname
local ss_encrypt_method_list = {
"rc4-md5", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-ctr",
@@ -54,7 +53,7 @@ local encrypt_methods_ss_aead = {
}
m = Map(appname, translate("Node Config"))
-m.redirect = d.build_url("admin", "services", appname)
+m.redirect = api.url()
s = m:section(NamedSection, arg[1], "nodes", "")
s.addremove = false
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_list.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_list.lua
index f34553fac4..66d700880b 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_list.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_list.lua
@@ -1,6 +1,5 @@
-local d = require "luci.dispatcher"
-local _api = require "luci.model.cbi.passwall.api.api"
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map(appname)
@@ -28,9 +27,9 @@ s = m:section(TypedSection, "nodes")
s.anonymous = true
s.addremove = true
s.template = "cbi/tblsection"
-s.extedit = d.build_url("admin", "services", appname, "node_config", "%s")
+s.extedit = api.url("node_config", "%s")
function s.create(e, t)
- local uuid = _api.gen_uuid()
+ local uuid = api.gen_uuid()
t = uuid
TypedSection.create(e, t)
luci.http.redirect(e.extedit:format(t))
@@ -39,7 +38,7 @@ end
function s.remove(e, t)
s.map.proceed = true
s.map:del(t)
- luci.http.redirect(d.build_url("admin", "services", appname, "node_list"))
+ luci.http.redirect(api.url("node_list"))
end
if nodes_display:find("show_group") then
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe.lua
index 3cd6757bf9..897490ee5e 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe.lua
@@ -1,4 +1,5 @@
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map(appname)
@@ -36,7 +37,7 @@ o = s:option(Button, "_update", translate("Manual subscription"))
o.inputstyle = "apply"
function o.write(e, e)
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua start log > /dev/null 2>&1 &")
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
+ luci.http.redirect(api.url("log"))
end
---- Subscribe Delete All
@@ -44,7 +45,7 @@ o = s:option(Button, "_stop", translate("Delete All Subscribe Node"))
o.inputstyle = "remove"
function o.write(e, e)
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua truncate log > /dev/null 2>&1 &")
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
+ luci.http.redirect(api.url("log"))
end
filter_enabled = s:option(Flag, "filter_enabled", translate("Filter keyword switch"), translate("When checked, below options can only be take effect."))
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua
index d7efef2c21..715f458c1d 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua
@@ -1,5 +1,5 @@
-local uci = require"luci.model.uci".cursor()
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map(appname)
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua
index 7ae5807c99..bebcfb7ea0 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua
@@ -1,5 +1,5 @@
-local d = require "luci.dispatcher"
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map(appname)
-- [[ Rule Settings ]]--
@@ -53,7 +53,7 @@ s = m:section(TypedSection, "shunt_rules", "Xray" .. translate("Shunt") .. trans
s.template = "cbi/tblsection"
s.anonymous = false
s.addremove = true
-s.extedit = d.build_url("admin", "services", appname, "shunt_rules", "%s")
+s.extedit = api.url("shunt_rules", "%s")
function s.create(e, t)
TypedSection.create(e, t)
luci.http.redirect(e.extedit:format(t))
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua
index 20740f458a..db9e5a1772 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua
@@ -1,5 +1,6 @@
local fs = require "nixio.fs"
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map(appname)
m.apply_on_parse=true
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua
index 94af7757c6..4ddc363eda 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua
@@ -1,8 +1,8 @@
-local d = require "luci.dispatcher"
-local appname = "passwall"
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map(appname, "Xray" .. translate("Shunt") .. translate("Rule"))
-m.redirect = d.build_url("admin", "services", appname)
+m.redirect = api.url()
s = m:section(NamedSection, arg[1], "shunt_rules", "")
s.addremove = false
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 e7372f7e26..62200646c5 100755
--- 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
@@ -4,7 +4,7 @@ local action = arg[1]
local sys = require 'luci.sys'
local jsonc = require "luci.jsonc"
local ucic = require"luci.model.uci".cursor()
-local _api = require "luci.model.cbi.passwall.api.api"
+local api = require "luci.model.cbi.passwall.api.api"
local CONFIG = "passwall_server"
local CONFIG_PATH = "/var/etc/" .. CONFIG
@@ -111,7 +111,7 @@ local function start()
bin = ln_start("/usr/bin/" .. type .. "-server", type .. "-server", "-c " .. config_file .. " " .. udp_param, log_path)
elseif type == "Xray" then
config = require("luci.model.cbi.passwall.server.api.xray").gen_config(user)
- bin = ln_start(_api.get_xray_path(), "xray", "-config=" .. config_file, log_path)
+ bin = ln_start(api.get_xray_path(), "xray", "-config=" .. config_file, log_path)
elseif type == "Trojan" then
config = require("luci.model.cbi.passwall.server.api.trojan").gen_config(user)
bin = ln_start("/usr/sbin/trojan", "trojan", "-c " .. config_file, log_path)
@@ -120,11 +120,11 @@ local function start()
bin = ln_start("/usr/sbin/trojan-plus", "trojan-plus", "-c " .. config_file, log_path)
elseif type == "Trojan-Go" then
config = require("luci.model.cbi.passwall.server.api.trojan").gen_config(user)
- bin = ln_start(_api.get_trojan_go_path(), "trojan-go", "-config " .. config_file, log_path)
+ bin = ln_start(api.get_trojan_go_path(), "trojan-go", "-config " .. config_file, log_path)
elseif type == "Brook" then
local brook_protocol = user.protocol
local brook_password = user.password
- bin = ln_start(_api.get_brook_path(), "brook_" .. id, string.format("%s -l :%s -p %s", brook_protocol, port, brook_password), log_path)
+ bin = ln_start(api.get_brook_path(), "brook_" .. id, string.format("%s -l :%s -p %s", brook_protocol, port, brook_password), log_path)
end
if next(config) then
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/index.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/index.lua
index b452a89512..6d901135d4 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/index.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/index.lua
@@ -1,6 +1,5 @@
-local d = require "luci.dispatcher"
-local _api = require "luci.model.cbi.passwall.api.api"
-local e = luci.model.uci.cursor()
+local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
m = Map("passwall_server", translate("Server-Side"))
@@ -16,9 +15,9 @@ t.anonymous = true
t.addremove = true
t.sortable = true
t.template = "cbi/tblsection"
-t.extedit = d.build_url("admin", "services", "passwall", "server_user", "%s")
+t.extedit = api.url("server_user", "%s")
function t.create(e, t)
- local uuid = _api.gen_uuid()
+ local uuid = api.gen_uuid()
t = uuid
TypedSection.create(e, t)
luci.http.redirect(e.extedit:format(t))
@@ -26,7 +25,7 @@ end
function t.remove(e, t)
e.map.proceed = true
e.map:del(t)
- luci.http.redirect(d.build_url("admin", "services", "passwall", "server"))
+ luci.http.redirect(api.url("server"))
end
e = t:option(Flag, "enable", translate("Enable"))
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 bd2df888d8..14fda9b01a 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,5 +1,5 @@
-local d = require "luci.dispatcher"
local api = require "luci.model.cbi.passwall.api.api"
+local appname = api.appname
local ss_encrypt_method_list = {
"rc4-md5", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-ctr",
@@ -48,7 +48,7 @@ local encrypt_methods_ss_aead = {
}
m = Map("passwall_server", translate("Server Config"))
-m.redirect = d.build_url("admin", "services", "passwall", "server")
+m.redirect = api.url("server")
s = m:section(NamedSection, arg[1], "user", "")
s.addremove = false
diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/app_update/brook_version.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/app_update/brook_version.htm
index 4fb2cfb9b4..9783e9b02c 100644
--- a/package/lienol/luci-app-passwall/luasrc/view/passwall/app_update/brook_version.htm
+++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/app_update/brook_version.htm
@@ -1,5 +1,6 @@
<%
-local brook_version = require "luci.model.cbi.passwall.api.api".get_brook_version()
+local api = require "luci.model.cbi.passwall.api.api"
+local brook_version = api.get_brook_version()
-%>
\ No newline at end of file
diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/log/log.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/log/log.htm
index c9af2f6554..75e5783170 100644
--- a/package/lienol/luci-app-passwall/luasrc/view/passwall/log/log.htm
+++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/log/log.htm
@@ -1,7 +1,10 @@
+<%
+local api = require "luci.model.cbi.passwall.api.api"
+-%>