parent
5bbaac7772
commit
0d11b74f7e
@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-passwall
|
PKG_NAME:=luci-app-passwall
|
||||||
PKG_VERSION:=24.12.25
|
PKG_VERSION:=24.12.26
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_CONFIG_DEPENDS:= \
|
PKG_CONFIG_DEPENDS:= \
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
module("luci.controller.passwall", package.seeall)
|
module("luci.controller.passwall", package.seeall)
|
||||||
local api = require "luci.passwall.api"
|
local api = require "luci.passwall.api"
|
||||||
local appname = "passwall" -- not available
|
local appname = "passwall" -- not available
|
||||||
local uci = luci.model.uci.cursor() -- in funtion index()
|
local uci = api.libuci -- in funtion index()
|
||||||
local http = require "luci.http"
|
local http = require "luci.http"
|
||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
local i18n = require "luci.i18n"
|
local i18n = require "luci.i18n"
|
||||||
@ -16,8 +16,9 @@ function index()
|
|||||||
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
|
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
|
||||||
else return end
|
else return end
|
||||||
end
|
end
|
||||||
|
local api = require "luci.passwall.api"
|
||||||
local appname = "passwall" -- global definitions not available
|
local appname = "passwall" -- global definitions not available
|
||||||
local uci = luci.model.uci.cursor() -- in function index()
|
local uci = api.libuci -- in function index()
|
||||||
entry({"admin", "services", appname}).dependent = true
|
entry({"admin", "services", appname}).dependent = true
|
||||||
entry({"admin", "services", appname, "reset_config"}, call("reset_config")).leaf = true
|
entry({"admin", "services", appname, "reset_config"}, call("reset_config")).leaf = true
|
||||||
entry({"admin", "services", appname, "show"}, call("show_menu")).leaf = true
|
entry({"admin", "services", appname, "show"}, call("show_menu")).leaf = true
|
||||||
@ -143,7 +144,7 @@ function socks_autoswitch_add_node()
|
|||||||
table.insert(new_list, e.id)
|
table.insert(new_list, e.id)
|
||||||
end
|
end
|
||||||
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)
|
uci:commit(appname)
|
||||||
end
|
end
|
||||||
luci.http.redirect(api.url("socks_config", id))
|
luci.http.redirect(api.url("socks_config", id))
|
||||||
@ -159,7 +160,7 @@ function socks_autoswitch_remove_node()
|
|||||||
table.remove(new_list, i)
|
table.remove(new_list, i)
|
||||||
end
|
end
|
||||||
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)
|
uci:commit(appname)
|
||||||
end
|
end
|
||||||
luci.http.redirect(api.url("socks_config", id))
|
luci.http.redirect(api.url("socks_config", id))
|
||||||
@ -346,7 +347,7 @@ end
|
|||||||
function copy_node()
|
function copy_node()
|
||||||
local section = luci.http.formvalue("section")
|
local section = luci.http.formvalue("section")
|
||||||
local uuid = api.gen_short_uuid()
|
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
|
for k, v in pairs(uci:get_all(appname, section)) do
|
||||||
local filter = k:find("%.")
|
local filter = k:find("%.")
|
||||||
if filter and filter == 1 then
|
if filter and filter == 1 then
|
||||||
@ -370,7 +371,7 @@ function clear_all_nodes()
|
|||||||
uci:delete(appname, '@global[0]', "udp_node")
|
uci:delete(appname, '@global[0]', "udp_node")
|
||||||
uci:foreach(appname, "socks", function(t)
|
uci:foreach(appname, "socks", function(t)
|
||||||
uci:delete(appname, t[".name"])
|
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)
|
end)
|
||||||
uci:foreach(appname, "haproxy_config", function(t)
|
uci:foreach(appname, "haproxy_config", function(t)
|
||||||
uci:delete(appname, t[".name"])
|
uci:delete(appname, t[".name"])
|
||||||
@ -406,7 +407,7 @@ function delete_select_nodes()
|
|||||||
table.remove(auto_switch_node_list, i)
|
table.remove(auto_switch_node_list, i)
|
||||||
end
|
end
|
||||||
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)
|
end)
|
||||||
uci:foreach(appname, "haproxy_config", function(t)
|
uci:foreach(appname, "haproxy_config", function(t)
|
||||||
if t["lbss"] == w then
|
if t["lbss"] == w then
|
||||||
|
@ -3,6 +3,7 @@ local com = require "luci.passwall.com"
|
|||||||
bin = require "nixio".bin
|
bin = require "nixio".bin
|
||||||
fs = require "nixio.fs"
|
fs = require "nixio.fs"
|
||||||
sys = require "luci.sys"
|
sys = require "luci.sys"
|
||||||
|
libuci = require "uci".cursor()
|
||||||
uci = require"luci.model.uci".cursor()
|
uci = require"luci.model.uci".cursor()
|
||||||
util = require "luci.util"
|
util = require "luci.util"
|
||||||
datatypes = require "luci.cbi.datatypes"
|
datatypes = require "luci.cbi.datatypes"
|
||||||
@ -30,6 +31,52 @@ function log(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function uci_set_list(cursor, config, section, option, value)
|
||||||
|
if config and section and option then
|
||||||
|
if not value or #value == 0 then
|
||||||
|
return cursor:delete(config, section, option)
|
||||||
|
end
|
||||||
|
return cursor:set(
|
||||||
|
config, section, option,
|
||||||
|
( type(value) == "table" and value or { value } )
|
||||||
|
)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function uci_section(cursor, config, type, name, values)
|
||||||
|
local stat = true
|
||||||
|
if name then
|
||||||
|
stat = cursor:set(config, name, type)
|
||||||
|
else
|
||||||
|
name = cursor:add(config, type)
|
||||||
|
stat = name and true
|
||||||
|
end
|
||||||
|
|
||||||
|
return stat and name
|
||||||
|
end
|
||||||
|
|
||||||
|
function sh_uci_get(config, section, option)
|
||||||
|
exec_call(string.format("uci -q get %s.%s.%s", config, section, option))
|
||||||
|
exec_call(string.format("uci -q commit %s", config))
|
||||||
|
end
|
||||||
|
|
||||||
|
function sh_uci_set(config, section, option, val)
|
||||||
|
exec_call(string.format("uci -q set %s.%s.%s=\"%s\"", config, section, option, val))
|
||||||
|
exec_call(string.format("uci -q commit %s", config))
|
||||||
|
end
|
||||||
|
|
||||||
|
function sh_uci_del(config, section, option)
|
||||||
|
exec_call(string.format("uci -q delete %s.%s.%s", config, section, option))
|
||||||
|
exec_call(string.format("uci -q commit %s", config))
|
||||||
|
end
|
||||||
|
|
||||||
|
function sh_uci_add_list(config, section, option, val)
|
||||||
|
exec_call(string.format("uci -q del_list %s.%s.%s=\"%s\"", config, section, option, val))
|
||||||
|
exec_call(string.format("uci -q add_list %s.%s.%s=\"%s\"", config, section, option, val))
|
||||||
|
exec_call(string.format("uci -q commit %s", config))
|
||||||
|
end
|
||||||
|
|
||||||
function set_cache_var(key, val)
|
function set_cache_var(key, val)
|
||||||
sys.call(string.format('/usr/share/passwall/app.sh set_cache_var %s "%s"', key, val))
|
sys.call(string.format('/usr/share/passwall/app.sh set_cache_var %s "%s"', key, val))
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local api = require "luci.passwall.api"
|
local api = require "luci.passwall.api"
|
||||||
local appname = "passwall"
|
local appname = "passwall"
|
||||||
local uci = api.uci
|
local uci = api.libuci
|
||||||
local sys = api.sys
|
local sys = api.sys
|
||||||
local fs = api.fs
|
local fs = api.fs
|
||||||
local datatypes = api.datatypes
|
local datatypes = api.datatypes
|
||||||
@ -46,7 +46,7 @@ local function restore_servers()
|
|||||||
uci:commit(appname)
|
uci:commit(appname)
|
||||||
end
|
end
|
||||||
if dns_table and #dns_table > 0 then
|
if dns_table and #dns_table > 0 then
|
||||||
uci:set_list("dhcp", "@dnsmasq[0]", "server", dns_table)
|
api.uci_set_list(uci, "dhcp", "@dnsmasq[0]", "server", dns_table)
|
||||||
uci:commit("dhcp")
|
uci:commit("dhcp")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -102,7 +102,7 @@ function logic_restart(var)
|
|||||||
tinsert(dns_table, v)
|
tinsert(dns_table, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
uci:set_list("dhcp", "@dnsmasq[0]", "server", dns_table)
|
api.uci_set_list(uci, "dhcp", "@dnsmasq[0]", "server", dns_table)
|
||||||
uci:commit("dhcp")
|
uci:commit("dhcp")
|
||||||
end
|
end
|
||||||
sys.call("/etc/init.d/dnsmasq restart >/dev/null 2>&1")
|
sys.call("/etc/init.d/dnsmasq restart >/dev/null 2>&1")
|
||||||
@ -505,11 +505,14 @@ function add_rule(var)
|
|||||||
end
|
end
|
||||||
if fwd_dns then
|
if fwd_dns then
|
||||||
local sets = {
|
local sets = {
|
||||||
setflag_4 .. "passwall_chn"
|
setflag_4 .. "passwall_chn",
|
||||||
|
setflag_6 .. "passwall_chn6"
|
||||||
}
|
}
|
||||||
if CHN_LIST == "proxy" then
|
if CHN_LIST == "proxy" then
|
||||||
if NO_PROXY_IPV6 ~= "1" then
|
if NO_PROXY_IPV6 == "1" then
|
||||||
table.insert(sets, setflag_6 .. "passwall_chn6")
|
sets = {
|
||||||
|
setflag_4 .. "passwall_chn"
|
||||||
|
}
|
||||||
end
|
end
|
||||||
if REMOTE_FAKEDNS == "1" then
|
if REMOTE_FAKEDNS == "1" then
|
||||||
sets = {}
|
sets = {}
|
||||||
|
@ -19,7 +19,7 @@ local ssub, slen, schar, sbyte, sformat, sgsub = string.sub, string.len, string.
|
|||||||
local split = api.split
|
local split = api.split
|
||||||
local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify
|
local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify
|
||||||
local base64Decode = api.base64Decode
|
local base64Decode = api.base64Decode
|
||||||
local uci = luci.model.uci.cursor()
|
local uci = api.libuci
|
||||||
uci:revert(appname)
|
uci:revert(appname)
|
||||||
|
|
||||||
local has_ss = api.is_finded("ss-redir")
|
local has_ss = api.is_finded("ss-redir")
|
||||||
@ -229,7 +229,7 @@ do
|
|||||||
set = function(o)
|
set = function(o)
|
||||||
for kk, vv in pairs(CONFIG) do
|
for kk, vv in pairs(CONFIG) do
|
||||||
if (vv.remarks == id .. "备用节点的列表") then
|
if (vv.remarks == id .. "备用节点的列表") then
|
||||||
uci:set_list(appname, id, "autoswitch_backup_node", vv.new_nodes)
|
api.uci_set_list(uci, appname, id, "autoswitch_backup_node", vv.new_nodes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -300,8 +300,8 @@ do
|
|||||||
if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then
|
if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then
|
||||||
uci:foreach(appname, "nodes", function(node2)
|
uci:foreach(appname, "nodes", function(node2)
|
||||||
if node2[".name"] == node[".name"] then
|
if node2[".name"] == node[".name"] then
|
||||||
local section = uci:section(appname, "nodes", node_id)
|
local section = api.uci_section(uci, appname, "nodes", node_id)
|
||||||
uci:set_list(appname, section, "balancing_node", vv.new_nodes)
|
api.uci_set_list(uci, appname, section, "balancing_node", vv.new_nodes)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -1456,7 +1456,7 @@ local function update_node(manual)
|
|||||||
local remark = v["remark"]
|
local remark = v["remark"]
|
||||||
local list = v["list"]
|
local list = v["list"]
|
||||||
for _, vv in ipairs(list) do
|
for _, vv in ipairs(list) do
|
||||||
local cfgid = uci:section(appname, "nodes", api.gen_short_uuid())
|
local cfgid = api.uci_section(uci, appname, "nodes", api.gen_short_uuid())
|
||||||
for kkk, vvv in pairs(vv) do
|
for kkk, vvv in pairs(vv) do
|
||||||
uci:set(appname, cfgid, kkk, vvv)
|
uci:set(appname, cfgid, kkk, vvv)
|
||||||
-- sing-box 域名解析策略
|
-- sing-box 域名解析策略
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile
|
diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile
|
||||||
index b167381..53e8463 100644
|
index 6397a77..07f4ea6 100644
|
||||||
--- a/luci-app-passwall/Makefile
|
--- a/luci-app-passwall/Makefile
|
||||||
+++ b/luci-app-passwall/Makefile
|
+++ b/luci-app-passwall/Makefile
|
||||||
@@ -144,7 +144,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata
|
@@ -144,7 +144,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata
|
||||||
@ -20,10 +20,10 @@ index b167381..53e8463 100644
|
|||||||
|
|
||||||
define Package/$(PKG_NAME)/postrm
|
define Package/$(PKG_NAME)/postrm
|
||||||
diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua
|
diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua
|
||||||
index abf7438..0199815 100644
|
index b56e7df..446186e 100644
|
||||||
--- a/luci-app-passwall/luasrc/controller/passwall.lua
|
--- a/luci-app-passwall/luasrc/controller/passwall.lua
|
||||||
+++ b/luci-app-passwall/luasrc/controller/passwall.lua
|
+++ b/luci-app-passwall/luasrc/controller/passwall.lua
|
||||||
@@ -281,7 +281,7 @@ function connect_status()
|
@@ -282,7 +282,7 @@ function connect_status()
|
||||||
url = "-x socks5h://" .. socks_server .. " " .. url
|
url = "-x socks5h://" .. socks_server .. " " .. url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user