Update On Thu Dec 26 19:33:33 CET 2024

This commit is contained in:
github-action[bot]
2024-12-26 19:33:33 +01:00
parent 90e70c28fa
commit a0cfaf9dfb
139 changed files with 6956 additions and 978 deletions
@@ -4,11 +4,11 @@
module("luci.controller.passwall", package.seeall)
local api = require "luci.passwall.api"
local appname = "passwall" -- not available
local uci = luci.model.uci.cursor() -- in funtion index()
local uci = api.libuci -- in funtion index()
local fs = api.fs
local http = require "luci.http"
local util = require "luci.util"
local i18n = require "luci.i18n"
local fs = require "nixio.fs"
function index()
if not nixio.fs.access("/etc/config/passwall") then
@@ -16,8 +16,10 @@ function index()
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
else return end
end
local api = require "luci.passwall.api"
local appname = "passwall" -- global definitions not available
local uci = luci.model.uci.cursor() -- in function index()
local uci = api.libuci -- in function index()
local fs = api.fs
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
@@ -35,7 +37,7 @@ function index()
entry({"admin", "services", appname, "node_list"}, cbi(appname .. "/client/node_list"), _("Node List"), 2).dependent = true
entry({"admin", "services", appname, "node_subscribe"}, cbi(appname .. "/client/node_subscribe"), _("Node Subscribe"), 3).dependent = true
entry({"admin", "services", appname, "other"}, cbi(appname .. "/client/other", {autoapply = true}), _("Other Settings"), 92).leaf = true
if nixio.fs.access("/usr/sbin/haproxy") then
if fs.access("/usr/sbin/haproxy") then
entry({"admin", "services", appname, "haproxy"}, cbi(appname .. "/client/haproxy"), _("Load Balancing"), 93).leaf = true
end
entry({"admin", "services", appname, "app_update"}, cbi(appname .. "/client/app_update"), _("App Update"), 95).leaf = true
@@ -143,7 +145,7 @@ function socks_autoswitch_add_node()
table.insert(new_list, e.id)
end
end
uci:set_list(appname, id, "autoswitch_backup_node", new_list)
api.uci_set_list(uci, appname, id, "autoswitch_backup_node", new_list)
uci:commit(appname)
end
luci.http.redirect(api.url("socks_config", id))
@@ -159,7 +161,7 @@ function socks_autoswitch_remove_node()
table.remove(new_list, i)
end
end
uci:set_list(appname, id, "autoswitch_backup_node", new_list)
api.uci_set_list(uci, appname, id, "autoswitch_backup_node", new_list)
uci:commit(appname)
end
luci.http.redirect(api.url("socks_config", id))
@@ -185,10 +187,10 @@ function get_redir_log()
local proto = luci.http.formvalue("proto")
local path = "/tmp/etc/passwall/acl/" .. name
proto = proto:upper()
if proto == "UDP" and (uci:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" and not nixio.fs.access(path .. "/" .. proto .. ".log") then
if proto == "UDP" and (uci:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" and not fs.access(path .. "/" .. proto .. ".log") then
proto = "TCP"
end
if nixio.fs.access(path .. "/" .. proto .. ".log") then
if fs.access(path .. "/" .. proto .. ".log") then
local content = luci.sys.exec("cat ".. path .. "/" .. proto .. ".log")
content = content:gsub("\n", "<br />")
luci.http.write(content)
@@ -200,7 +202,7 @@ end
function get_socks_log()
local name = luci.http.formvalue("name")
local path = "/tmp/etc/passwall/SOCKS_" .. name .. ".log"
if nixio.fs.access(path) then
if fs.access(path) then
local content = luci.sys.exec("cat ".. path)
content = content:gsub("\n", "<br />")
luci.http.write(content)
@@ -346,7 +348,7 @@ end
function copy_node()
local section = luci.http.formvalue("section")
local uuid = api.gen_short_uuid()
uci:section(appname, "nodes", uuid)
api.uci_section(uci, appname, "nodes", uuid)
for k, v in pairs(uci:get_all(appname, section)) do
local filter = k:find("%.")
if filter and filter == 1 then
@@ -370,7 +372,7 @@ function clear_all_nodes()
uci:delete(appname, '@global[0]', "udp_node")
uci:foreach(appname, "socks", function(t)
uci:delete(appname, t[".name"])
uci:set_list(appname, t[".name"], "autoswitch_backup_node", {})
api.uci_set_list(uci, appname, t[".name"], "autoswitch_backup_node", {})
end)
uci:foreach(appname, "haproxy_config", function(t)
uci:delete(appname, t[".name"])
@@ -406,7 +408,7 @@ function delete_select_nodes()
table.remove(auto_switch_node_list, i)
end
end
uci:set_list(appname, t[".name"], "autoswitch_backup_node", auto_switch_node_list)
api.uci_set_list(uci, appname, t[".name"], "autoswitch_backup_node", auto_switch_node_list)
end)
uci:foreach(appname, "haproxy_config", function(t)
if t["lbss"] == w then
@@ -452,7 +454,7 @@ end
function server_user_log()
local id = luci.http.formvalue("id")
if nixio.fs.access("/tmp/etc/passwall_server/" .. id .. ".log") then
if fs.access("/tmp/etc/passwall_server/" .. id .. ".log") then
local content = luci.sys.exec("cat /tmp/etc/passwall_server/" .. id .. ".log")
content = content:gsub("\n", "<br />")
luci.http.write(content)