🎨 Sync 2026-03-10 23:48:22

This commit is contained in:
github-actions[bot] committed 2026-03-10 23:48:22 +08:00
1 parent 29f8468189
commit d37e092fac
2 files changed
+22 -52

No files matched your search

+10
View File
@@ -1521,3 +1521,13 @@ function get_core(field, candidates)
end end
return nil return nil
end end
function cleanEmptyTables(t)
if type(t) ~= "table" then return nil end
for k, v in pairs(t) do
if type(v) == "table" then
t[k] = cleanEmptyTables(v)
end
end
return next(t) and t or nil
end
+12 -52
View File
@@ -241,31 +241,21 @@ function gen_outbound(flag, node, tag, proxy_table)
path = node.xhttp_path or "/", path = node.xhttp_path or "/",
host = node.xhttp_host, host = node.xhttp_host,
extra = (function() extra = (function()
local extra_tbl = {} local extra = {}
-- 解析 xhttp_extra 并做简单容错处理
if node.xhttp_extra then if node.xhttp_extra then
local success, parsed = pcall(jsonc.parse, api.base64Decode(node.xhttp_extra)) local ok, parsed = pcall(jsonc.parse, api.base64Decode(node.xhttp_extra))
if success and parsed then if ok and type(parsed) == "table" then
extra_tbl = parsed.extra or parsed extra = parsed.extra or parsed
for k, v in pairs(extra_tbl) do
if (type(v) == "table" and next(v) == nil) or v == nil then
extra_tbl[k] = nil
end
end
end end
end end
-- 处理 User-Agent -- 处理 User-Agent
if node.user_agent and node.user_agent ~= "" then if node.user_agent and node.user_agent ~= "" then
extra_tbl.headers = extra_tbl.headers or {} extra.headers = extra.headers or {}
if not extra_tbl.headers["User-Agent"] and not extra_tbl.headers["user-agent"] then if not extra.headers["User-Agent"] and not extra.headers["user-agent"] then
extra_tbl.headers["User-Agent"] = node.user_agent extra.headers["User-Agent"] = node.user_agent
end end
end end
-- 清理空的 headers return api.cleanEmptyTables(extra)
if extra_tbl.headers and next(extra_tbl.headers) == nil then
extra_tbl.headers = nil
end
return next(extra_tbl) ~= nil and extra_tbl or nil
end)() end)()
} or nil, } or nil,
hysteriaSettings = (node.transport == "hysteria") and { hysteriaSettings = (node.transport == "hysteria") and {
@@ -322,25 +312,10 @@ function gen_outbound(flag, node, tag, proxy_table)
if node.finalmask and node.finalmask ~= "" then if node.finalmask and node.finalmask ~= "" then
local ok, fm = pcall(jsonc.parse, api.base64Decode(node.finalmask)) local ok, fm = pcall(jsonc.parse, api.base64Decode(node.finalmask))
if ok and type(fm) == "table" then if ok and type(fm) == "table" then
if not finalmask or not next(finalmask) then finalmask = fm
finalmask = fm
else
if type(fm.udp) == "table" then
finalmask.udp = finalmask.udp or {}
for i = 1, #fm.udp do
finalmask.udp[#finalmask.udp+1] = fm.udp[i]
end
end
if type(fm.tcp) == "table" then
finalmask.tcp = fm.tcp
end
if type(fm.quicParams) == "table" then
finalmask.quicParams = fm.quicParams
end
end
end end
end end
return (finalmask and next(finalmask)) and finalmask or nil return api.cleanEmptyTables(finalmask)
end)() end)()
} or nil, } or nil,
settings = { settings = {
@@ -649,25 +624,10 @@ function gen_config_server(node)
if node.finalmask and node.finalmask ~= "" then if node.finalmask and node.finalmask ~= "" then
local ok, fm = pcall(jsonc.parse, api.base64Decode(node.finalmask)) local ok, fm = pcall(jsonc.parse, api.base64Decode(node.finalmask))
if ok and type(fm) == "table" then if ok and type(fm) == "table" then
if not finalmask or not next(finalmask) then finalmask = fm
finalmask = fm
else
if type(fm.udp) == "table" then
finalmask.udp = finalmask.udp or {}
for i = 1, #fm.udp do
finalmask.udp[#finalmask.udp+1] = fm.udp[i]
end
end
if type(fm.tcp) == "table" then
finalmask.tcp = fm.tcp
end
if type(fm.quicParams) == "table" then
finalmask.quicParams = fm.quicParams
end
end
end end
end end
return (finalmask and next(finalmask)) and finalmask or nil return api.cleanEmptyTables(finalmask)
end)(), end)(),
sockopt = { sockopt = {
tcpFastOpen = (node.tcp_fast_open == "1") and true or nil, tcpFastOpen = (node.tcp_fast_open == "1") and true or nil,