diff --git a/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall b/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall index fb77b72a..e0c8277b 100644 --- a/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall +++ b/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall @@ -12,7 +12,7 @@ if [ "$ACTION" = "ifupdate" ]; then USE_TABLES=$(get_cache_var "USE_TABLES") - [ -n "$USE_TABLES" ] && ${APP_PATH}/${USE_TABLES}.sh update_wan_sets >/dev/null 2>&1 & + [ -n "$USE_TABLES" ] && { ${APP_PATH}/${USE_TABLES}.sh update_wan_sets >/dev/null 2>&1 & } exit 0 fi diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index d29cf2d3..679a8f51 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -1101,7 +1101,7 @@ start_crontab() { if [ "$ENABLED_DEFAULT_ACL" = "1" ] || [ "$ENABLED_ACLS" = "1" ]; then local start_daemon=$(config_t_get global_delay start_daemon 0) - [ "$start_daemon" = "1" ] && { $APP_PATH/monitor.sh >/dev/null 2>&1 & } + [ "$start_daemon" = "1" ] && { $APP_PATH/monitor.sh > /dev/null 2>&1 & } fi if [ -f "${LOCK_PATH}/${CONFIG}_cron.lock" ]; then @@ -1194,7 +1194,7 @@ start_crontab() { # ===== loop ===== if [ "$ENABLED_DEFAULT_ACL" = "1" ] || [ "$ENABLED_ACLS" = "1" ]; then if [ "$update_loop" = "1" ]; then - $APP_PATH/tasks.sh >/dev/null 2>&1 & + $APP_PATH/tasks.sh > /dev/null 2>&1 & echolog "自动更新:启动循环更新进程。" fi else diff --git a/luci-app-passwall/root/usr/share/passwall/tasks.sh b/luci-app-passwall/root/usr/share/passwall/tasks.sh index 3cfc5444..564caee4 100755 --- a/luci-app-passwall/root/usr/share/passwall/tasks.sh +++ b/luci-app-passwall/root/usr/share/passwall/tasks.sh @@ -23,7 +23,7 @@ do stop_interval_mode=$(expr "$stop_interval_mode" \* 60) if [ -n "$stop_week_mode" ]; then [ "$stop_week_mode" = "8" ] && { - [ "$(expr "$CFG_UPDATE_INT" % "$stop_interval_mode")" -eq 0 ] && /etc/init.d/$CONFIG stop > /dev/null 2>&1 & + [ "$(expr "$CFG_UPDATE_INT" % "$stop_interval_mode")" -eq 0 ] && { /etc/init.d/$CONFIG stop > /dev/null 2>&1 & } } fi @@ -32,7 +32,7 @@ do start_interval_mode=$(expr "$start_interval_mode" \* 60) if [ -n "$start_week_mode" ]; then [ "$start_week_mode" = "8" ] && { - [ "$(expr "$CFG_UPDATE_INT" % "$start_interval_mode")" -eq 0 ] && /etc/init.d/$CONFIG start > /dev/null 2>&1 & + [ "$(expr "$CFG_UPDATE_INT" % "$start_interval_mode")" -eq 0 ] && { /etc/init.d/$CONFIG start > /dev/null 2>&1 & } } fi @@ -41,7 +41,7 @@ do restart_interval_mode=$(expr "$restart_interval_mode" \* 60) if [ -n "$restart_week_mode" ]; then [ "$restart_week_mode" = "8" ] && { - [ "$(expr "$CFG_UPDATE_INT" % "$restart_interval_mode")" -eq 0 ] && /etc/init.d/$CONFIG restart > /dev/null 2>&1 & + [ "$(expr "$CFG_UPDATE_INT" % "$restart_interval_mode")" -eq 0 ] && { /etc/init.d/$CONFIG restart > /dev/null 2>&1 & } } fi @@ -51,7 +51,7 @@ do hourupdate=$(expr "$hourupdate" \* 60) if [ "$autoupdate" = "1" ]; then [ "$weekupdate" = "8" ] && { - [ "$(expr "$CFG_UPDATE_INT" % "$hourupdate")" -eq 0 ] && lua $APP_PATH/rule_update.lua log all cron > /dev/null 2>&1 & + [ "$(expr "$CFG_UPDATE_INT" % "$hourupdate")" -eq 0 ] && { lua $APP_PATH/rule_update.lua log all cron > /dev/null 2>&1 & } } fi @@ -74,7 +74,7 @@ do hour_update=$(expr "$hour_update" \* 60) cfgids=$(echo -n $(cat ${TMP_SUB_PATH}/${name}) | sed 's# #,#g') [ "$week_update" = "8" ] && { - [ "$(expr "$CFG_UPDATE_INT" % "$hour_update")" -eq 0 ] && lua $APP_PATH/subscribe.lua start $cfgids cron > /dev/null 2>&1 & + [ "$(expr "$CFG_UPDATE_INT" % "$hour_update")" -eq 0 ] && { lua $APP_PATH/subscribe.lua start $cfgids cron > /dev/null 2>&1 & } } done 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 9ddcabbc..7f108542 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,6 +254,7 @@ local tls_flows = { "none" } +--[[ local function migrate_xray_protocol_nodes() local changed = false @@ -306,6 +307,7 @@ local function migrate_xray_protocol_nodes() end migrate_xray_protocol_nodes() +]]-- m = Map("shadowsocksr", translate("Edit ShadowSocksR Server")) m.redirect = url("servers") @@ -371,44 +373,43 @@ o.cfgvalue = function(self, section) end return val end +o.description = translate("Using incorrect encryption mothod may causes service fail to start") - o.description = translate("Using incorrect encryption mothod may causes service fail to start") +o = s:option(Value, "alias", translate("Alias(optional)")) - o = s:option(Value, "alias", translate("Alias(optional)")) - - local function clash_source_formvalue(map, section, option) - local value = map:formvalue("cbid." .. map.config .. "." .. section .. "." .. option) - if value == nil then - value = map.uci:get(map.config, section, option) - end - return trim(value or "") +local function clash_source_formvalue(map, section, option) + local value = map:formvalue("cbid." .. map.config .. "." .. section .. "." .. option) + if value == nil then + value = map.uci:get(map.config, section, option) end + return trim(value or "") +end - local function validate_clash_source(self, value, section) - local clash_url = clash_source_formvalue(self.map, section, "clash_url") - local clash_path = clash_source_formvalue(self.map, section, "clash_path") - if clash_url == "" and clash_path == "" then - return nil, translate("Please specify either a Clash subscription URL or a local YAML path.") - end - return value +local function validate_clash_source(self, value, section) + local clash_url = clash_source_formvalue(self.map, section, "clash_url") + local clash_path = clash_source_formvalue(self.map, section, "clash_path") + if clash_url == "" and clash_path == "" then + return nil, translate("Please specify either a Clash subscription URL or a local YAML path.") end + return value +end - o = s:option(Value, "clash_url", translate("Clash Subscription URL")) - o.placeholder = "https://example.com/config.yaml" - o.rmempty = true - o:depends("type", "clash") - o.validate = validate_clash_source +o = s:option(Value, "clash_url", translate("Clash Subscription URL")) +o.placeholder = "https://example.com/config.yaml" +o.rmempty = true +o:depends("type", "clash") +o.validate = validate_clash_source - o = s:option(Value, "clash_path", translate("Clash YAML Path")) - o.placeholder = "/etc/ssrplus/clash/custom.yaml" - o.rmempty = true - o:depends("type", "clash") - o.validate = validate_clash_source +o = s:option(Value, "clash_path", translate("Clash YAML Path")) +o.placeholder = "/etc/ssrplus/clash/custom.yaml" +o.rmempty = true +o:depends("type", "clash") +o.validate = validate_clash_source - o = s:option(Value, "clash_user_agent", translate("Clash User-Agent")) - o.default = "clash" - o.rmempty = false - o:depends("type", "clash") +o = s:option(Value, "clash_user_agent", translate("Clash User-Agent")) +o.default = "clash" +o.rmempty = false +o:depends("type", "clash") o = s:option(ListValue, "v2ray_protocol", translate("V2Ray/XRay protocol")) o:value("vless", translate("VLESS")) @@ -425,33 +426,33 @@ o:value("socks", translate("Socks")) o:value("http", translate("HTTP")) o:depends("type", "v2ray") - o = s:option(Value, "server", translate("Server Address")) - o.datatype = "or(host,ip6addr)" - o.rmempty = false - o:depends("type", "ssr") - o:depends("type", "ss") - o:depends("type", "ss-rust") - o:depends("type", "v2ray") +o = s:option(Value, "server", translate("Server Address")) +o.datatype = "or(host,ip6addr)" +o.rmempty = false +o:depends("type", "ssr") +o:depends("type", "ss") +o:depends("type", "ss-rust") +o:depends("type", "v2ray") o:depends("type", "trojan") - o:depends("type", "naiveproxy") - o:depends("type", "hysteria2") - o:depends("type", "tuic") - o:depends("type", "shadowtls") - o:depends("type", "socks5") +o:depends("type", "naiveproxy") +o:depends("type", "hysteria2") +o:depends("type", "tuic") +o:depends("type", "shadowtls") +o:depends("type", "socks5") - o = s:option(Value, "server_port", translate("Server Port")) - o.datatype = "port" - o.rmempty = true - o:depends("type", "ssr") - o:depends("type", "ss") - o:depends("type", "ss-rust") - o:depends("type", "v2ray") +o = s:option(Value, "server_port", translate("Server Port")) +o.datatype = "port" +o.rmempty = true +o:depends("type", "ssr") +o:depends("type", "ss") +o:depends("type", "ss-rust") +o:depends("type", "v2ray") o:depends("type", "trojan") - o:depends("type", "naiveproxy") - o:depends("type", "hysteria2") - o:depends("type", "tuic") - o:depends("type", "shadowtls") - o:depends("type", "socks5") +o:depends("type", "naiveproxy") +o:depends("type", "hysteria2") +o:depends("type", "tuic") +o:depends("type", "shadowtls") +o:depends("type", "socks5") o = s:option(Flag, "auth_enable", translate("Enable Authentication")) o.rmempty = false @@ -467,13 +468,13 @@ o:depends({type = "socks5", auth_enable = true}) o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true}) o:depends({type = "v2ray", v2ray_protocol = "socks", auth_enable = true}) - o = s:option(Value, "password", translate("Password")) - o.password = true - o.rmempty = true - o:depends("type", "ssr") - o:depends("type", "ss") - o:depends("type", "ss-rust") - o:depends("type", "trojan") +o = s:option(Value, "password", translate("Password")) +o.password = true +o.rmempty = true +o:depends("type", "ssr") +o:depends("type", "ss") +o:depends("type", "ss-rust") +o:depends("type", "trojan") o:depends("type", "naiveproxy") o:depends("type", "shadowtls") o:depends({type = "socks5", auth_enable = true}) @@ -489,7 +490,7 @@ end o.rmempty = true o:depends("type", "ssr") - o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method")) +o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method")) for _, v in ipairs(encrypt_methods_ss) do if v == "none" then o.default = "none" @@ -498,10 +499,10 @@ for _, v in ipairs(encrypt_methods_ss) do o:value(v, translate(v)) end end - o.rmempty = true - o:depends("type", "ss-rust") - o:depends("type", "ss") - o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"}) +o.rmempty = true +o:depends("type", "ss-rust") +o:depends("type", "ss") +o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"}) o = s:option(Flag, "uot", translate("UDP over TCP")) o.description = translate("Enable the SUoT protocol, requires server support.") @@ -515,11 +516,11 @@ o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"}) o.default = "1" -- [[ Enable Shadowsocks Plugin ]]-- - o = s:option(Flag, "enable_plugin", translate("Enable Plugin")) - o.rmempty = true - o:depends("type", "ss") - o:depends("type", "ss-rust") - o.default = "0" +o = s:option(Flag, "enable_plugin", translate("Enable Plugin")) +o.rmempty = true +o:depends("type", "ss") +o:depends("type", "ss-rust") +o.default = "0" -- Shadowsocks Plugin o = s:option(ListValue, "plugin", translate("Obfs")) 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 9157a0db..be9779b4 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua @@ -25,6 +25,50 @@ local function is_finded(e) return luci.sys.exec(string.format('type -t -p "%s" -p "/usr/libexec/%s" 2>/dev/null', e, e)) ~= "" end +local function is_js_luci() + return luci.sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0 +end + +-- 保存并应用行为 +local function apply_redirect(m) + local tmp_uci_file = "/etc/config/" .. "shadowsocksr" .. "_redirect" + if m.redirect and m.redirect ~= "" then + if nixio.fs.access(tmp_uci_file) then + local redirect + for line in io.lines(tmp_uci_file) do + redirect = line:match("option%s+url%s+['\"]([^'\"]+)['\"]") + if redirect and redirect ~= "" then break end + end + if redirect and redirect ~= "" then + luci.sys.call("/bin/rm -f " .. tmp_uci_file) + luci.http.redirect(redirect) + end + else + nixio.fs.writefile(tmp_uci_file, "config redirect\n") + end + m.on_after_save = function(self) + local redirect = self.redirect + if redirect and redirect ~= "" then + m.uci:set("shadowsocksr" .. "_redirect", "@redirect[0]", "url", redirect) + end + end + else + luci.sys.call("/bin/rm -f " .. tmp_uci_file) + end +end + +local function set_apply_on_parse(map) + if not map then return end + if is_js_luci() then + apply_redirect(map) + local old = map.on_after_save + map.on_after_save = function(self) + if old then old(self) end + map:set("@global[0]", "timestamp", os.time()) + end + end +end + local function trim(text) if not text or text == "" then return "" @@ -532,6 +576,7 @@ s.anonymous = true s.addremove = true s.description = translate("Node order can be dragged with the mouse and takes effect immediately. The automatic switch order of server nodes is consistent with the node order in the table.") s.template = "shadowsocksr/server_table" +set_apply_on_parse(m) s:append(cbi.Template("shadowsocksr/optimize_cbi_ui")) s.extedit = luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers", "%s") @@ -584,12 +629,17 @@ s.server_first_index = server_first_index s.server_last_index = server_last_index s.server_base_url = luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers") -function s.create(...) - local sid = TypedSection.create(...) - if sid then - luci.http.redirect(s.extedit % sid) - return - end +function s.create(self, ...) + local sid = TypedSection.create(self, ...) + if sid then + local newsid = "cfg" .. sid:sub(-6) + -- 删除匿名 + self.map.uci:delete(self.config, sid) + -- 重命名 section + self.map.uci:section(self.config, self.sectiontype, newsid) + luci.http.redirect(self.extedit % newsid) + return + end end o = s:option(DummyValue, "type", translate("Type")) diff --git a/luci-app-ssr-plus/luasrc/view/shadowsocksr/optimize_cbi_ui.htm b/luci-app-ssr-plus/luasrc/view/shadowsocksr/optimize_cbi_ui.htm index 68286cd0..579d0383 100644 --- a/luci-app-ssr-plus/luasrc/view/shadowsocksr/optimize_cbi_ui.htm +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/optimize_cbi_ui.htm @@ -2,6 +2,13 @@ document.addEventListener("DOMContentLoaded", function () { setTimeout(updateElements, 200); function updateElements() { + //修正上移、下移按钮名称 + document.querySelectorAll("input.btn.cbi-button.cbi-button-up").forEach(function(btn) { + btn.value = "<%:Move up%>"; + }); + document.querySelectorAll("input.btn.cbi-button.cbi-button-down").forEach(function(btn) { + btn.value = "<%:Move down%>"; + }); //删除控件和说明之间的多余换行 document.querySelectorAll("div.cbi-value-description").forEach(function(descDiv) { var prev = descDiv.previousSibling; diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index a22d8721..efa48187 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -797,7 +797,27 @@ normalize_xray_protocol_nodes() { _migrate_xray_protocol_node() { local section="$1" local type="$(uci_get_by_name "$section" type)" + local v2ray_protocol="$(uci_get_by_name "$section" v2ray_protocol)" + if [ "$type" = "ss" ] || [ "$type" = "ss-libev" ]; then + if [ -n "$(first_type mihomo)" ]; then + uci -q set "$NAME.$section.type=ss" + changed=1 + elif [ -n "$(first_type sslocal)" ]; then + uci -q set "$NAME.$section.type=ss-rust" + changed=1 + elif [ -n "$(first_type xray)" ]; then + uci -q set "$NAME.$section.type=v2ray" + uci -q set "$NAME.$section.v2ray_protocol=shadowsocks" + changed=1 + fi + elif [ "$type" = "v2ray" ] && [ "$v2ray_protocol" = "shadowsocks" ]; then + if [ -n "$(first_type mihomo)" ]; then + uci -q set "$NAME.$section.type=ss" + uci -q delete "$NAME.$section.v2ray_protocol" + changed=1 + fi + fi if [ "$type" = "hysteria2" ]; then echolog "提示:检测到原生 Hysteria2 节点,自动迁移为 Xray(Hysteria2)。" uci -q set "$NAME.$section.type=v2ray" @@ -815,13 +835,13 @@ normalize_xray_protocol_nodes() { config_foreach _migrate_xray_protocol_node servers local subscribe_sid="$(uci_get_by_cfgid server_subscribe)" - if [ -n "$subscribe_sid" ] && uci -q get "$NAME.$subscribe_sid.xray_hy2_type" >/dev/null; then - uci -q delete "$NAME.$subscribe_sid.xray_hy2_type" - changed=1 - fi - if [ -n "$subscribe_sid" ] && uci -q get "$NAME.$subscribe_sid.xray_tj_type" >/dev/null; then - uci -q delete "$NAME.$subscribe_sid.xray_tj_type" - changed=1 + if [ -n "$subscribe_sid" ]; then + for key in xray_hy2_type xray_tj_type ss_type; do + if uci -q get "$NAME.$subscribe_sid.$key" >/dev/null; then + uci -q delete "$NAME.$subscribe_sid.$key" + changed=1 + fi + done fi if [ "$changed" = "1" ]; then