🏅 Sync 2026-08-09 09:19:32

This commit is contained in:
github-actions[bot]
2026-08-09 09:19:32 +08:00
parent d561df80a2
commit 4e68dd678d
32 changed files with 313 additions and 221 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=26.8.1
PKG_RELEASE:=205
PKG_RELEASE:=206
PKG_PO_VERSION:=$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
@@ -310,7 +310,7 @@ end
function get_socks_log()
local name = http.formvalue("name")
local path = "/tmp/etc/passwall/SOCKS_" .. name .. ".log"
local path = "/tmp/etc/passwall/" .. name .. ".log"
if fs.access(path) then
local content = luci.sys.exec("cat ".. path)
content = content:gsub("\n", "<br />")
@@ -466,7 +466,7 @@ function socks_status()
local index = http.formvalue("index")
local id = http.formvalue("id")
e.index = index
e.socks_status = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep '%s' | grep 'SOCKS_' > /dev/null", id)) == 0
e.socks_status = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v -E 'grep|acl/|acl_' | grep '%s/bin/' | grep '%s' > /dev/null", appname, id)) == 0
local use_http = uci:get(appname, id, "http_port") or 0
e.use_http = 0
if tonumber(use_http) > 0 then
@@ -631,7 +631,7 @@ end
function clear_all_nodes()
uci:set(appname, '@global[0]', "enabled", "0")
uci:set(appname, '@global[0]', "socks_enabled", "0")
uci:set(appname, '@haproxy_config[0]', "balancing_enable", "0")
uci:set(appname, '@global_haproxy[0]', "balancing_enable", "0")
uci:delete(appname, '@global[0]', "tcp_node")
uci:delete(appname, '@global[0]', "udp_node")
uci:foreach(appname, "socks", function(t)
@@ -65,7 +65,7 @@ m.uci:foreach(appname, "socks", function(s)
remark = id .. " - " .. (remark or translate("Misconfigured"))
}
socks_list[#socks_list + 1] = {
id = "Socks_" .. s[".name"],
id = s[".name"],
remark = translate("Socks Config") .. " " .. string.format("[%s %s]", s.port, translate("Port")),
group = "Socks"
}
@@ -735,10 +735,10 @@ s2.anonymous = true
s2.addremove = true
s2.extedit = api.url("socks_config", "%s")
function s2.create(e, t)
local uuid = api.gen_short_uuid()
t = uuid
TypedSection.create(e, t)
luci.http.redirect(e.extedit:format(t))
local uuid = api.gen_short_uuid(5)
uuid = "socks_" .. uuid
TypedSection.create(e, uuid)
luci.http.redirect(e.extedit:format(uuid))
end
function s2.remove(e, t)
local socks = "Socks_" .. t
@@ -805,7 +805,7 @@ o.group = {}
o = s2:option(DummyValue, "now_node", translate("Current Node"))
o.rawhtml = true
o.cfgvalue = function(_, n)
local current_node = api.get_cache_var("socks_" .. n)
local current_node = api.get_cache_var(n)
if current_node then
local node = m:get(current_node)
if node then
@@ -114,7 +114,9 @@ s.anonymous = true
s.addremove = true
s.create = function(e, t)
TypedSection.create(e, api.gen_short_uuid())
local uuid = api.gen_short_uuid(5)
uuid = "haproxy_" .. uuid
TypedSection.create(e, uuid)
end
s.remove = function(self, section)
@@ -222,7 +222,9 @@ if has_xray then
s_xray_noise.addremove = true
s_xray_noise.create = function(e, t)
TypedSection.create(e, api.gen_short_uuid())
local uuid = api.gen_short_uuid(5)
uuid = "xray_noise_" .. uuid
TypedSection.create(e, uuid)
end
s_xray_noise.remove = function(self, section)
@@ -32,7 +32,7 @@ o.default = 1
o.rmempty = false
local auto_switch_tip
local current_node = api.get_cache_var("socks_" .. arg[1])
local current_node = api.get_cache_var(arg[1])
if current_node then
local n = m:get(current_node)
if n then
+4 -3
View File
@@ -556,7 +556,7 @@ function get_node_list()
uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then
node_list.socks_list[#node_list.socks_list + 1] = {
id = "Socks_" .. s[".name"],
id = s[".name"],
remark = i18n.translate("Socks Config") .. " [" .. s.port .. i18n.translate("Port") .. "]",
group = "Socks"
}
@@ -650,8 +650,9 @@ function gen_uuid(format)
return uuid
end
function gen_short_uuid()
return sys.exec("echo -n $(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)")
function gen_short_uuid(length)
if not length then length = 8 end
return sys.exec("echo -n $(head /dev/urandom | tr -dc A-Za-z0-9 | head -c %s)" % length)
end
function uci_get_type(type, config, default)
@@ -1266,36 +1266,25 @@ function gen_config(var)
})
end
function gen_socks_config_node(node_id, socks_id, remarks)
if node_id then
socks_id = node_id:sub(1 + #"Socks_")
end
local result
local socks_node = uci:get_all(appname, socks_id) or nil
if socks_node then
if not remarks then
remarks = socks_node.port
end
result = {
[".name"] = "Socksid_" .. socks_id,
remarks = remarks,
function get_node_by_id(node_id)
if not node_id or node_id == "" or node_id == "nil" then return nil end
local section = uci:get_all(appname, node_id) or {}
if section[".type"] == "socks" then
local result = {
[".name"] = node_id,
remarks = "socks[%s]" % section.port,
type = "sing-box",
protocol = "socks",
address = "127.0.0.1",
port = socks_node.port,
port = section.port,
uot = "1"
}
return result
end
return result
end
function get_node_by_id(node_id)
if not node_id or node_id == "" or node_id == "nil" then return nil end
if node_id:find("Socks_") then
return gen_socks_config_node(node_id)
else
return uci:get_all(appname, node_id)
if section[".type"] == "nodes" then
return section
end
return nil
end
function gen_urltest_outbound(_node)
+12 -23
View File
@@ -981,37 +981,26 @@ function gen_config(var)
end
function gen_socks_config_node(node_id, socks_id, remarks)
if node_id then
socks_id = node_id:sub(1 + #"Socks_")
end
local result
local socks_node = uci:get_all(appname, socks_id) or nil
if socks_node then
if not remarks then
remarks = socks_node.port
end
result = {
[".name"] = "Socksid_" .. socks_id,
remarks = remarks,
function get_node_by_id(node_id)
if not node_id or node_id == "" or node_id == "nil" then return nil end
local section = uci:get_all(appname, node_id) or {}
if section[".type"] == "socks" then
local result = {
[".name"] = node_id,
remarks = "socks[%s]" % section.port,
type = "Xray",
protocol = "socks",
address = "127.0.0.1",
port = socks_node.port,
port = section.port,
transport = "tcp",
stream_security = "none"
}
return result
end
return result
end
function get_node_by_id(node_id)
if not node_id or node_id == "" or node_id == "nil" then return nil end
if node_id:find("Socks_") then
return gen_socks_config_node(node_id)
else
return uci:get_all(appname, node_id)
if section[".type"] == "nodes" then
return section
end
return nil
end
function gen_loopback(outbound_tag, loopback_dst)
@@ -55,8 +55,8 @@ local appname = api.appname
return;
}
let to_url = '<%=api.url("node_config")%>/' + node_select_value;
if (node_select_value.indexOf("Socks_") === 0) {
to_url = '<%=api.url("socks_config")%>/' + node_select_value.substring("Socks_".length);
if (node_select_value.indexOf("socks_") === 0) {
to_url = '<%=api.url("socks_config")%>/' + node_select_value;
}
location.href = to_url;
}
@@ -30,7 +30,7 @@
const selectNode = document.getElementById(dom_id + "_node");
val = selectNode.value;
}
if (val == "" || val.startsWith("_") || val.startsWith("Socks_") || !normal_list.find(element => element.id == val)) {
if (val == "" || val.startsWith("_") || val.startsWith("socks_") || !normal_list.find(element => element.id == val)) {
const hiddenSelect = document.getElementById(cbid);
const panel = document.getElementById(cbid + ".panel");
const display = document.getElementById(cbid + ".display");
@@ -60,6 +60,15 @@ chmod +x /usr/share/passwall/*.sh
[ "$(uci -q get passwall.@global_xray[0].sniffing)" == "1" ] && [ "$(uci -q get passwall.@global_xray[0].route_only)" != "1" ] && uci -q set passwall.@global_xray[0].sniffing_override_dest=1
uci -q delete passwall.@global_xray[0].sniffing
uci -q delete passwall.@global_xray[0].route_only
for sid in $(uci show passwall | grep "=socks" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}'); do
if [ -z "$(echo ${sid} | grep '^socks_')" ]; then
new_id="socks_$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)"
uci -q rename passwall.${sid}="${new_id}"
unset sid new_id
fi
done
uci -q commit passwall
sed -i "s#add_from#group#g" /etc/config/passwall 2>/dev/null
@@ -341,8 +341,8 @@ run_socks() {
local node2socks_port=0
local type remarks server_host server_port
if is_socks_wrap "$node"; then
node2socks_port=$(config_n_get ${node#Socks_} port 0)
if [ "$(config_get_type $node)" = "socks" ]; then
node2socks_port=$(config_n_get $node port 0)
fi
if [ "$node2socks_port" = "0" ]; then
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
@@ -546,8 +546,8 @@ run_redir() {
local node2socks_port=0
local type remarks server_host port
if is_socks_wrap "$node"; then
node2socks_port=$(config_n_get ${node#Socks_} port 0)
if [ "$(config_get_type $node)" = "socks" ]; then
node2socks_port=$(config_n_get $node port 0)
fi
if [ "$node2socks_port" = "0" ]; then
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
@@ -999,8 +999,8 @@ start_socks() {
local bind="0.0.0.0"
[ "$bind_local" = "1" ] && bind="127.0.0.1"
local port=$(config_n_get $id port)
local config_file="SOCKS_${id}.json"
local log_file="SOCKS_${id}.log"
local config_file="${id}.json"
local log_file="${id}.log"
local log=$(config_n_get $id log 1)
[ "$log" = "0" ] && log_file=""
local http_port=$(config_n_get $id http_port 0)
@@ -1009,7 +1009,7 @@ start_socks() {
local no_rec=0
[ "$enable_autoswitch" = "1" ] && no_rec=1
NO_REC_PROCESS=$no_rec $APP_PATH/app.sh run_socks flag=$id node=$node bind=$bind socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
set_cache_var "socks_${id}" "$node"
set_cache_var "${id}" "$node"
#自动切换逻辑
[ "$enable_autoswitch" = "1" ] && { $APP_PATH/socks_auto_switch.sh ${id} > /dev/null 2>&1 & }
done
@@ -1024,13 +1024,13 @@ socks_node_switch() {
local prefix pf filename
# 结束 SS 插件进程
for prefix in "" "HTTP_"; do
pf="$TMP_PATH/${prefix}SOCKS_${flag}_plugin.pid"
pf="$TMP_PATH/${prefix}${flag}_plugin.pid"
[ -s "$pf" ] && kill -9 "$(head -n1 "$pf")" >/dev/null 2>&1
done
busybox pgrep -af "$TMP_BIN_PATH" | awk -v P1="${flag}" 'BEGIN{IGNORECASE=1}$0~P1 && !/acl\/|acl_/{print $1}' | xargs kill -9 >/dev/null 2>&1
for prefix in "" "HTTP_" "HTTP2"; do
rm -rf "$TMP_PATH/${prefix}SOCKS_${flag}"*
rm -rf "$TMP_PATH/${prefix}${flag}"*
done
for filename in $(ls ${TMP_SCRIPT_FUNC_PATH}); do
@@ -1041,15 +1041,15 @@ socks_node_switch() {
local bind="0.0.0.0"
[ "$bind_local" = "1" ] && bind="127.0.0.1"
local port=$(config_n_get $flag port)
local config_file="SOCKS_${flag}.json"
local log_file="SOCKS_${flag}.log"
local config_file="${flag}.json"
local log_file="${flag}.log"
local log=$(config_n_get $flag log 1)
[ "$log" = "0" ] && log_file=""
local http_port=$(config_n_get $flag http_port 0)
local http_config_file="HTTP2SOCKS_${flag}.json"
LOG_FILE="/dev/null"
run_socks flag=$flag node=$new_node bind=$bind socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
set_cache_var "socks_${flag}" "$new_node"
set_cache_var "${flag}" "$new_node"
local ENABLED_DEFAULT_ACL=$(get_cache_var "ENABLED_DEFAULT_ACL")
local ENABLED_ACLS=$(get_cache_var "ENABLED_ACLS")
[ "$ENABLED_DEFAULT_ACL" != "1" ] && [ "$ENABLED_ACLS" != "1" ] && return
@@ -1604,7 +1604,7 @@ acl_app() {
echolog " - 全局节点未启用,跳过【${remarks}"
fi
else
[ "$(config_get_type $tcp_node)" = "nodes" ] || [ "$(config_get_type ${tcp_node#Socks_})" = "socks" ] && {
[ "$(config_get_type $tcp_node)" = "nodes" ] || [ "$(config_get_type $tcp_node)" = "socks" ] && {
if [ -n "${GLOBAL_TCP_NODE}" ] && [ "$tcp_node" = "${GLOBAL_TCP_NODE}" ]; then
set_cache_var "ACL_${sid}_tcp_node" "${GLOBAL_TCP_NODE}"
set_cache_var "ACL_${sid}_tcp_redir_port" "${GLOBAL_TCP_redir_port}"
@@ -1613,7 +1613,7 @@ acl_app() {
[ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1
else
local type protocol
if [ "$(config_get_type ${tcp_node#Socks_})" = "socks" ]; then
if [ "$(config_get_type $tcp_node)" = "socks" ]; then
if [ "${dns_mode}" = "xray" ]; then
type="xray"
elif [ "${dns_mode}" = "sing-box" ]; then
@@ -1800,7 +1800,7 @@ acl_app() {
set_cache_var "ACL_${sid}_udp_node" "${udp_node}"
set_cache_var "ACL_${sid}_udp_redir_port" "${udp_port}"
else
[ "$(config_get_type $udp_node)" = "nodes" ] || [ "$(config_get_type ${udp_node#Socks_})" = "socks" ] && {
[ "$(config_get_type $udp_node)" = "nodes" ] || [ "$(config_get_type $udp_node)" = "socks" ] && {
if [ -n "${GLOBAL_UDP_NODE}" ] && [ "$udp_node" = "${GLOBAL_UDP_NODE}" ]; then
set_cache_var "ACL_${sid}_udp_node" "${GLOBAL_UDP_NODE}"
set_cache_var "ACL_${sid}_udp_redir_port" "${GLOBAL_UDP_redir_port}"
@@ -1821,7 +1821,7 @@ acl_app() {
[ "${log}" = "1" ] && log_file="${TMP_ACL_PATH}/${sid}/UDP.log"
local type
if [ "$(config_get_type ${udp_node#Socks_})" = "socks" ]; then
if [ "$(config_get_type $udp_node)" = "socks" ]; then
if [ "${dns_mode}" = "xray" ]; then
type="xray"
elif [ "${dns_mode}" = "sing-box" ]; then
@@ -1997,10 +1997,9 @@ get_config() {
[ "$ENABLED" = 1 ] && {
local _node
for _node in "$TCP_NODE" "$UDP_NODE"; do
[ -n "$_node" ] && case "$_node" in
Socks_*) [ "$(config_get_type "${_node#Socks_}")" = "socks" ] && ENABLED_DEFAULT_ACL=1 ;;
*) [ "$(config_get_type "$_node")" = "nodes" ] && ENABLED_DEFAULT_ACL=1 ;;
esac
if [ -n "$_node" ] && ([ "$(config_get_type $_node)" = "nodes" ] || [ "$(config_get_type $_node)" = "socks" ]); then
ENABLED_DEFAULT_ACL=1
fi
done
}
ENABLED_ACLS=$(config_t_get global acl_enable 0)
@@ -142,8 +142,8 @@ test_auto_switch() {
local b_nodes=$1
local now_node=$2
[ -z "$now_node" ] && {
if [ -n "$(get_cache_var "socks_${id}")" ]; then
now_node=$(get_cache_var "socks_${id}")
if [ -n "$(get_cache_var "${id}")" ]; then
now_node=$(get_cache_var "${id}")
else
#echolog "Socks切换检测:未知错误"
return 1
@@ -180,10 +180,10 @@ do
local flag = "Socks节点列表[" .. i .. "]备用节点的列表"
local currentNodes = {}
local newNodes = {}
for k, node_id in ipairs(t.autoswitch_backup_node) do
if node_id then
local currentNode = uci:get_all(appname, node_id) or nil
if currentNode then
for k, asb_node in ipairs(t.autoswitch_backup_node) do
if asb_node then
local currentNode = uci:get_all(appname, asb_node) or {}
if currentNode[".type"] == "nodes" then
currentNodes[#currentNodes + 1] = {
log = true,
remarks = flag .. "[" .. k .. "]",
@@ -291,17 +291,20 @@ do
for k, e in pairs(rules) do
local _node_id = node[e[".name"]] or nil
if _node_id and not _node_id:find("Socks_") then
CONFIG[#CONFIG + 1] = {
log = false,
currentNode = _node_id and uci:get_all(appname, _node_id) or nil,
remarks = "分流" .. e.remarks .. "节点",
set = function(o, server)
if not server then server = "" end
uci:set(appname, node_id, e[".name"], server)
o.newNodeId = server
end
}
if _node_id then
local section = uci:get_all(appname, _node_id) or {}
if section[".type"] == "nodes" then
CONFIG[#CONFIG + 1] = {
log = false,
currentNode = section,
remarks = "分流" .. e.remarks .. "节点",
set = function(o, server)
if not server then server = "" end
uci:set(appname, node_id, e[".name"], server)
o.newNodeId = server
end
}
end
end
end
elseif node.protocol and node.protocol == '_balancing' then
@@ -309,17 +312,18 @@ do
local currentNodes = {}
local newNodes = {}
if node.balancing_node then
for k, node in pairs(node.balancing_node) do
for k, b_node_id in pairs(node.balancing_node) do
currentNodes[#currentNodes + 1] = {
log = true,
node = node,
node = b_node_id,
currentNode = (function()
if node and node:find("Socks_") then
return { Socks = node }
local section = uci:get_all(appname, b_node_id) or {}
if section[".type"] == "socks" then
return { Socks = b_node_id }
end
return node and uci:get_all(appname, node) or nil
return section
end)(),
remarks = node,
remarks = b_node_id,
set = function(o, server)
if o and server and server ~= "nil" then
table.insert(o.newNodes, server)
@@ -342,37 +346,41 @@ do
--后备节点
local currentNode = uci:get_all(appname, node_id) or nil
if currentNode and currentNode.fallback_node and not currentNode.fallback_node:find("Socks_") then
CONFIG[#CONFIG + 1] = {
log = true,
id = node_id,
remarks = "Xray负载均衡节点[" .. node_id .. "]后备节点",
currentNode = uci:get_all(appname, currentNode.fallback_node) or nil,
set = function(o, server)
uci:set(appname, node_id, "fallback_node", server)
o.newNodeId = server
end,
delete = function(o)
uci:delete(appname, node_id, "fallback_node")
end
}
if currentNode and currentNode.fallback_node then
local section = uci:get_all(appname, currentNode.fallback_node) or {}
if section[".type"] == "nodes" then
CONFIG[#CONFIG + 1] = {
log = true,
id = node_id,
remarks = "Xray负载均衡节点[" .. node_id .. "]后备节点",
currentNode = section,
set = function(o, server)
uci:set(appname, node_id, "fallback_node", server)
o.newNodeId = server
end,
delete = function(o)
uci:delete(appname, node_id, "fallback_node")
end
}
end
end
elseif node.protocol and node.protocol == '_urltest' then
local flag = "Sing-Box URLTest节点[" .. node_id .. "]列表"
local currentNodes = {}
local newNodes = {}
if node.urltest_node then
for k, node in pairs(node.urltest_node) do
for k, u_node_id in pairs(node.urltest_node) do
currentNodes[#currentNodes + 1] = {
log = true,
node = node,
node = u_node_id,
currentNode = (function()
if node and node:find("Socks_") then
return { Socks = node }
local section = uci:get_all(appname, u_node_id) or {}
if section[".type"] == "socks" then
return { Socks = u_node_id }
end
return node and uci:get_all(appname, node) or nil
return section
end)(),
remarks = node,
remarks = u_node_id,
set = function(o, server)
if o and server and server ~= "nil" then
table.insert(o.newNodes, server)
@@ -395,37 +403,43 @@ do
else
--前置代理节点
local currentNode = uci:get_all(appname, node_id) or nil
if currentNode and currentNode.preproxy_node and not currentNode.preproxy_node:find("Socks_") then
CONFIG[#CONFIG + 1] = {
log = true,
id = node_id,
remarks = "节点[" .. node_id .. "]前置代理节点",
currentNode = uci:get_all(appname, currentNode.preproxy_node) or nil,
set = function(o, server)
uci:set(appname, node_id, "preproxy_node", server)
o.newNodeId = server
end,
delete = function(o)
uci:delete(appname, node_id, "preproxy_node")
end
}
if currentNode and currentNode.preproxy_node then
local section = uci:get_all(appname, currentNode.preproxy_node) or {}
if section[".type"] == "nodes" then
CONFIG[#CONFIG + 1] = {
log = true,
id = node_id,
remarks = "节点[" .. node_id .. "]前置代理节点",
currentNode = uci:get_all(appname, currentNode.preproxy_node) or nil,
set = function(o, server)
uci:set(appname, node_id, "preproxy_node", server)
o.newNodeId = server
end,
delete = function(o)
uci:delete(appname, node_id, "preproxy_node")
end
}
end
end
--落地节点
local currentNode = uci:get_all(appname, node_id) or nil
if currentNode and currentNode.to_node and not currentNode.to_node:find("Socks_") then
CONFIG[#CONFIG + 1] = {
log = true,
id = node_id,
remarks = "节点[" .. node_id .. "]落地节点",
currentNode = uci:get_all(appname, currentNode.to_node) or nil,
set = function(o, server)
uci:set(appname, node_id, "to_node", server)
o.newNodeId = server
end,
delete = function(o)
uci:delete(appname, node_id, "to_node")
end
}
if currentNode and currentNode.to_node then
local section = uci:get_all(appname, currentNode.to_node) or {}
if section[".type"] == "nodes" then
CONFIG[#CONFIG + 1] = {
log = true,
id = node_id,
remarks = "节点[" .. node_id .. "]落地节点",
currentNode = uci:get_all(appname, currentNode.to_node) or nil,
set = function(o, server)
uci:set(appname, node_id, "to_node", server)
o.newNodeId = server
end,
delete = function(o)
uci:delete(appname, node_id, "to_node")
end
}
end
end
end
end)
@@ -508,13 +508,6 @@ ln_run() {
echo "${file_func:-echolog " - ${ln_name}"} $@ >${output}" > $TMP_SCRIPT_FUNC_PATH/$process_count
}
is_socks_wrap() {
case "$1" in
Socks_*) return 0 ;;
*) return 1 ;;
esac
}
kill_all() {
kill -9 $(pidof "$@") >/dev/null 2>&1
}
+1 -1
View File
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall2
PKG_VERSION:=26.8.7
PKG_RELEASE:=69
PKG_RELEASE:=70
PKG_PO_VERSION:=$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
@@ -329,7 +329,7 @@ end
function get_acl_log()
local id = http.formvalue("id")
local path = "/tmp/log/passwall2_acl_" .. id .. ".log"
local path = api.TMP_PATH .. "/acl/" .. id .. "/node.log"
if nixio.fs.access(path) then
local content = luci.sys.exec("tail -n 5000 '" .. path .. "'")
content = content:gsub("\n", "<br />")
@@ -46,6 +46,15 @@ sys.net.mac_hints(function(e, t)
}
end)
i = s:option(DummyValue, "interface", translate("Source Interface"))
i.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n) or ''
if v == "" then
return translate("All")
end
return v
end
o = s:option(DummyValue, "sources", translate("Source"))
o.rawhtml = true
o.cfgvalue = function(t, n)
@@ -64,10 +73,13 @@ o.cfgvalue = function(t, n)
return e
end
i = s:option(DummyValue, "interface", translate("Source Interface"))
i = s:option(DummyValue, "mode", translate("Mode"))
i.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n) or '-'
return v
local v = Value.cfgvalue(t, n) or '0'
if v == "1" then
return translate("Proxy")
end
return translate("No Proxy")
end
local sortable = Template(appname .. "/cbi/sortable")
@@ -78,33 +78,6 @@ o = s:option(Value, "remarks", translate("Remarks"))
o.default = arg[1]
o.rmempty = false
---- Log
o = s:option(Flag, "log", translate("Enable Log"))
o.default = 0
o.rmempty = false
o = s:option(ListValue, "loglevel", translate("Log Level"))
o.default = "warn"
o:value("debug", "Debug")
o:value("info", "Info")
o:value("warn", "Warning")
o:value("error", "Error")
o:depends("log", "1")
o = s:option(DummyValue, "_acl_log", translate("Log File"))
o.rawhtml = true
o.cfgvalue = function(t, n)
local log_path = "/tmp/log/passwall2_acl_" .. arg[1] .. ".log"
local log_url = api.url("get_acl_log") .. "?id=" .. arg[1]
return string.format(
'<code>%s</code>&nbsp;&nbsp;<input class="btn cbi-button cbi-button-apply" type="button" value="%s" onclick="window.open(\'%s\', \'_blank\')" />',
log_path,
translate("View Log"),
log_url
)
end
o:depends("log", "1")
o = s:option(Value, "interface", translate("Source Interface"))
o:value("", translate("All"))
local iface = api.get_network_devices()
@@ -205,28 +178,32 @@ sources.validate = function(self, value, t)
end
sources.write = dynamicList_write
o = s:option(ListValue, "mode", translate("Mode"))
o:value("0", translate("No Proxy"))
o:value("1", translate("Proxy"))
---- TCP No Redir Ports
local TCP_NO_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_no_redir_ports")
o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports"))
o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")")
o:value("disable", translate("No patterns are used"))
o:value("1:65535", translate("All"))
o:depends("mode", "1")
o.validate = port_validate
---- UDP No Redir Ports
local UDP_NO_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_no_redir_ports")
o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"),
"<font color='red'>" ..
translate("If you don't want to let the device in the list to go proxy, please choose all.") ..
"</font>")
o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"))
o:value("", translate("Use global config") .. "(" .. UDP_NO_REDIR_PORTS .. ")")
o:value("disable", translate("No patterns are used"))
o:value("1:65535", translate("All"))
o:depends("mode", "1")
o.validate = port_validate
o = s:option(DummyValue, "_hide_node_option", "")
o.template = "passwall2/cbi/hidevalue"
o.value = "1"
o:depends("mode", "0")
o:depends({ tcp_no_redir_ports = "1:65535", udp_no_redir_ports = "1:65535" })
if TCP_NO_REDIR_PORTS == "1:65535" and UDP_NO_REDIR_PORTS == "1:65535" then
o:depends({ tcp_no_redir_ports = "", udp_no_redir_ports = "" })
@@ -250,13 +227,30 @@ if not current_node_id then
end
current_node = current_node_id and m.uci:get_all(appname, current_node_id) or {}
o = s:option(DummyValue, "_hide_dns_option", "")
o.template = "passwall2/cbi/hidevalue"
o.value = "1"
o:depends({ node = "" })
if GLOBAL_ENABLED == "1" and NODE then
o:depends({ node = NODE })
o = s:option(Flag, "log", translate("Enable Node Log"))
o:depends({ _hide_node_option = "1", ['!reverse'] = true })
o = s:option(ListValue, "loglevel", translate("Log Level"))
o.default = "warn"
o:value("debug", "Debug")
o:value("info", "Info")
o:value("warn", "Warning")
o:value("error", "Error")
o:depends("log", "1")
o = s:option(DummyValue, "_acl_log", translate("Log File"))
o.rawhtml = true
o.cfgvalue = function(t, n)
local log_path = api.TMP_PATH .. "/acl/" .. arg[1] .. "/node.log"
local log_url = api.url("get_acl_log") .. "?id=" .. arg[1]
return string.format(
'<code>%s</code>&nbsp;&nbsp;<input class="btn cbi-button cbi-button-apply" type="button" value="%s" onclick="window.open(\'%s\', \'_blank\')" />',
log_path,
translate("View Log"),
log_url
)
end
o:depends("log", "1")
---- TCP Redir Ports
local TCP_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_redir_ports")
@@ -282,6 +276,15 @@ o.cfgvalue = function(t, n)
return string.format('<font color="red">%s</font>',
translate("The port settings support single ports and ranges.<br>Separate multiple ports with commas (,).<br>Example: 21,80,443,1000:2000."))
end
o:depends({ _hide_node_option = "1", ['!reverse'] = true })
o = s:option(DummyValue, "_hide_dns_option", "")
o.template = "passwall2/cbi/hidevalue"
o.value = "1"
o:depends({ node = "" })
if GLOBAL_ENABLED == "1" and NODE then
o:depends({ node = NODE })
end
o = s:option(ListValue, "direct_dns_query_strategy", translate("Direct Query Strategy"))
o.default = "UseIP"
@@ -377,6 +380,7 @@ o = s:option(ListValue, "dns_hosts_mode", translate("Domain Override"))
o:value("default", translate("Use global config"))
o:value("disable", translate("No patterns are used"))
o:value("custom", translate("-- custom --"))
o:depends({ _hide_dns_option = "1", ['!reverse'] = true })
o = s:option(TextValue, "dns_hosts", translate("Domain Override"))
o.rows = 5
@@ -287,12 +287,26 @@ o.default = "1"
o.rmempty = false
loglevel = s:taboption("log", ListValue, "loglevel", translate("Log Level"))
loglevel.default = "warning"
loglevel.default = "warn"
loglevel:value("debug")
loglevel:value("info")
loglevel:value("warning")
loglevel:value("warn")
loglevel:value("error")
o = s:taboption("log", DummyValue, "_log", translate("Log File"))
o.rawhtml = true
o.cfgvalue = function(t, n)
local log_path = api.TMP_PATH .. "/acl/default/global.log"
local log_url = api.url("get_redir_log") .. "?id=default&name=global"
return string.format(
'<code>%s</code>&nbsp;&nbsp;<input class="btn cbi-button cbi-button-apply" type="button" value="%s" onclick="window.open(\'%s\', \'_blank\')" />',
log_path,
translate("View Log"),
log_url
)
end
o:depends("log_node", "1")
s:tab("faq", "FAQ")
o = s:taboption("faq", DummyValue, "")
@@ -574,6 +574,9 @@ o.validate = function(self, value)
return value
end
o = s:option(Value, _n("cipherSuites"), translate("Cipher Suites"), '<a href="https://go.dev/src/crypto/tls/cipher_suites.go#L44" target="_blank">***</a>' .. " " .. translate("Configures the list of supported cipher suites, separated by :"))
o:depends({ [_n("tls")] = true })
o = s:option(Flag, _n("ech"), translate("ECH"))
o.default = "0"
o:depends({ [_n("tls")] = true, [_n("flow")] = "", [_n("reality")] = false })
@@ -91,6 +91,11 @@ local function convert_geofile()
convert(GEO_VAR.IP_PATH, "geoip", GEO_VAR.IP_TAGS)
end
local function get_log_level(s)
if s == "warning" then s = "warn" end
return s
end
function parseDNS(str)
local result_dns_server
-- [proto]://[ip]
@@ -256,6 +261,7 @@ function gen_outbound(flag, node, tag, proxy_table)
fragment = fragment,
record_fragment = record_fragment,
certificate = (node.tls_certificate == "1" and node.tls_certificate_pem ~= "") and split(node.tls_certificate_pem, "\n") or nil,
cipher_suites = node.cipherSuites or nil,
ech = (node.ech == "1") and (function()
local function get_ech_domain(s) --兼容xray "域名+DNS" 格式ech
local domain, dns = s:match("^([^+]+)%+(.+)$")
@@ -1072,7 +1078,7 @@ function gen_config_server(node)
local config = {
log = {
disabled = (not node or node.log == "0") and true or false,
level = node.loglevel or "info",
level = get_log_level(node.loglevel) or "info",
timestamp = true,
--output = logfile,
},
@@ -2160,7 +2166,7 @@ function gen_config(var)
local config = {
log = {
disabled = log == "0" and true or false,
level = loglevel,
level = get_log_level(loglevel),
timestamp = true,
output = logfile,
},
@@ -31,6 +31,11 @@ local function get_domain_excluded()
return hosts
end
local function get_log_level(s)
if s == "warn" then s = "warning" end
return s
end
function parseDNS(str)
local result_dns_server
-- [proto]://[ip]
@@ -657,7 +662,7 @@ function gen_config_server(node)
local config = {
log = {
loglevel = ("1" == node.log) and node.loglevel or "none"
loglevel = ("1" == node.log) and get_log_level(node.loglevel) or "none"
},
inbounds = {
{
@@ -1981,7 +1986,7 @@ function gen_config(var)
--access = string.format("/tmp/etc/%s/%s_access.log", appname, "global"),
--error = string.format("/tmp/etc/%s/%s_error.log", appname, "global"),
--dnsLog = true,
loglevel = loglevel
loglevel = get_log_level(loglevel)
},
dns = dns,
fakedns = fakedns,
+9
View File
@@ -1507,6 +1507,12 @@ msgstr "فعال‌سازی گزارش گره"
msgid "Log Level"
msgstr "سطح گزارش"
msgid "Log File"
msgstr "فایل لاگ"
msgid "View Log"
msgstr "مشاهده گزارش"
msgid "Not enabled log"
msgstr "گزارش فعال نیست"
@@ -2381,6 +2387,9 @@ msgstr "گره [%s] با موفقیت حل شد، تعداد: %s"
msgid "Get subscription content for [%s] is empty. This may be due to an invalid subscription address or a network problem. Please diagnose the issue!"
msgstr "دریافت محتوای اشتراک برای [%s] خالی است. این ممکن است به دلیل آدرس اشتراک نامعتبر یا مشکل شبکه باشد. لطفاً مشکل را بررسی کنید!"
msgid "No Proxy"
msgstr "بدون پروکسی"
msgid "Proxy"
msgstr "پروکسی"
+9
View File
@@ -1508,6 +1508,12 @@ msgstr "Запись журнала"
msgid "Log Level"
msgstr "Уровень записи журнала"
msgid "Log File"
msgstr "Файл журнала"
msgid "View Log"
msgstr "Просмотреть журнал"
msgid "Not enabled log"
msgstr "Запись журнала отключена"
@@ -2379,6 +2385,9 @@ msgstr "Успешно разобран [%s], количество узлов: %
msgid "Get subscription content for [%s] is empty. This may be due to an invalid subscription address or a network problem. Please diagnose the issue!"
msgstr "Содержимое подписки [%s] пусто. Возможно, адрес подписки неверен или есть проблема с сетью. Пожалуйста, проведите диагностику!"
msgid "No Proxy"
msgstr "Без прокси"
msgid "Proxy"
msgstr "Прокси"
+9
View File
@@ -1499,6 +1499,12 @@ msgstr "启用节点日志"
msgid "Log Level"
msgstr "日志等级"
msgid "Log File"
msgstr "日志文件"
msgid "View Log"
msgstr "查看日志"
msgid "Not enabled log"
msgstr "未启用日志"
@@ -2367,6 +2373,9 @@ msgstr "成功解析【%s】节点,数量:%s"
msgid "Get subscription content for [%s] is empty. This may be due to an invalid subscription address or a network problem. Please diagnose the issue!"
msgstr "获取到的【%s】订阅内容为空,可能是订阅地址无效,或是网络问题,请诊断!"
msgid "No Proxy"
msgstr "不代理"
msgid "Proxy"
msgstr "代理"
+9
View File
@@ -1499,6 +1499,12 @@ msgstr "啟用節點日誌"
msgid "Log Level"
msgstr "日誌等級"
msgid "Log File"
msgstr "日誌檔案"
msgid "View Log"
msgstr "查看日誌"
msgid "Not enabled log"
msgstr "未啟用日誌"
@@ -2373,6 +2379,9 @@ msgstr "成功解析【%s】節點,數量:%s"
msgid "Get subscription content for [%s] is empty. This may be due to an invalid subscription address or a network problem. Please diagnose the issue!"
msgstr "獲取到的【%s】訂閱內容為空,可能是訂閱地址無效,或是網絡問題,請診斷!"
msgid "No Proxy"
msgstr "不代理"
msgid "Proxy"
msgstr "代理"
@@ -209,7 +209,6 @@ run_singbox() {
node_protocol=$(config_n_get $node protocol)
[ -n "$log_file" ] || local log_file="/dev/null"
[ -z "$loglevel" ] && local loglevel=$(config_t_get global loglevel "warn")
[ "$loglevel" = "warning" ] && loglevel="warn"
local singbox_tag=$($SINGBOX_BIN version | grep 'Tags:' | awk '{print $2}')
json_init
@@ -413,7 +412,6 @@ run_socks() {
}
[ "${log_file}" != "/dev/null" ] && {
local loglevel=$(config_t_get global loglevel "warn")
[ "$loglevel" = "warning" ] && loglevel="warn"
json_add_string "log" "1"
json_add_string "loglevel" "${loglevel}"
json_add_string "logfile" "${log_file}"
@@ -440,6 +438,11 @@ run_socks() {
json_add_null "server_host"
json_add_null "server_port"
}
[ "${log_file}" != "/dev/null" ] && {
local loglevel=$(config_t_get global loglevel "warn")
json_add_string "log" "1"
json_add_string "loglevel" "${loglevel}"
}
[ -n "$no_run" ] && json_add_string "no_run" "1"
json_add_string "flag" "${flag}"
json_add_string "local_socks_address" "${bind}"
@@ -1029,10 +1032,6 @@ acl_app() {
[ "$(config_n_get $sid enabled)" = "1" ] || continue
has_enabled=1
eval $(uci -q show "${CONFIG}.${sid}" | cut -d'.' -sf 3-)
log=${log:-0}
loglevel=${loglevel:-warn}
log_file="/dev/null"
[ "${log}" = "1" ] && log_file="/tmp/log/passwall2_acl_${sid}.log"
if [ -n "${sources}" ]; then
for s in $sources; do
@@ -1061,6 +1060,11 @@ acl_app() {
mkdir -p ${acl_path}
[ -n "${source_list}" ] && echo -e "${source_list}" | sed '/^$/d' > ${acl_path}/source_list
log=${log:-0}
loglevel=${loglevel:-warn}
log_file="/dev/null"
[ "${log}" = "1" ] && log_file="${acl_path}/node.log"
node=${node:-default}
tcp_no_redir_ports=${tcp_no_redir_ports:-default}
udp_no_redir_ports=${udp_no_redir_ports:-default}
@@ -261,6 +261,7 @@ load_acl() {
for sid in $(ls -F ${TMP_ACL_PATH} | grep '/$' | awk -F '/' '{print $1}' | grep -v 'default'); do
eval $(uci -q show "${CONFIG}.${sid}" | cut -d'.' -sf 3-)
mode=${mode:-0}
tcp_no_redir_ports=${tcp_no_redir_ports:-default}
udp_no_redir_ports=${udp_no_redir_ports:-default}
tcp_proxy_mode="global"
@@ -268,6 +269,10 @@ load_acl() {
tcp_redir_ports=${tcp_redir_ports:-default}
udp_redir_ports=${udp_redir_ports:-default}
node=${node:-default}
[ "$mode" = "0" ] && {
tcp_no_redir_ports="1:65535"
udp_no_redir_ports="1:65535"
}
[ "$tcp_no_redir_ports" = "default" ] && tcp_no_redir_ports=$TCP_NO_REDIR_PORTS
[ "$udp_no_redir_ports" = "default" ] && udp_no_redir_ports=$UDP_NO_REDIR_PORTS
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
@@ -299,6 +299,7 @@ load_acl() {
for sid in $(ls -F ${TMP_ACL_PATH} | grep '/$' | awk -F '/' '{print $1}' | grep -v 'default'); do
eval $(uci -q show "${CONFIG}.${sid}" | cut -d'.' -sf 3-)
mode=${mode:-0}
tcp_no_redir_ports=${tcp_no_redir_ports:-default}
udp_no_redir_ports=${udp_no_redir_ports:-default}
tcp_proxy_mode="global"
@@ -306,6 +307,10 @@ load_acl() {
tcp_redir_ports=${tcp_redir_ports:-default}
udp_redir_ports=${udp_redir_ports:-default}
node=${node:-default}
[ "$mode" = "0" ] && {
tcp_no_redir_ports="1:65535"
udp_no_redir_ports="1:65535"
}
[ "$tcp_no_redir_ports" = "default" ] && tcp_no_redir_ports=$TCP_NO_REDIR_PORTS
[ "$udp_no_redir_ports" = "default" ] && udp_no_redir_ports=$UDP_NO_REDIR_PORTS
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
@@ -168,9 +168,9 @@ do
local flag = i18n.translatef("Socks node list [%s]", i) .. " " .. i18n.translatef("Backup node list")
local currentNodes = {}
local newNodes = {}
for k, asb_node in ipairs(t.autoswitch_backup_node) do
if asb_node then
local currentNode = uci:get_all(appname, asb_node) or {}
for k, asb_node_id in ipairs(t.autoswitch_backup_node) do
if asb_node_id then
local currentNode = uci:get_all(appname, asb_node_id) or {}
if currentNode[".type"] == "nodes" then
currentNodes[#currentNodes + 1] = {
log = true,
@@ -277,7 +277,7 @@ do
for k, e in pairs(rules) do
local _node_id = node[e[".name"]] or nil
if _node_id then
local section = uci:get_all(appname, node_id) or {}
local section = uci:get_all(appname, _node_id) or {}
if section[".type"] == "nodes" then
CONFIG[#CONFIG + 1] = {
log = false,