Skip to content

Commit

Permalink
luci-app-passwall: bump to 24.12.26
Browse files Browse the repository at this point in the history
  • Loading branch information
SakuraFallingMad committed Dec 26, 2024
1 parent 4c9bcbb commit 82343b5
Show file tree
Hide file tree
Showing 34 changed files with 252 additions and 207 deletions.
4 changes: 2 additions & 2 deletions applications/luci-app-passwall/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-passwall
PKG_VERSION:=24.12.25
PKG_VERSION:=24.12.26
PKG_RELEASE:=1

PKG_CONFIG_DEPENDS:= \
Expand All @@ -28,7 +28,7 @@ PKG_CONFIG_DEPENDS:= \
LUCI_TITLE:=LuCI support for PassWall
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+coreutils +coreutils-base64 +coreutils-nohup +curl \
+chinadns-ng +dns2socks +dns2tcp +ip-full +libuci-lua +lua +luci-compat +luci-lib-jsonc \
+chinadns-ng +dns2socks +ip-full +libuci-lua +lua +luci-compat +luci-lib-jsonc \
+microsocks +resolveip +tcping +unzip +ipt2socks \
+kmod-nft-socket +kmod-nft-tproxy +kmod-nft-nat \
+PACKAGE_$(PKG_NAME)_INCLUDE_Brook:brook \
Expand Down
28 changes: 15 additions & 13 deletions applications/luci-app-passwall/luasrc/controller/passwall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
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
if nixio.fs.access("/usr/share/passwall/0_default_config") then
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
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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"])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local api = require "luci.passwall.api"
local appname = "passwall"
local uci = api.uci
local uci = api.libuci
local sys = api.sys
local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local api = require "luci.passwall.api"
local appname = "passwall"
local uci = api.uci
local uci = api.libuci
local datatypes = api.datatypes
local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local api = require "luci.passwall.api"
local appname = "passwall"
local uci = api.uci
local fs = require "nixio.fs"
local uci = api.libuci
local fs = api.fs
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall/client/type/"

if not arg[1] or not uci:get(appname, arg[1]) then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local api = require "luci.passwall.api"
local appname = "passwall"
local uci = api.uci
local uci = api.libuci
local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end

local appname = "passwall"
local jsonc = api.jsonc
local uci = api.uci
local uci = api.libuci

local type_name = "Xray"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end
local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'")

local appname = "passwall"
local uci = api.uci
local uci = api.libuci

local type_name = "sing-box"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if not api.finded_com("hysteria") then
return
end

local fs = api.fs

local type_name = "Hysteria2"

local option_prefix = "hysteria2_"
Expand Down Expand Up @@ -46,7 +48,7 @@ o = s:option(FileUpload, _n("tls_certificateFile"), translate("Public key absolu
o.default = m:get(s.section, "tls_certificateFile") or "/etc/config/ssl/" .. arg[1] .. ".pem"
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand All @@ -59,7 +61,7 @@ o = s:option(FileUpload, _n("tls_keyFile"), translate("Private key absolute path
o.default = m:get(s.section, "tls_keyFile") or "/etc/config/ssl/" .. arg[1] .. ".key"
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if not api.finded_com("xray") then
return
end

local fs = api.fs

local type_name = "Xray"

local option_prefix = "xray_"
Expand Down Expand Up @@ -174,7 +176,7 @@ o.default = m:get(s.section, "tls_certificateFile") or "/etc/config/ssl/" .. arg
o:depends({ [_n("tls")] = true, [_n("reality")] = false })
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand All @@ -188,7 +190,7 @@ o.default = m:get(s.section, "tls_keyFile") or "/etc/config/ssl/" .. arg[1] .. "
o:depends({ [_n("tls")] = true, [_n("reality")] = false })
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if not singbox_bin then
return
end

local fs = api.fs

local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'")

local type_name = "sing-box"
Expand Down Expand Up @@ -255,7 +257,7 @@ o:depends({ [_n("protocol")] = "tuic" })
o:depends({ [_n("protocol")] = "hysteria2" })
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand All @@ -273,7 +275,7 @@ o:depends({ [_n("protocol")] = "tuic" })
o:depends({ [_n("protocol")] = "hysteria2" })
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if not api.is_finded("trojan-plus") then
return
end

local fs = api.fs

local type_name = "Trojan-Plus"

local option_prefix = "trojan_plus_"
Expand Down Expand Up @@ -50,7 +52,7 @@ o.default = m:get(s.section, "tls_certificateFile") or "/etc/config/ssl/" .. arg
o:depends({ [_n("tls")] = true })
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand All @@ -64,7 +66,7 @@ o.default = m:get(s.section, "tls_keyFile") or "/etc/config/ssl/" .. arg[1] .. "
o:depends({ [_n("tls")] = true })
o.validate = function(self, value, t)
if value and value ~= "" then
if not nixio.fs.access(value) then
if not fs.access(value) then
return nil, translate("Can't find this file!")
else
return value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local fs = require "nixio.fs"
local fs = api.fs
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall/server/type/"

m = Map("passwall_server", translate("Server Config"))
Expand Down
Loading

0 comments on commit 82343b5

Please sign in to comment.