diff --git a/luci-app-passwall2/luasrc/controller/passwall2.lua b/luci-app-passwall2/luasrc/controller/passwall2.lua
index f92c1358f..cf48425f2 100644
--- a/luci-app-passwall2/luasrc/controller/passwall2.lua
+++ b/luci-app-passwall2/luasrc/controller/passwall2.lua
@@ -24,7 +24,6 @@ function index()
entry({"admin", "services", appname, "settings"}, cbi(appname .. "/client/global"), _("Basic Settings"), 1).dependent = true
entry({"admin", "services", appname, "node_list"}, cbi(appname .. "/client/node_list"), _("Node List"), 2).dependent = true
entry({"admin", "services", appname, "node_subscribe"}, cbi(appname .. "/client/node_subscribe"), _("Node Subscribe"), 3).dependent = true
- entry({"admin", "services", appname, "auto_switch"}, cbi(appname .. "/client/auto_switch"), _("Auto Switch"), 4).leaf = true
entry({"admin", "services", appname, "other"}, cbi(appname .. "/client/other", {autoapply = true}), _("Other Settings"), 92).leaf = true
if nixio.fs.access("/usr/sbin/haproxy") then
entry({"admin", "services", appname, "haproxy"}, cbi(appname .. "/client/haproxy"), _("Load Balancing"), 93).leaf = true
@@ -48,8 +47,6 @@ function index()
entry({"admin", "services", appname, "server_get_log"}, call("server_get_log")).leaf = true
entry({"admin", "services", appname, "server_clear_log"}, call("server_clear_log")).leaf = true
entry({"admin", "services", appname, "link_add_node"}, call("link_add_node")).leaf = true
- entry({"admin", "services", appname, "autoswitch_add_node"}, call("autoswitch_add_node")).leaf = true
- entry({"admin", "services", appname, "autoswitch_remove_node"}, call("autoswitch_remove_node")).leaf = true
entry({"admin", "services", appname, "get_now_use_node"}, call("get_now_use_node")).leaf = true
entry({"admin", "services", appname, "get_redir_log"}, call("get_redir_log")).leaf = true
entry({"admin", "services", appname, "get_log"}, call("get_log")).leaf = true
@@ -107,41 +104,6 @@ function link_add_node()
luci.sys.call("lua /usr/share/passwall2/subscribe.lua add log")
end
-function autoswitch_add_node()
- local key = luci.http.formvalue("key")
- if key and key ~= "" then
- local new_list = ucic:get(appname, "@auto_switch[0]", "node") or {}
- for i = #new_list, 1, -1 do
- if (ucic:get(appname, new_list[i], "remarks") or ""):find(key) then
- table.remove(new_list, i)
- end
- end
- for k, e in ipairs(api.get_valid_nodes()) do
- if e.node_type == "normal" and e["remark"]:find(key) then
- table.insert(new_list, e.id)
- end
- end
- ucic:set_list(appname, "@auto_switch[0]", "node", new_list)
- ucic:commit(appname)
- end
- luci.http.redirect(api.url("auto_switch"))
-end
-
-function autoswitch_remove_node()
- local key = luci.http.formvalue("key")
- if key and key ~= "" then
- local new_list = ucic:get(appname, "@auto_switch[0]", "node") or {}
- for i = #new_list, 1, -1 do
- if (ucic:get(appname, new_list[i], "remarks") or ""):find(key) then
- table.remove(new_list, i)
- end
- end
- ucic:set_list(appname, "@auto_switch[0]", "node", new_list)
- ucic:commit(appname)
- end
- luci.http.redirect(api.url("auto_switch"))
-end
-
function get_now_use_node()
local e = {}
local data, code, msg = nixio.fs.readfile("/tmp/etc/passwall2/id/global")
@@ -293,7 +255,6 @@ end
function clear_all_nodes()
ucic:set(appname, '@global[0]', "enabled", "0")
ucic:set(appname, '@global[0]', "node", "nil")
- ucic:set_list(appname, "@auto_switch[0]", "node", {})
ucic:foreach(appname, "socks", function(t)
ucic:delete(appname, t[".name"])
end)
@@ -313,14 +274,7 @@ end
function delete_select_nodes()
local ids = luci.http.formvalue("ids")
- local auto_switch_node_list = ucic:get(appname, "@auto_switch[0]", "node") or {}
string.gsub(ids, '[^' .. "," .. ']+', function(w)
- for i = #auto_switch_node_list, 1, -1 do
- if w == auto_switch_node_list[i] then
- table.remove(auto_switch_node_list, i)
- end
- end
- ucic:set_list(appname, "@auto_switch[0]", "node", auto_switch_node_list)
if (ucic:get(appname, "@global[0]", "node") or "nil") == w then
ucic:set(appname, '@global[0]', "node", "nil")
end
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/auto_switch.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/auto_switch.lua
deleted file mode 100644
index c4f0573ca..000000000
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/auto_switch.lua
+++ /dev/null
@@ -1,66 +0,0 @@
-local api = require "luci.passwall2.api"
-local appname = api.appname
-
-local nodes_table = {}
-for k, e in ipairs(api.get_valid_nodes()) do
- nodes_table[#nodes_table + 1] = e
-end
-
-m = Map(appname)
-
--- [[ Auto Switch Settings ]]--
-s = m:section(TypedSection, "auto_switch")
-s.anonymous = true
-
----- Enable
-o = s:option(Flag, "enable", translate("Enable"))
-o.default = 0
-o.rmempty = false
-
-o = s:option(Value, "testing_time", translate("How often to test"), translate("Units:minutes"))
-o.datatype = "uinteger"
-o.default = 1
-
-o = s:option(Value, "connect_timeout", translate("Timeout seconds"), translate("Units:seconds"))
-o.datatype = "uinteger"
-o.default = 3
-
-o = s:option(Value, "retry_num", translate("Timeout retry num"))
-o.datatype = "uinteger"
-o.default = 3
-
-o = s:option(DynamicList, "node", translate("List of backup nodes"))
-for k, v in pairs(nodes_table) do
- if v.node_type == "normal" then
- o:value(v.id, v["remark"])
- end
-end
-function o.write(self, section, value)
- local t = {}
- local t2 = {}
- if type(value) == "table" then
- local x
- for _, x in ipairs(value) do
- if x and #x > 0 then
- if not t2[x] then
- t2[x] = x
- t[#t+1] = x
- end
- end
- end
- else
- t = { value }
- end
- return DynamicList.write(self, section, t)
-end
-
-o = s:option(Flag, "restore_switch", translate("Restore Switch"), translate("When detects main node is available, switch back to the main node."))
-
-o = s:option(ListValue, "shunt_logic", translate("If the main node is shunt"))
-o:value("0", translate("Switch it"))
-o:value("1", translate("Applying to the default node"))
-o:value("2", translate("Applying to the default preproxy node"))
-
-m:append(Template(appname .. "/auto_switch/footer"))
-
-return m
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua
index 8d0c3b890..480433a06 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua
@@ -46,42 +46,9 @@ s:tab("Main", translate("Main"))
o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
o.rmempty = false
-local auto_switch_tip
-local shunt_remark
-local current_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/global' ] && echo -n $(cat /tmp/etc/%s/id/global)", appname, appname))
-if current_node and current_node ~= "" and current_node ~= "nil" then
- local n = uci:get_all(appname, current_node)
- if n then
- if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
- if n.protocol == "_shunt" then
- local shunt_logic = tonumber(m:get("@auto_switch[0]", "shunt_logic"))
- if shunt_logic == 1 or shunt_logic == 2 then
- if shunt_logic == 1 then
- shunt_remark = "default"
- elseif shunt_logic == 2 then
- shunt_remark = "main"
- end
- current_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/global_%s' ] && echo -n $(cat /tmp/etc/%s/id/global_%s)", appname, shunt_remark, appname, shunt_remark))
- if current_node and current_node ~= "" and current_node ~= "nil" then
- n = uci:get_all(appname, current_node)
- end
- end
- end
- if n then
- local remarks = api.get_node_remarks(n)
- local url = api.url("node_config", n[".name"])
- auto_switch_tip = translatef("Current node: %s", string.format('%s', url, remarks)) .. " "
- end
- end
- end
-end
-
---- Node
node = s:taboption("Main", ListValue, "node", "" .. translate("Node") .. "")
node:value("nil", translate("Close"))
-if not shunt_remark and auto_switch_tip then
- node.description = auto_switch_tip
-end
-- 分流
if (has_v2ray or has_xray) and #nodes_table > 0 then
@@ -151,9 +118,6 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
end
o.cfgvalue = get_cfgvalue(v.id, "main_node")
o.write = get_write(v.id, "main_node")
- if shunt_remark == "main" and auto_switch_tip then
- o.description = auto_switch_tip
- end
if (has_v2ray and has_xray) or (v.type == "V2ray" and not has_v2ray) or (v.type == "Xray" and not has_xray) then
type:depends("node", v.id)
@@ -211,9 +175,6 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
for k1, v1 in pairs(normal_list) do
o:value(v1.id, v1.remark)
end
- if shunt_remark == "default" and auto_switch_tip then
- o.description = auto_switch_tip
- end
local id = "default_proxy_tag"
o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* %s', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua
index bff34094b..f62f03e5b 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua
@@ -43,11 +43,6 @@ function s.remove(e, t)
m:set(s[".name"], "node", "default")
end
end)
- for k, v in ipairs(m:get("@auto_switch[0]", "node") or {}) do
- if v and v == t then
- sys.call(string.format("uci -q del_list %s.@auto_switch[0].node='%s'", appname, v))
- end
- end
TypedSection.remove(e, t)
local new_node = "nil"
local node0 = m:get("@nodes[0]") or nil
diff --git a/luci-app-passwall2/luasrc/view/passwall2/auto_switch/footer.htm b/luci-app-passwall2/luasrc/view/passwall2/auto_switch/footer.htm
deleted file mode 100644
index ab648d2f3..000000000
--- a/luci-app-passwall2/luasrc/view/passwall2/auto_switch/footer.htm
+++ /dev/null
@@ -1,22 +0,0 @@
-<%
-local api = require "luci.passwall2.api"
--%>
-
-
-
-
\ No newline at end of file
diff --git a/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm b/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm
index dd9a4b2d6..d3f6dc32b 100644
--- a/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm
+++ b/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm
@@ -1,6 +1,5 @@
<%
local api = require "luci.passwall2.api"
-local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
-%>