luci-app-ssr-plus: keep user's auto-switch setting after subscribe update

This commit is contained in:
coolsnowwolf 2020-02-20 01:10:50 +08:00
parent ce4f85886d
commit 06f2f56860
4 changed files with 15 additions and 4 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=146
PKG_VERSION:=147
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

View File

@ -116,7 +116,7 @@ end
o = s:option(DummyValue, "switch_enable", translate("Auto Switch"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or "0"
return Value.cfgvalue(...) or "1"
end
o = s:option(DummyValue, "server_port", translate("Socket Connected"))

View File

@ -365,7 +365,7 @@ start_redir() {
pdnsd_enable_flag=1
fi
if [ "$(uci_get_by_type global enable_switch)" == "1" ]; then
if [ "$(uci_get_by_name $GLOBAL_SERVER switch_enable)" == "1" ]; then
if [ "$(uci_get_by_name $GLOBAL_SERVER switch_enable 1)" == "1" ]; then
if [ -z "$switch_server" ]; then
local switch_time=$(uci_get_by_type global switch_time)
local switch_timeout=$(uci_get_by_type global switch_timeout)

View File

@ -96,7 +96,7 @@ end
local function processData(szType, content)
local result = {
-- auth_enable = '0',
switch_enable = '1',
-- switch_enable = '1',
type = szType,
local_port = 1234,
-- timeout = 60, -- 不太确定 好像是死的
@ -228,8 +228,11 @@ local function processData(szType, content)
-- alias 不参与 hashkey 计算
local alias = result.alias
result.alias = nil
local switch_enable = result.switch_enable
result.switch_enable = nil
result.hashkey = md5(jsonStringify(result))
result.alias = alias
result.switch_enable = switch_enable
return result
end
-- wget
@ -333,7 +336,15 @@ local execute = function()
else
log('忽略手动添加的节点: ' .. old.alias)
end
-- 保留原有节点的自动切换设置
if(old.switch_enable)
then
nodeResult.switch_enable = old.switch_enable
end
end)
for k, v in ipairs(nodeResult) do
for kk, vv in ipairs(v) do
if not vv._ignore then