From e12e831d0187be13f5f2346f460fec4a63f558b5 Mon Sep 17 00:00:00 2001 From: action Date: Mon, 17 Aug 2026 08:56:27 +0800 Subject: [PATCH] update 2026-08-17 08:56:27 --- luci-app-passwall/Makefile | 7 ---- .../luasrc/controller/passwall.lua | 25 +++++++---- .../model/cbi/passwall/client/global.lua | 5 +++ .../model/cbi/passwall/client/type/naive.lua | 37 ---------------- luci-app-passwall/luasrc/passwall/api.lua | 27 +++++++++++- .../luasrc/passwall/util_naiveproxy.lua | 42 ------------------- .../root/etc/uci-defaults/luci-app-passwall | 2 + .../root/usr/share/passwall/app.sh | 8 ---- 8 files changed, 48 insertions(+), 105 deletions(-) delete mode 100644 luci-app-passwall/luasrc/model/cbi/passwall/client/type/naive.lua delete mode 100644 luci-app-passwall/luasrc/passwall/util_naiveproxy.lua diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 5ea0e1fc..9432e9bb 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -17,7 +17,6 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Geoview \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Client \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Server \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Client \ @@ -80,12 +79,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria select PACKAGE_hysteria default n -config PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy - bool "Include NaiveProxy" - depends on !(arc||armeb||loongarch64||mips||mips64||powerpc||TARGET_gemini) - select PACKAGE_naiveproxy - default n - config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Client bool "Include Shadowsocks Rust Client" depends on !i386 diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index 057efe4c..20c0d311 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -584,11 +584,16 @@ end function delete_select_nodes() local ids = http.formvalue("ids") local redirect = http.formvalue("redirect") + local ids_t = {} string.gsub(ids, '[^' .. "," .. ']+', function(w) + ids_t[#ids_t + 1] = w + if (uci_get("@global[0]", "tcp_node") or "") == w then + uci_del('@global[0]', "tcp_node") + end + if (uci_get("@global[0]", "udp_node") or "") == w then + uci_del('@global[0]', "udp_node") + end uci_foreach("socks", function(t) - if t["node"] == w then - uci_del(t[".name"]) - end local changed = false local auto_switch_node_list = uci_get(t[".name"], "autoswitch_backup_node") or {} for i = #auto_switch_node_list, 1, -1 do @@ -600,13 +605,15 @@ function delete_select_nodes() if changed then uci_set(t[".name"], "autoswitch_backup_node", auto_switch_node_list) end + if t["node"] == w then + local new_node = api.get_random_normal_node(ids_t) + if new_node then + uci_set(t[".name"], "node", new_node[".name"]) + else + uci_set(t[".name"], "enabled", "0") + end + end end) - if (uci_get("@global[0]", "tcp_node") or "") == w then - uci_del('@global[0]', "tcp_node") - end - if (uci_get("@global[0]", "udp_node") or "") == w then - uci_del('@global[0]', "udp_node") - end uci_foreach("haproxy_config", function(t) if t["lbss"] == w then uci_del(t[".name"]) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index 10ccfc2e..c35e594b 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -676,6 +676,7 @@ o.rmempty = false s2 = m:section(TypedSection, "socks", translate("Socks Config")) s2.template = "cbi/tblsection" +s2.sortable = true s2.anonymous = true s2.addremove = true s2.extedit = api.url("socks_config", "%s") @@ -770,11 +771,13 @@ o.default = n + 1080 o.datatype = "port" o.rmempty = false +--[[ if has_singbox or has_xray then o = s2:option(Value, "http_port", "HTTP " .. translate("Listen Port")) o.default = 0 o.datatype = "port" end +]]-- local tcp = s.fields["tcp_node"] local udp = s.fields["udp_node"] @@ -823,4 +826,6 @@ end m:appendTemplate("/global/footer", {shunt_list = api.jsonc.stringify(shunt_list)}) +m:appendTemplate("/cbi/sortable", {sectiontype = s2.sectiontype}) + return api.return_map(m) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/naive.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/naive.lua deleted file mode 100644 index 621596fd..00000000 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/naive.lua +++ /dev/null @@ -1,37 +0,0 @@ -local m, s = ... - -if not api.is_finded("naive") then - return -end - -type_name = "Naiveproxy" - --- [[ Naive ]] - -s.fields["type"]:value(type_name, "NaiveProxy") - -if s.val["type"] ~= type_name then - return -end - -local option_prefix = "naive_" - -local function _n(name) - return option_prefix .. name -end - -o = s:option(ListValue, _n("protocol"), translate("Protocol")) -o:value("https", translate("HTTPS")) -o:value("quic", translate("QUIC")) - -o = s:option(Value, _n("address"), translate("Address (Support Domain Name)")) - -o = s:option(Value, _n("port"), translate("Port")) -o.datatype = "port" - -o = s:option(Value, _n("username"), translate("Username")) - -o = s:option(Value, _n("password"), translate("Password")) -o.password = true - -api.luci_types(arg[1], m, s, type_name, option_prefix) diff --git a/luci-app-passwall/luasrc/passwall/api.lua b/luci-app-passwall/luasrc/passwall/api.lua index ec76e81f..2bd6d741 100644 --- a/luci-app-passwall/luasrc/passwall/api.lua +++ b/luci-app-passwall/luasrc/passwall/api.lua @@ -565,7 +565,7 @@ function get_valid_nodes() local nodes = {} local default_nodes = {} local other_nodes = {} - uci:foreach(c_config, "nodes", function(e) + uci_foreach_c("nodes", function(e) e.id = e[".name"] if e.type and e.remarks then local type_name = e.type @@ -638,7 +638,7 @@ function get_node_list() socks_list = {}, normal_list = {}, } - uci:foreach(c_config, "socks", function(s) + uci_foreach_c("socks", function(s) if s.enabled == "1" and s.node then node_list.socks_list[#node_list.socks_list + 1] = { id = s[".name"], @@ -727,6 +727,29 @@ function get_full_node_remarks(n) return remarks end +function get_random_normal_node(exclude_id) + local exclude_id_lookup = {} + if type(exclude_id) == "table" then + for i, v in ipairs(exclude_id) do + exclude_id_lookup[v] = true + end + elseif type(exclude_id) == "string" then + exclude_id_lookup[exclude_id] = true + end + local normal_list = {} + for k, e in ipairs(get_valid_nodes()) do + if e.node_type == "normal" and not exclude_id_lookup[e[".name"]] then + normal_list[#normal_list + 1] = e + end + end + if #normal_list > 0 then + math.randomseed(os.time()) + local num = math.random(1, #normal_list) + return normal_list[num] + end + return nil +end + function gen_uuid() local uuid = sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)") return uuid diff --git a/luci-app-passwall/luasrc/passwall/util_naiveproxy.lua b/luci-app-passwall/luasrc/passwall/util_naiveproxy.lua deleted file mode 100644 index a29cfafe..00000000 --- a/luci-app-passwall/luasrc/passwall/util_naiveproxy.lua +++ /dev/null @@ -1,42 +0,0 @@ -module("luci.passwall.util_naiveproxy", package.seeall) -local api = require "luci.passwall.api" -local jsonc = api.jsonc - -function gen_config(var) - local node_id = var["node"] - if not node_id then - print("node 不能为空") - return - end - local node = api.uci_get_c(node_id) - local run_type = var["run_type"] - local local_addr = var["local_addr"] - local local_port = var["local_port"] - local server_host = var["server_host"] or (node.address or ""):lower() - local server_port = var["server_port"] or node.port - - if api.is_ipv6(server_host) then - server_host = api.get_ipv6_full(server_host) - end - local server = server_host .. ":" .. server_port - - local config = { - listen = run_type .. "://" .. local_addr .. ":" .. local_port, - proxy = node.protocol .. "://" .. node.username .. ":" .. node.password .. "@" .. server - } - - return jsonc.stringify(config, 1) -end - -_G.gen_config = gen_config - -if arg[1] then - local func =_G[arg[1]] - if func then - local var = nil - if arg[2] then - var = jsonc.parse(arg[2]) - end - print(func(var)) - end -end diff --git a/luci-app-passwall/root/etc/uci-defaults/luci-app-passwall b/luci-app-passwall/root/etc/uci-defaults/luci-app-passwall index e81c81c3..a69d8970 100755 --- a/luci-app-passwall/root/etc/uci-defaults/luci-app-passwall +++ b/luci-app-passwall/root/etc/uci-defaults/luci-app-passwall @@ -37,6 +37,8 @@ chmod +x /usr/share/passwall/*.sh uci -q delete passwall.@global_xray[0].sniffing uci -q delete passwall.@global_xray[0].route_only +[ "$(uci -q get passwall.@global_haproxy[0].health_check_type)" = "passwall_logic" ] && uci -q set passwall.@global_haproxy[0].health_check_type='script_logic' + for sid in $(uci show passwall | grep "=socks" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}'); do if [ -z "$(echo ${sid} | grep '^socks_')" ]; then new_id="socks_$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)" diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index bc0246cc..da6986ef 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -13,7 +13,6 @@ LUA_UTIL_PATH=/usr/lib/lua/luci/passwall UTIL_SINGBOX=$LUA_UTIL_PATH/util_sing-box.lua UTIL_SS=$LUA_UTIL_PATH/util_shadowsocks.lua UTIL_XRAY=$LUA_UTIL_PATH/util_xray.lua -UTIL_NAIVE=$LUA_UTIL_PATH/util_naiveproxy.lua UTIL_HYSTERIA2=$LUA_UTIL_PATH/util_hysteria2.lua SINGBOX_BIN=$(first_type $(config_t_get global_app sing_box_file) sing-box) XRAY_BIN=$(first_type $(config_t_get global_app xray_file) xray) @@ -456,13 +455,6 @@ run_socks() { [ -n "$no_run" ] && _args="${_args} no_run=1" run_xray flag=$flag node=$node socks_address=$bind socks_port=$socks_port config_file=$config_file log_file=$log_file ${_args} ;; - naiveproxy) - json_add_string "run_type" "socks" - json_add_string "local_addr" "$bind" - json_add_string "local_port" "$socks_port" - lua $UTIL_NAIVE gen_config "$(json_dump)" > $config_file - [ -n "$no_run" ] || ln_run "$(first_type naive)" naive $log_file "$config_file" - ;; ssr) json_add_string "local_addr" "$bind" json_add_string "local_port" "$socks_port"