From 3cb04f969ca85a9029dc6635ccefbe42523d2fb0 Mon Sep 17 00:00:00 2001 From: action Date: Fri, 22 May 2026 22:28:32 +0800 Subject: [PATCH] update 2026-05-22 22:28:32 --- .../model/cbi/shadowsocksr/client-config.lua | 55 +++++++++---------- .../luasrc/model/cbi/shadowsocksr/servers.lua | 20 ++++--- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua index 7f108542..76f8a6e9 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua @@ -254,60 +254,55 @@ local tls_flows = { "none" } ---[[ local function migrate_xray_protocol_nodes() local changed = false uci:foreach("shadowsocksr", "servers", function(section) - if section.type == "ss" or section.type == "ss-libev" then + local sid = section[".name"] + local stype = section.type + local proto = section.v2ray_protocol + local escaped_sid = luci.util.shellquote(sid) + + if stype == "ss" or stype == "ss-libev" then if has_mihomo then - uci:set("shadowsocksr", section[".name"], "type", "ss") + luci.sys.call(string.format("uci set shadowsocksr.%s.type='ss'", escaped_sid)) changed = true elseif has_ss_rust then - uci:set("shadowsocksr", section[".name"], "type", "ss-rust") + luci.sys.call(string.format("uci set shadowsocksr.%s.type='ss-rust'", escaped_sid)) changed = true elseif has_xray then - uci:set("shadowsocksr", section[".name"], "type", "v2ray") - uci:set("shadowsocksr", section[".name"], "v2ray_protocol", "shadowsocks") + luci.sys.call(string.format("uci set shadowsocksr.%s.type='v2ray' && " .. "uci set shadowsocksr.%s.v2ray_protocol='shadowsocks'", escaped_sid, escaped_sid)) changed = true end - elseif section.type == "v2ray" and section.v2ray_protocol == "shadowsocks" and has_mihomo then - uci:set("shadowsocksr", section[".name"], "type", "ss") - uci:delete("shadowsocksr", section[".name"], "v2ray_protocol") + elseif stype == "v2ray" and proto == "shadowsocks" and has_mihomo then + luci.sys.call(string.format("uci set shadowsocksr.%s.type='ss' && " .. "uci delete shadowsocksr.%s.v2ray_protocol", escaped_sid, escaped_sid)) changed = true end - if section.type == "hysteria2" then - uci:set("shadowsocksr", section[".name"], "type", "v2ray") - uci:set("shadowsocksr", section[".name"], "v2ray_protocol", "hysteria2") + if stype == "hysteria2" then + luci.sys.call(string.format("uci set shadowsocksr.%s.type='v2ray' && " .. "uci set shadowsocksr.%s.v2ray_protocol='hysteria2'", escaped_sid, escaped_sid)) changed = true - elseif section.type == "trojan" then - uci:set("shadowsocksr", section[".name"], "type", "v2ray") - uci:set("shadowsocksr", section[".name"], "v2ray_protocol", "trojan") + elseif stype == "trojan" then + luci.sys.call(string.format("uci set shadowsocksr.%s.type='v2ray' && " .. "uci set shadowsocksr.%s.v2ray_protocol='trojan'", escaped_sid, escaped_sid)) changed = true end end) - local subscribe_sid = uci:get_first("shadowsocksr", "server_subscribe") - if subscribe_sid and uci:get("shadowsocksr", subscribe_sid, "xray_hy2_type") then - uci:delete("shadowsocksr", subscribe_sid, "xray_hy2_type") - changed = true + if subscribe_sid then + local old_options = {"xray_hy2_type", "xray_tj_type", "ss_type"} + local escaped_sub_sid = luci.util.shellquote(subscribe_sid) + for _, opt in ipairs(old_options) do + if uci:get("shadowsocksr", subscribe_sid, opt) then + luci.sys.call(string.format("uci delete shadowsocksr.%s.%s", escaped_sub_sid, opt)) + changed = true + end + end end - if subscribe_sid and uci:get("shadowsocksr", subscribe_sid, "xray_tj_type") then - uci:delete("shadowsocksr", subscribe_sid, "xray_tj_type") - changed = true - end - if subscribe_sid and uci:get("shadowsocksr", subscribe_sid, "ss_type") then - uci:delete("shadowsocksr", subscribe_sid, "ss_type") - changed = true - end - if changed then - uci:commit("shadowsocksr") + luci.sys.call("uci commit shadowsocksr") end end migrate_xray_protocol_nodes() -]]-- m = Map("shadowsocksr", translate("Edit ShadowSocksR Server")) m.redirect = url("servers") diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua index 1c9c2e8f..8fa3f19e 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua @@ -321,18 +321,22 @@ local function migrate_legacy_subscribe_urls() for index, url in ipairs(legacy_urls) do local trimmed = trim(url) if trimmed ~= "" then - local sid = uci:add("shadowsocksr", "server_subscribe_item") - if sid then - uci:set("shadowsocksr", sid, "enabled", "1") - uci:set("shadowsocksr", sid, "alias", string.format("Subscribe %d", index)) - uci:set("shadowsocksr", sid, "url", trimmed) + local sid_output = luci.sys.exec("uci add shadowsocksr server_subscribe_item") + local sid = sid_output:match("%S+") + if sid and sid ~= "" then + local escaped_sid = luci.util.shellquote(sid) + local alias = string.format("Subscribe %d", index) + local escaped_alias = luci.util.shellquote(alias) + local escaped_url = luci.util.shellquote(trimmed) + luci.sys.call("uci set shadowsocksr." .. escaped_sid .. ".enabled=1") + luci.sys.call("uci set shadowsocksr." .. escaped_sid .. ".alias=" .. escaped_alias) + luci.sys.call("uci set shadowsocksr." .. escaped_sid .. ".url=" .. escaped_url) end end end - uci:delete("shadowsocksr", subscribe_sid, "subscribe_url") - uci:save("shadowsocksr") - uci:commit("shadowsocksr") + luci.sys.call("uci delete shadowsocksr." .. subscribe_sid .. ".subscribe_url") + luci.sys.call("uci commit shadowsocksr") end local function clash_host_port(clash_url)