From d57e43433903da878ba65e8759a5f8159c4e7e8e Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sun, 17 Mar 2024 19:17:01 +0800 Subject: [PATCH] update 2024-03-17 19:17:01 --- luci-app-eqos/luasrc/controller/eqos.lua | 3 +- luci-app-passwall2/Makefile | 45 ++++------ .../luasrc/controller/passwall2.lua | 10 ++- .../model/cbi/passwall2/client/global.lua | 63 ++++++++----- .../model/cbi/passwall2/client/other.lua | 6 +- .../model/cbi/passwall2/client/type/brook.lua | 40 --------- .../model/cbi/passwall2/client/type/ray.lua | 74 ++++++++++------ .../cbi/passwall2/client/type/sing-box.lua | 45 +++++++--- .../model/cbi/passwall2/server/type/brook.lua | 41 --------- .../model/cbi/passwall2/server/type/ray.lua | 9 ++ luci-app-passwall2/luasrc/passwall2/api.lua | 2 +- luci-app-passwall2/luasrc/passwall2/com.lua | 11 --- .../luasrc/passwall2/server_app.lua | 9 -- .../luasrc/passwall2/util_sing-box.lua | 64 +++++++------- .../luasrc/passwall2/util_xray.lua | 78 +++++++++------- .../luasrc/view/passwall2/global/footer.htm | 20 +++-- .../passwall2/node_list/link_share_man.htm | 88 ------------------- luci-app-passwall2/po/zh-cn/passwall2.po | 12 --- .../root/usr/share/passwall2/0_default_config | 1 - .../root/usr/share/passwall2/app.sh | 34 ++----- .../root/usr/share/passwall2/iptables.sh | 2 +- .../root/usr/share/passwall2/nftables.sh | 2 +- 22 files changed, 256 insertions(+), 403 deletions(-) delete mode 100644 luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/brook.lua delete mode 100644 luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/brook.lua diff --git a/luci-app-eqos/luasrc/controller/eqos.lua b/luci-app-eqos/luasrc/controller/eqos.lua index a8aea8644..d24a36f52 100755 --- a/luci-app-eqos/luasrc/controller/eqos.lua +++ b/luci-app-eqos/luasrc/controller/eqos.lua @@ -6,6 +6,5 @@ function index() end local page - entry({"admin", "nas"}, firstchild(), "NAS", 45).dependent = false - entry({"admin", "network", "eqos"}, cbi("eqos"), _("EQoS")) + entry({"admin", "network", "eqos"}, cbi("eqos"), _("EQoS"), 121).dependent = true end diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index eb9954136..9a8ef91a0 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,13 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=1.28-1 +PKG_VERSION:=1.28-2 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Brook \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_IPv6_Nat \ @@ -33,26 +32,11 @@ LUCI_DEPENDS:=+coreutils +coreutils-base64 +coreutils-nohup +curl \ +ip-full +libuci-lua +lua +luci-compat +luci-lib-jsonc +resolveip +tcping \ +xray-core +v2ray-geoip +v2ray-geosite \ +unzip \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Brook:brook \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy:haproxy \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria:hysteria \ - +PACKAGE_$(PKG_NAME)_INCLUDE_IPv6_Nat:ip6tables-mod-nat \ - +PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy:naiveproxy \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Client:shadowsocks-libev-ss-local \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Client:shadowsocks-libev-ss-redir \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Server:shadowsocks-libev-ss-server \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Client:shadowsocks-rust-sslocal \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Server:shadowsocks-rust-ssserver \ - +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Client:shadowsocksr-libev-ssr-local \ - +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Client:shadowsocksr-libev-ssr-redir \ - +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Server:shadowsocksr-libev-ssr-server \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Simple_Obfs:simple-obfs \ - +PACKAGE_$(PKG_NAME)_INCLUDE_SingBox:sing-box \ - +PACKAGE_$(PKG_NAME)_INCLUDE_tuic_client:tuic-client \ - +PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin:v2ray-plugin + +PACKAGE_$(PKG_NAME)_INCLUDE_IPv6_Nat:ip6tables-mod-nat define Package/$(PKG_NAME)/config menu "Configuration" + depends on PACKAGE_$(PKG_NAME) config PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy bool "Iptables Transparent Proxy" @@ -67,9 +51,8 @@ config PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy select PACKAGE_iptables-mod-socket select PACKAGE_iptables-mod-tproxy select PACKAGE_kmod-ipt-nat - depends on PACKAGE_$(PKG_NAME) default y if ! PACKAGE_firewall4 - + config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy bool "Nftables Transparent Proxy" select PACKAGE_dnsmasq-full @@ -78,19 +61,16 @@ config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy select PACKAGE_kmod-nft-socket select PACKAGE_kmod-nft-tproxy select PACKAGE_kmod-nft-nat - depends on PACKAGE_$(PKG_NAME) default y if PACKAGE_firewall4 -config PACKAGE_$(PKG_NAME)_INCLUDE_Brook - bool "Include Brook" - default n - config PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy bool "Include Haproxy" + select PACKAGE_haproxy default y if aarch64||arm||i386||x86_64 config PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria bool "Include Hysteria" + select PACKAGE_hysteria default n config PACKAGE_$(PKG_NAME)_INCLUDE_IPv6_Nat @@ -101,49 +81,62 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_IPv6_Nat config PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy bool "Include NaiveProxy" depends on !(arc||(arm&&TARGET_gemini)||armeb||mips||mips64||powerpc) + select PACKAGE_naiveproxy default n config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Client bool "Include Shadowsocks Libev Client" + select PACKAGE_shadowsocks-libev-ss-local + select PACKAGE_shadowsocks-libev-ss-redir default y config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Server bool "Include Shadowsocks Libev Server" + select PACKAGE_shadowsocks-libev-ss-server default n config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Client bool "Include Shadowsocks Rust Client" depends on aarch64||arm||i386||mips||mipsel||x86_64 + select PACKAGE_shadowsocks-rust-sslocal default y if aarch64 config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust_Server bool "Include Shadowsocks Rust Server" depends on aarch64||arm||i386||mips||mipsel||x86_64 + select PACKAGE_shadowsocks-rust-ssserver default n config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Client bool "Include ShadowsocksR Libev Client" + select PACKAGE_shadowsocksr-libev-ssr-local + select PACKAGE_shadowsocksr-libev-ssr-redir default y config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Server bool "Include ShadowsocksR Libev Server" + select PACKAGE_shadowsocksr-libev-ssr-server default n config PACKAGE_$(PKG_NAME)_INCLUDE_Simple_Obfs bool "Include Simple-Obfs (Shadowsocks Plugin)" + select PACKAGE_simple-obfs default y config PACKAGE_$(PKG_NAME)_INCLUDE_SingBox bool "Include Sing-Box" + select PACKAGE_sing-box default y if aarch64||arm||i386||x86_64 config PACKAGE_$(PKG_NAME)_INCLUDE_tuic_client bool "Include tuic-client" depends on aarch64||arm||i386||x86_64 + select PACKAGE_tuic-client default n config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin bool "Include V2ray-Plugin (Shadowsocks Plugin)" + select PACKAGE_v2ray-plugin default y if aarch64||arm||i386||x86_64 endmenu diff --git a/luci-app-passwall2/luasrc/controller/passwall2.lua b/luci-app-passwall2/luasrc/controller/passwall2.lua index 7a7c7630f..862a443c1 100644 --- a/luci-app-passwall2/luasrc/controller/passwall2.lua +++ b/luci-app-passwall2/luasrc/controller/passwall2.lua @@ -146,7 +146,7 @@ end function get_now_use_node() local e = {} - local data, code, msg = nixio.fs.readfile("/tmp/etc/passwall2/id/global") + local data, code, msg = nixio.fs.readfile("/tmp/etc/passwall2/acl/default/global.id") if data then e["global"] = util.trim(data) end @@ -156,8 +156,10 @@ end function get_redir_log() local id = luci.http.formvalue("id") - if nixio.fs.access("/tmp/etc/passwall2/" .. id .. ".log") then - local content = luci.sys.exec("cat /tmp/etc/passwall2/" .. id .. ".log") + local name = luci.http.formvalue("name") + local file_path = "/tmp/etc/passwall2/acl/" .. id .. "/" .. name .. ".log" + if nixio.fs.access(file_path) then + local content = luci.sys.exec("cat '" .. file_path .. "'") content = content:gsub("\n", "
") luci.http.write(content) else @@ -176,7 +178,7 @@ end function status() local e = {} - e["global_status"] = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v -E 'grep|acl/|acl_' | grep '%s/bin/' | grep -i 'global\\.json' >/dev/null", appname)) == 0 + e["global_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall2/bin/' | grep -v '_acl_' | grep 'global' >/dev/null") == 0 luci.http.prepare_content("application/json") luci.http.write_json(e) end 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 6afb0b2ba..c34ab9714 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua @@ -13,6 +13,35 @@ for k, e in ipairs(api.get_valid_nodes()) do nodes_table[#nodes_table + 1] = e end +local normal_list = {} +local balancing_list = {} +local shunt_list = {} +local iface_list = {} +for k, v in pairs(nodes_table) do + if v.node_type == "normal" then + normal_list[#normal_list + 1] = v + end + if v.protocol and v.protocol == "_balancing" then + balancing_list[#balancing_list + 1] = v + end + if v.protocol and v.protocol == "_shunt" then + shunt_list[#shunt_list + 1] = v + end + if v.protocol and v.protocol == "_iface" then + iface_list[#iface_list + 1] = v + end +end + +local socks_list = {} +uci:foreach(appname, "socks", function(s) + if s.enabled == "1" and s.node then + socks_list[#socks_list + 1] = { + id = "Socks_" .. s[".name"], + remark = translate("Socks Config") .. " [" .. s.port .. "端口]" + } + end +end) + local doh_validate = function(self, value, t) if value ~= "" then local flag = 0 @@ -55,25 +84,6 @@ node:value("nil", translate("Close")) -- 分流 if (has_singbox or has_xray) and #nodes_table > 0 then - local normal_list = {} - local balancing_list = {} - local shunt_list = {} - local iface_list = {} - for k, v in pairs(nodes_table) do - if v.node_type == "normal" then - normal_list[#normal_list + 1] = v - end - if v.protocol and v.protocol == "_balancing" then - balancing_list[#balancing_list + 1] = v - end - if v.protocol and v.protocol == "_shunt" then - shunt_list[#shunt_list + 1] = v - end - if v.protocol and v.protocol == "_iface" then - iface_list[#iface_list + 1] = v - end - end - local function get_cfgvalue(shunt_node_id, option) return function(self, section) return m:get(shunt_node_id, option) or "nil" @@ -105,8 +115,11 @@ if (has_singbox or has_xray) and #nodes_table > 0 then o.cfgvalue = get_cfgvalue(v.id, "preproxy_enabled") o.write = get_write(v.id, "preproxy_enabled") - o = s:taboption("Main", Value, vid .. "-main_node", string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default) has a separate switch that controls whether this rule uses the pre-proxy or not.")) + o = s:taboption("Main", ListValue, vid .. "-main_node", string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default) has a separate switch that controls whether this rule uses the pre-proxy or not.")) o:depends(vid .. "-preproxy_enabled", "1") + for k1, v1 in pairs(socks_list) do + o:value(v1.id, v1.remark) + end for k1, v1 in pairs(balancing_list) do o:value(v1.id, v1.remark) end @@ -132,7 +145,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then local id = e[".name"] local node_option = vid .. "-" .. id .. "_node" if id and e.remarks then - o = s:taboption("Main", Value, node_option, string.format('* %s', api.url("shunt_rules", id), e.remarks)) + o = s:taboption("Main", ListValue, node_option, string.format('* %s', api.url("shunt_rules", id), e.remarks)) o.cfgvalue = get_cfgvalue(v.id, id) o.write = get_write(v.id, id) o:depends("node", v.id) @@ -148,6 +161,9 @@ if (has_singbox or has_xray) and #nodes_table > 0 then pt:value("nil", translate("Close")) pt:value("main", translate("Preproxy Node")) pt.default = "nil" + for k1, v1 in pairs(socks_list) do + o:value(v1.id, v1.remark) + end for k1, v1 in pairs(balancing_list) do o:value(v1.id, v1.remark) end @@ -162,13 +178,16 @@ if (has_singbox or has_xray) and #nodes_table > 0 then end) local id = "default_node" - o = s:taboption("Main", Value, vid .. "-" .. id, string.format('* %s', translate("Default"))) + o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* %s', translate("Default"))) o.cfgvalue = get_cfgvalue(v.id, id) o.write = get_write(v.id, id) o:depends("node", v.id) o.default = "_direct" o:value("_direct", translate("Direct Connection")) o:value("_blackhole", translate("Blackhole")) + for k1, v1 in pairs(socks_list) do + o:value(v1.id, v1.remark) + end for k1, v1 in pairs(balancing_list) do o:value(v1.id, v1.remark) end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua index f49b9213e..fb697493f 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua @@ -146,12 +146,14 @@ if has_xray then o = s_xray:option(ListValue, "fragment_packets", translate("Fragment Packets"), translate(" \"1-3\" is for segmentation at TCP layer, applying to the beginning 1 to 3 data writes by the client. \"tlshello\" is for TLS client hello packet fragmentation.")) o.default = "tlshello" - o:value("1-3", "1-3") o:value("tlshello", "tlshello") + o:value("1-2", "1-2") + o:value("1-3", "1-3") + o:value("1-5", "1-5") o:depends("fragment", true) o = s_xray:option(Value, "fragment_length", translate("Fragment Length"), translate("Fragmented packet length (byte)")) - o.default = "10-20" + o.default = "100-200" o:depends("fragment", true) o = s_xray:option(Value, "fragment_interval", translate("Fragment Interval"), translate("Fragmentation interval (ms)")) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/brook.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/brook.lua deleted file mode 100644 index 7c75be13a..000000000 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/brook.lua +++ /dev/null @@ -1,40 +0,0 @@ -local m, s = ... - -local api = require "luci.passwall2.api" - -if not api.finded_com("brook") then - return -end - -local type_name = "Brook" - -local option_prefix = "brook_" - -local function option_name(name) - return option_prefix .. name -end - --- [[ Brook ]] - -s.fields["type"]:value(type_name, translate("Brook")) - -o = s:option(ListValue, option_name("protocol"), translate("Protocol")) -o:value("client", translate("Brook")) -o:value("wsclient", translate("WebSocket")) - -o = s:option(Value, option_name("address"), translate("Address (Support Domain Name)")) - -o = s:option(Value, option_name("port"), translate("Port")) -o.datatype = "port" - -o = s:option(Value, option_name("ws_path"), translate("WebSocket Path")) -o.placeholder = "/" -o:depends({ [option_name("protocol")] = "wsclient" }) - -o = s:option(Flag, option_name("tls"), translate("Use TLS")) -o:depends({ [option_name("protocol")] = "wsclient" }) - -o = s:option(Value, option_name("password"), translate("Password")) -o.password = true - -api.luci_types(arg[1], m, s, type_name, option_prefix) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua index 19afae3ab..ab2edf0b4 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua @@ -54,28 +54,38 @@ for k, e in ipairs(api.get_valid_nodes()) do if e.node_type == "normal" then nodes_table[#nodes_table + 1] = { id = e[".name"], - remarks = e["remark"], + remark = e["remark"], type = e["type"] } end if e.protocol == "_balancing" then balancers_table[#balancers_table + 1] = { id = e[".name"], - remarks = e["remark"] + remark = e["remark"] } end if e.protocol == "_iface" then iface_table[#iface_table + 1] = { id = e[".name"], - remarks = e["remark"] + remark = e["remark"] } end end +local socks_list = {} +uci:foreach(appname, "socks", function(s) + if s.enabled == "1" and s.node then + socks_list[#socks_list + 1] = { + id = "Socks_" .. s[".name"], + remark = translate("Socks Config") .. " [" .. s.port .. "端口]" + } + end +end) + -- 负载均衡列表 local o = s:option(DynamicList, option_name("balancing_node"), translate("Load balancing node list"), translate("Load balancing node list, document")) o:depends({ [option_name("protocol")] = "_balancing" }) -for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end +for k, v in pairs(nodes_table) do o:value(v.id, v.remark) end local o = s:option(ListValue, option_name("balancingStrategy"), translate("Balancing Strategy")) o:depends({ [option_name("protocol")] = "_balancing" }) @@ -106,22 +116,25 @@ if #nodes_table > 0 then o = s:option(Flag, option_name("preproxy_enabled"), translate("Preproxy")) o:depends({ [option_name("protocol")] = "_shunt" }) - o = s:option(Value, option_name("main_node"), string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default) has a separate switch that controls whether this rule uses the pre-proxy or not.")) + o = s:option(ListValue, option_name("main_node"), string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default) has a separate switch that controls whether this rule uses the pre-proxy or not.")) o:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true }) + for k, v in pairs(socks_list) do + o:value(v.id, v.remark) + end for k, v in pairs(balancers_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end for k, v in pairs(iface_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end o.default = "nil" end uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then - o = s:option(Value, option_name(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) + o = s:option(ListValue, option_name(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) o:value("nil", translate("Close")) o:value("_default", translate("Default")) o:value("_direct", translate("Direct Connection")) @@ -129,18 +142,21 @@ uci:foreach(appname, "shunt_rules", function(e) o:depends({ [option_name("protocol")] = "_shunt" }) if #nodes_table > 0 then + for k, v in pairs(socks_list) do + o:value(v.id, v.remark) + end for k, v in pairs(balancers_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end for k, v in pairs(iface_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end local pt = s:option(ListValue, option_name(e[".name"] .. "_proxy_tag"), string.format('* %s', e.remarks .. " " .. translate("Preproxy"))) pt:value("nil", translate("Close")) pt:value("main", translate("Preproxy Node")) pt.default = "nil" for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) pt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name(e[".name"])] = v.id }) end end @@ -155,24 +171,27 @@ o.cfgvalue = function(t, n) end o:depends({ [option_name("protocol")] = "_shunt" }) -local o = s:option(Value, option_name("default_node"), string.format('* %s', translate("Default"))) +local o = s:option(ListValue, option_name("default_node"), string.format('* %s', translate("Default"))) o:depends({ [option_name("protocol")] = "_shunt" }) o:value("_direct", translate("Direct Connection")) o:value("_blackhole", translate("Blackhole")) if #nodes_table > 0 then + for k, v in pairs(socks_list) do + o:value(v.id, v.remark) + end for k, v in pairs(balancers_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end for k, v in pairs(iface_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end local dpt = s:option(ListValue, option_name("default_proxy_tag"), 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.")) dpt:value("nil", translate("Close")) dpt:value("main", translate("Preproxy Node")) dpt.default = "nil" for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) dpt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name("default_node")] = v.id }) end end @@ -328,20 +347,13 @@ o:value("h2", "HTTP/2") o:value("ds", "DomainSocket") o:value("quic", "QUIC") o:value("grpc", "gRPC") +o:value("httpupgrade", "HttpUpgrade") o:depends({ [option_name("protocol")] = "vmess" }) o:depends({ [option_name("protocol")] = "vless" }) o:depends({ [option_name("protocol")] = "socks" }) o:depends({ [option_name("protocol")] = "shadowsocks" }) o:depends({ [option_name("protocol")] = "trojan" }) ---[[ -o = s:option(ListValue, option_name("ss_transport"), translate("Transport")) -o:value("ws", "WebSocket") -o:value("h2", "HTTP/2") -o:value("h2+ws", "HTTP/2 & WebSocket") -o:depends({ [option_name("protocol")] = "shadowsocks" }) -]]-- - o = s:option(Value, option_name("wireguard_public_key"), translate("Public Key")) o:depends({ [option_name("protocol")] = "wireguard" }) @@ -423,22 +435,18 @@ o:depends({ [option_name("transport")] = "mkcp" }) -- [[ WebSocket部分 ]]-- o = s:option(Value, option_name("ws_host"), translate("WebSocket Host")) o:depends({ [option_name("transport")] = "ws" }) -o:depends({ [option_name("ss_transport")] = "ws" }) o = s:option(Value, option_name("ws_path"), translate("WebSocket Path")) o.placeholder = "/" o:depends({ [option_name("transport")] = "ws" }) -o:depends({ [option_name("ss_transport")] = "ws" }) -- [[ HTTP/2部分 ]]-- o = s:option(Value, option_name("h2_host"), translate("HTTP/2 Host")) o:depends({ [option_name("transport")] = "h2" }) -o:depends({ [option_name("ss_transport")] = "h2" }) o = s:option(Value, option_name("h2_path"), translate("HTTP/2 Path")) o.placeholder = "/" o:depends({ [option_name("transport")] = "h2" }) -o:depends({ [option_name("ss_transport")] = "h2" }) o = s:option(Flag, option_name("h2_health_check"), translate("Health check")) o:depends({ [option_name("transport")] = "h2" }) @@ -497,6 +505,14 @@ o = s:option(Value, option_name("grpc_initial_windows_size"), translate("Initial o.default = "0" o:depends({ [option_name("transport")] = "grpc" }) +-- [[ HttpUpgrade部分 ]]-- +o = s:option(Value, option_name("httpupgrade_host"), translate("HttpUpgrade Host")) +o:depends({ [option_name("transport")] = "httpupgrade" }) + +o = s:option(Value, option_name("httpupgrade_path"), translate("HttpUpgrade Path")) +o.placeholder = "/" +o:depends({ [option_name("transport")] = "httpupgrade" }) + -- [[ Mux ]]-- o = s:option(Flag, option_name("mux"), translate("Mux")) o:depends({ [option_name("protocol")] = "vmess" }) @@ -532,7 +548,7 @@ o.default = "" o:value("", translate("Close(Not use)")) for k, v in pairs(nodes_table) do if v.type == "Xray" then - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua index 611a884a7..e4c1e161c 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua @@ -70,36 +70,49 @@ for k, e in ipairs(api.get_valid_nodes()) do if e.node_type == "normal" then nodes_table[#nodes_table + 1] = { id = e[".name"], - remarks = e["remark"], + remark = e["remark"], type = e["type"] } end if e.protocol == "_iface" then iface_table[#iface_table + 1] = { id = e[".name"], - remarks = e["remark"] + remark = e["remark"] } end end +local socks_list = {} +uci:foreach(appname, "socks", function(s) + if s.enabled == "1" and s.node then + socks_list[#socks_list + 1] = { + id = "Socks_" .. s[".name"], + remark = translate("Socks Config") .. " [" .. s.port .. "端口]" + } + end +end) + -- [[ 分流模块 ]] if #nodes_table > 0 then o = s:option(Flag, option_name("preproxy_enabled"), translate("Preproxy")) o:depends({ [option_name("protocol")] = "_shunt" }) - o = s:option(Value, option_name("main_node"), string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default) has a separate switch that controls whether this rule uses the pre-proxy or not.")) + o = s:option(ListValue, option_name("main_node"), string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default) has a separate switch that controls whether this rule uses the pre-proxy or not.")) o:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true }) + for k, v in pairs(socks_list) do + o:value(v.id, v.remark) + end for k, v in pairs(iface_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end o.default = "nil" end uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then - o = s:option(Value, option_name(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) + o = s:option(ListValue, option_name(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) o:value("nil", translate("Close")) o:value("_default", translate("Default")) o:value("_direct", translate("Direct Connection")) @@ -107,15 +120,18 @@ uci:foreach(appname, "shunt_rules", function(e) o:depends({ [option_name("protocol")] = "_shunt" }) if #nodes_table > 0 then + for k, v in pairs(socks_list) do + o:value(v.id, v.remark) + end for k, v in pairs(iface_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end local pt = s:option(ListValue, option_name(e[".name"] .. "_proxy_tag"), string.format('* %s', e.remarks .. " " .. translate("Preproxy"))) pt:value("nil", translate("Close")) pt:value("main", translate("Preproxy Node")) pt.default = "nil" for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) pt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name(e[".name"])] = v.id }) end end @@ -130,21 +146,24 @@ o.cfgvalue = function(t, n) end o:depends({ [option_name("protocol")] = "_shunt" }) -local o = s:option(Value, option_name("default_node"), string.format('* %s', translate("Default"))) +local o = s:option(ListValue, option_name("default_node"), string.format('* %s', translate("Default"))) o:depends({ [option_name("protocol")] = "_shunt" }) o:value("_direct", translate("Direct Connection")) o:value("_blackhole", translate("Blackhole")) if #nodes_table > 0 then + for k, v in pairs(socks_list) do + o:value(v.id, v.remark) + end for k, v in pairs(iface_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end local dpt = s:option(ListValue, option_name("default_proxy_tag"), 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.")) dpt:value("nil", translate("Close")) dpt:value("main", translate("Preproxy Node")) dpt.default = "nil" for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) + o:value(v.id, v.remark) dpt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name("default_node")] = v.id }) end end @@ -615,7 +634,7 @@ o:value("v2ray-plugin") o = s:option(Value, option_name("plugin_opts"), translate("opts")) o:depends({ [option_name("plugin_enabled")] = true }) -o = s:option(ListValue, option_name("domain_strategy"), "Domain Strategy", translate("If is domain name, The requested domain name will be resolved to IP before connect.")) +o = s:option(ListValue, option_name("domain_strategy"), translate("Domain Strategy"), translate("If is domain name, The requested domain name will be resolved to IP before connect.")) o.default = "prefer_ipv6" o:value("prefer_ipv4") o:value("prefer_ipv6") @@ -627,7 +646,7 @@ o.default = "" o:value("", translate("Close(Not use)")) for k, v in pairs(nodes_table) do if v.type == "sing-box" then - o:value(v.id, v.remarks) + o:value(v.id, v.remark) end end for i, v in ipairs(s.fields[option_name("protocol")].keylist) do diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/brook.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/brook.lua deleted file mode 100644 index c79ae2e4d..000000000 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/brook.lua +++ /dev/null @@ -1,41 +0,0 @@ -local m, s = ... - -local api = require "luci.passwall2.api" - -if not api.finded_com("brook") then - return -end - -local type_name = "Brook" - -local option_prefix = "brook_" - -local function option_name(name) - return option_prefix .. name -end - --- [[ Brook ]] - -s.fields["type"]:value(type_name, translate("Brook")) - -o = s:option(Value, option_name("port"), translate("Listen Port")) -o.datatype = "port" - -o = s:option(ListValue, option_name("protocol"), translate("Protocol")) -o:value("server", "Brook") -o:value("wsserver", "WebSocket") - ---o = s:option(Flag, option_name("tls"), translate("Use TLS")) ---o:depends({ [option_name("protocol")] = "wsserver" }) - -o = s:option(Value, option_name("password"), translate("Password")) -o.password = true - -o = s:option(Value, option_name("ws_path"), translate("WebSocket Path")) -o:depends({ [option_name("protocol")] = "wsserver" }) - -o = s:option(Flag, option_name("log"), translate("Log")) -o.default = "1" -o.rmempty = false - -api.luci_types(arg[1], m, s, type_name, option_prefix) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua index 642154734..1f352ad92 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua @@ -202,6 +202,7 @@ o:value("h2", "HTTP/2") o:value("ds", "DomainSocket") o:value("quic", "QUIC") o:value("grpc", "gRPC") +o:value("httpupgrade", "HttpUpgrade") o:depends({ [option_name("protocol")] = "vmess" }) o:depends({ [option_name("protocol")] = "vless" }) o:depends({ [option_name("protocol")] = "socks" }) @@ -216,6 +217,14 @@ o:depends({ [option_name("transport")] = "ws" }) o = s:option(Value, option_name("ws_path"), translate("WebSocket Path")) o:depends({ [option_name("transport")] = "ws" }) +-- [[ HttpUpgrade部分 ]]-- +o = s:option(Value, option_name("httpupgrade_host"), translate("HttpUpgrade Host")) +o:depends({ [option_name("transport")] = "httpupgrade" }) + +o = s:option(Value, option_name("httpupgrade_path"), translate("HttpUpgrade Path")) +o.placeholder = "/" +o:depends({ [option_name("transport")] = "httpupgrade" }) + -- [[ HTTP/2部分 ]]-- o = s:option(Value, option_name("h2_host"), translate("HTTP/2 Host")) diff --git a/luci-app-passwall2/luasrc/passwall2/api.lua b/luci-app-passwall2/luasrc/passwall2/api.lua index 5f0da5c3d..68cc0f383 100644 --- a/luci-app-passwall2/luasrc/passwall2/api.lua +++ b/luci-app-passwall2/luasrc/passwall2/api.lua @@ -73,7 +73,7 @@ end function curl_proxy(url, file, args) --使用代理 - local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall2/global_SOCKS_server ] && echo -n $(cat /tmp/etc/passwall2/global_SOCKS_server) || echo -n ''") + local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall2/acl/default/SOCKS_server ] && echo -n $(cat /tmp/etc/passwall2/acl/default/SOCKS_server) || echo -n ''") if socks_server ~= "" then if not args then args = {} end local tmp_args = clone(args) diff --git a/luci-app-passwall2/luasrc/passwall2/com.lua b/luci-app-passwall2/luasrc/passwall2/com.lua index 69e5c6930..f3e24e0d1 100644 --- a/luci-app-passwall2/luasrc/passwall2/com.lua +++ b/luci-app-passwall2/luasrc/passwall2/com.lua @@ -8,17 +8,6 @@ local function gh_pre_release_url(self) return "https://api.github.com/repos/" .. self.repo .. "/releases?per_page=1" end -_M.brook = { - name = "Brook", - repo = "txthinking/brook", - get_url = gh_release_url, - cmd_version = "-v | awk '{print $3}'", - zipped = false, - default_path = "/usr/bin/brook", - match_fmt_str = "linux_%s$", - file_tree = {} -} - _M.hysteria = { name = "Hysteria", repo = "HyNetwork/hysteria", diff --git a/luci-app-passwall2/luasrc/passwall2/server_app.lua b/luci-app-passwall2/luasrc/passwall2/server_app.lua index eadef9270..e9b905cd7 100644 --- a/luci-app-passwall2/luasrc/passwall2/server_app.lua +++ b/luci-app-passwall2/luasrc/passwall2/server_app.lua @@ -150,15 +150,6 @@ local function start() elseif type == "sing-box" then config = require(require_dir .. "util_sing-box").gen_config_server(user) bin = ln_run(api.get_app_path("singbox"), "sing-box", "run -c " .. config_file, log_path) - elseif type == "Brook" then - local brook_protocol = user.protocol - local brook_password = user.password - local brook_path = user.ws_path or "/ws" - local brook_path_arg = "" - if brook_protocol == "wsserver" and brook_path then - brook_path_arg = " --path " .. brook_path - end - bin = ln_run(api.get_app_path("brook"), "brook_" .. id, string.format("--debug %s -l :%s -p %s%s", brook_protocol, port, brook_password, brook_path_arg), log_path) elseif type == "Hysteria2" then config = require(require_dir .. "util_hysteria2").gen_config_server(user) bin = ln_run(api.get_app_path("hysteria"), "hysteria", "-c " .. config_file .. " server", log_path) diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua index 77c1e220c..ff9e57757 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua @@ -928,22 +928,23 @@ function gen_config(var) local preproxy_node_id = node["main_node"] local preproxy_node = preproxy_enabled and preproxy_node_id and uci:get_all(appname, preproxy_node_id) or nil - if not preproxy_node and preproxy_node_id and api.parseURL(preproxy_node_id) then - local parsed1 = api.parseURL(preproxy_node_id) - local _node = { - type = "sing-box", - protocol = parsed1.protocol, - username = parsed1.username, - password = parsed1.password, - address = parsed1.host, - port = parsed1.port, - uot = "1", - } - local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag) - if preproxy_outbound then - table.insert(outbounds, preproxy_outbound) - else - preproxy_enabled = false + if preproxy_node_id and preproxy_node_id:find("Socks_") then + local socks_id = preproxy_node_id:sub(1 + #"Socks_") + local socks_node = uci:get_all(appname, socks_id) or nil + if socks_node then + local _node = { + type = "sing-box", + protocol = "socks", + address = "127.0.0.1", + port = socks_node.port, + uot = "1", + } + local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag) + if preproxy_outbound then + table.insert(outbounds, preproxy_outbound) + else + preproxy_enabled = false + end end elseif preproxy_node and api.is_normal_node(preproxy_node) then local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag) @@ -965,21 +966,22 @@ function gen_config(var) rule_outboundTag = "block" elseif _node_id == "_default" and rule_name ~= "default" then rule_outboundTag = "default" - elseif api.parseURL(_node_id) then - local parsed1 = api.parseURL(_node_id) - local _node = { - type = "sing-box", - protocol = parsed1.protocol, - username = parsed1.username, - password = parsed1.password, - address = parsed1.host, - port = parsed1.port, - uot = "1", - } - local _outbound = gen_outbound(flag, _node, rule_name) - if _outbound then - table.insert(outbounds, _outbound) - rule_outboundTag = rule_name + elseif _node_id:find("Socks_") then + local socks_id = _node_id:sub(1 + #"Socks_") + local socks_node = uci:get_all(appname, socks_id) or nil + if socks_node then + local _node = { + type = "sing-box", + protocol = "socks", + address = "127.0.0.1", + port = socks_node.port, + uot = "1", + } + local _outbound = gen_outbound(flag, _node, rule_name) + if _outbound then + table.insert(outbounds, _outbound) + rule_outboundTag = rule_name + end end elseif _node_id ~= "nil" then local _node = uci:get_all(appname, _node_id) diff --git a/luci-app-passwall2/luasrc/passwall2/util_xray.lua b/luci-app-passwall2/luasrc/passwall2/util_xray.lua index 3d26ed0be..3fd36e507 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_xray.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_xray.lua @@ -197,7 +197,11 @@ function gen_outbound(flag, node, tag, proxy_table) health_check_timeout = tonumber(node.grpc_health_check_timeout) or nil, permit_without_stream = (node.grpc_permit_without_stream == "1") and true or nil, initial_windows_size = tonumber(node.grpc_initial_windows_size) or nil - } or nil + } or nil, + httpupgradeSettings = (node.transport == "httpupgrade") and { + path = node.httpupgrade_path or "/", + host = node.httpupgrade_host + } or nil, } or nil, settings = { vnext = (node.protocol == "vmess" or node.protocol == "vless") and { @@ -469,6 +473,10 @@ function gen_config_server(node) grpcSettings = (node.transport == "grpc") and { serviceName = node.grpc_serviceName } or nil, + httpupgradeSettings = (node.transport == "httpupgrade") and { + path = node.httpupgrade_path or "/", + host = node.httpupgrade_host + } or nil, sockopt = { acceptProxyProtocol = (node.acceptProxyProtocol and node.acceptProxyProtocol == "1") and true or false } @@ -740,23 +748,24 @@ function gen_config(var) local preproxy_node = preproxy_enabled and preproxy_node_id and uci:get_all(appname, preproxy_node_id) or nil local preproxy_is_balancer - if not preproxy_node and preproxy_node_id and api.parseURL(preproxy_node_id) then - local parsed1 = api.parseURL(preproxy_node_id) - local _node = { - type = "Xray", - protocol = parsed1.protocol, - username = parsed1.username, - password = parsed1.password, - address = parsed1.host, - port = parsed1.port, - transport = "tcp", - stream_security = "none" - } - local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag) - if preproxy_outbound then - table.insert(outbounds, preproxy_outbound) - else - preproxy_enabled = false + if preproxy_node_id and preproxy_node_id:find("Socks_") then + local socks_id = preproxy_node_id:sub(1 + #"Socks_") + local socks_node = uci:get_all(appname, socks_id) or nil + if socks_node then + local _node = { + type = "Xray", + protocol = "socks", + address = "127.0.0.1", + port = socks_node.port, + transport = "tcp", + stream_security = "none" + } + local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag) + if preproxy_outbound then + table.insert(outbounds, preproxy_outbound) + else + preproxy_enabled = false + end end elseif preproxy_node and api.is_normal_node(preproxy_node) then local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag, { fragment = xray_settings.fragment == "1" or nil }) @@ -788,22 +797,23 @@ function gen_config(var) rule_outboundTag = "blackhole" elseif _node_id == "_default" and rule_name ~= "default" then rule_outboundTag = "default" - elseif api.parseURL(_node_id) then - local parsed1 = api.parseURL(_node_id) - local _node = { - type = "Xray", - protocol = parsed1.protocol, - username = parsed1.username, - password = parsed1.password, - address = parsed1.host, - port = parsed1.port, - transport = "tcp", - stream_security = "none" - } - local _outbound = gen_outbound(flag, _node, rule_name) - if _outbound then - table.insert(outbounds, _outbound) - rule_outboundTag = rule_name + elseif _node_id:find("Socks_") then + local socks_id = _node_id:sub(1 + #"Socks_") + local socks_node = uci:get_all(appname, socks_id) or nil + if socks_node then + local _node = { + type = "Xray", + protocol = "socks", + address = "127.0.0.1", + port = socks_node.port, + transport = "tcp", + stream_security = "none" + } + local _outbound = gen_outbound(flag, _node, rule_name) + if _outbound then + table.insert(outbounds, _outbound) + rule_outboundTag = rule_name + end end elseif _node_id ~= "nil" then local _node = uci:get_all(appname, _node_id) diff --git a/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm b/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm index d3f6dc32b..60aac5c7e 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm @@ -53,22 +53,28 @@ local api = require "luci.passwall2.api" var dom_id = dom.id.split(cbi_id).join(cbi_id.split("-").join(".")).split("cbi.").join("cbid.") var node_select = document.getElementsByName(dom_id)[0]; var node_select_value = node_select.value; - if (node_select_value && node_select_value != "nil" && node_select_value.indexOf("socks://") != 0 && node_select_value.indexOf("_default") != 0 && node_select_value.indexOf("_direct") != 0 && node_select_value.indexOf("_blackhole") != 0) { + if (node_select_value && node_select_value != "nil" && node_select_value.indexOf("_default") != 0 && node_select_value.indexOf("_direct") != 0 && node_select_value.indexOf("_blackhole") != 0) { if (node_select.tagName == "INPUT") { node_select = document.getElementById("cbi.combobox." + dom_id); } - var new_a = document.createElement("a"); - new_a.innerHTML = "<%:Edit%>"; - new_a.href = "#"; - new_a.setAttribute("onclick", "location.href='" + '<%=api.url("node_config")%>' + "/" + node_select_value + "'"); - var new_html = new_a.outerHTML; + if (true) { + var to_url = "<%=api.url("node_config")%>/" + node_select_value; + if (node_select_value.indexOf("Socks_") == 0) { + to_url = "<%=api.url("socks_config")%>/" + node_select_value.substring("Socks_".length); + } + var new_a = document.createElement("a"); + new_a.innerHTML = "<%:Edit%>"; + new_a.href = "#"; + new_a.setAttribute("onclick", "location.href='" + to_url + "'"); + var new_html = new_a.outerHTML; + } if (s[0] == "") { var log_a = document.createElement("a"); log_a.innerHTML = "<%:Log%>"; log_a.href = "#"; - log_a.setAttribute("onclick", "window.open('" + '<%=api.url("get_redir_log")%>' + "?id=" + "global" + "', '_blank')"); + log_a.setAttribute("onclick", "window.open('" + '<%=api.url("get_redir_log")%>' + "?id=default&name=global" + "', '_blank')"); new_html += "  " + log_a.outerHTML; } diff --git a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm index f2c324a39..037caf3d2 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm @@ -137,9 +137,6 @@ local api = require "luci.passwall2.api" } else if (v_type === "SSR") { dom_prefix = "ssr_" protocol = "ssr" - } else if (v_type === "Brook") { - dom_prefix = "brook_" - protocol = "brook" } else if (v_type === "Hysteria2") { dom_prefix = "hysteria2_" protocol = "hysteria2" @@ -344,34 +341,6 @@ local api = require "luci.passwall2.api" params = params.substring(1); } url += params; - } else if (v_type === "Brook") { - var url = ""; - var params = "?"; - var v_protocol = opt.get(dom_prefix + "protocol"); - var v_port = opt.get(dom_prefix + "port"); - var v_password = opt.get(dom_prefix + "password"); - var b_protocol_value = v_protocol.value.split('client').join('server'); - - var url_protocol = b_protocol_value; - params += opt.query("password", dom_prefix + "password"); - if (b_protocol_value == "wsserver") { - var server = ''; - var prefix = "ws://"; - if (opt.get(dom_prefix + "tls").checked) { - prefix = "wss://"; - url_protocol = 'wssserver'; - } - var v_path = opt.get(dom_prefix + "ws_path"); - var v_path_value = v_path.value || '/ws'; - if (v_path_value.length > 1 && v_path_value.indexOf('/') < 0) { - v_path_value = '/' + v_path_value; - } - params += "&" + url_protocol + "=" + encodeURIComponent(prefix + _address + ":" + v_port.value + v_path_value); - } else { - params += "&" + url_protocol + "=" + encodeURIComponent(_address + ":" + v_port.value); - } - url += url_protocol; - url += params; } else if ((v_type === "Hysteria2") || (v_type === "sing-box" && opt.get(dom_prefix + "protocol").value === "hysteria2")) { protocol = "hysteria2"; var v_port = opt.get(dom_prefix + "port"); @@ -871,63 +840,6 @@ local api = require "luci.passwall2.api" opt.set('remarks', decodeURI(m.hash.substr(1))); } } - if (ssu[0] === "brook") { - dom_prefix = "brook_" - var stype = "Brook"; - var m = parseNodeUrl(ssrurl); - - var from_protocol = m.host; - var protocol = from_protocol.split('server').join('client'); - - var queryParam = {}; - if (m.search.length > 1) { - var query = m.search.split('?'); - var queryParams = query[1]; - var queryArray = queryParams.split('&'); - var params; - for (i = 0; i < queryArray.length; i++) { - params = queryArray[i].split('='); - queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || ''); - } - } - - var password = queryParam.password; - if (password === "") { - s.innerHTML = "<%:Invalid Share URL Format%>"; - return false; - } - - opt.set('type', stype); - opt.set(dom_prefix + 'protocol', protocol); - opt.set(dom_prefix + 'password', password); - - if (protocol == 'wsclient' || protocol == 'wssclient') { - opt.set(dom_prefix + 'protocol', 'wsclient'); - var wsserver = queryParam[from_protocol].split('://'); - wsserver = wsserver[1].split('/'); - var path = wsserver[1] && '/' + wsserver[1] || '/ws'; - var server = wsserver[0].split(':'); - opt.set(dom_prefix + 'address', server[0]); - opt.set(dom_prefix + 'port', server[1]); - opt.set(dom_prefix + 'ws_path', path); - if (protocol == 'wssclient') { - opt.set(dom_prefix + 'tls', true); - } - } else { - var server = queryParam[from_protocol].split(':'); - if (server.length < 2) { - s.innerHTML = "<%:Invalid Share URL Format%>"; - return false; - } - opt.set(dom_prefix + 'address', server[0]); - opt.set(dom_prefix + 'port', server[1]); - } - - if (m.hash) { - opt.set('remarks', decodeURI(m.hash.substr(1))); - } - } - if (ssu[0] === "hysteria2" || ssu[0] === "hy2") { var m = parseNodeUrl(ssrurl); var password = m.passwd; diff --git a/luci-app-passwall2/po/zh-cn/passwall2.po b/luci-app-passwall2/po/zh-cn/passwall2.po index d1f82d163..07c45d34f 100644 --- a/luci-app-passwall2/po/zh-cn/passwall2.po +++ b/luci-app-passwall2/po/zh-cn/passwall2.po @@ -850,12 +850,6 @@ msgstr "%s 程序路径" msgid "%s Client App Path" msgstr "%s 客户端程序路径" -msgid "Trojan-Go Version API" -msgstr "Trojan-Go 版本 API" - -msgid "alternate API URL for version checking" -msgstr "用于版本检查的 API URL" - msgid "Node Subscribe" msgstr "节点订阅" @@ -1066,12 +1060,6 @@ msgstr "插件名称" msgid "Plugin Arguments" msgstr "插件参数" -msgid "Brook Protocol" -msgstr "Brook协议" - -msgid "Use TLS" -msgstr "使用TLS" - msgid "Naiveproxy Protocol" msgstr "Naiveproxy协议" diff --git a/luci-app-passwall2/root/usr/share/passwall2/0_default_config b/luci-app-passwall2/root/usr/share/passwall2/0_default_config index 5392092bc..464f5c84e 100644 --- a/luci-app-passwall2/root/usr/share/passwall2/0_default_config +++ b/luci-app-passwall2/root/usr/share/passwall2/0_default_config @@ -51,7 +51,6 @@ config global_rules config global_app option xray_file '/usr/bin/xray' - option brook_file '/usr/bin/brook' option hysteria_file '/usr/bin/hysteria' option singbox_file '/usr/bin/sing-box' diff --git a/luci-app-passwall2/root/usr/share/passwall2/app.sh b/luci-app-passwall2/root/usr/share/passwall2/app.sh index a9ee2150d..b74cc62b5 100644 --- a/luci-app-passwall2/root/usr/share/passwall2/app.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/app.sh @@ -9,7 +9,6 @@ TMP_PATH=/tmp/etc/$CONFIG TMP_BIN_PATH=$TMP_PATH/bin TMP_SCRIPT_FUNC_PATH=$TMP_PATH/script_func TMP_ID_PATH=$TMP_PATH/id -TMP_PORT_PATH=$TMP_PATH/port TMP_ROUTE_PATH=$TMP_PATH/route TMP_ACL_PATH=$TMP_PATH/acl TMP_IFACE_PATH=$TMP_PATH/iface @@ -561,21 +560,6 @@ run_socks() { lua $UTIL_NAIVE gen_config -node $node -run_type socks -local_addr $bind -local_port $socks_port -server_host $server_host -server_port $port > $config_file ln_run "$(first_type naive)" naive $log_file "$config_file" ;; - brook) - local protocol=$(config_n_get $node protocol client) - local prefix="" - [ "$protocol" == "wsclient" ] && { - prefix="ws://" - local brook_tls=$(config_n_get $node brook_tls 0) - [ "$brook_tls" == "1" ] && { - prefix="wss://" - protocol="wssclient" - } - local ws_path=$(config_n_get $node ws_path "/ws") - } - server_host=${prefix}${server_host} - ln_run "$(first_type $(config_t_get global_app brook_file) brook)" "brook_SOCKS_${flag}" $log_file "$protocol" --socks5 "$bind:$socks_port" -s "${server_host}:${port}${ws_path}" -p "$(config_n_get $node password)" - ;; ssr) lua $UTIL_SS gen_config -node $node -local_addr "0.0.0.0" -local_port $socks_port -server_host $server_host -server_port $port > $config_file ln_run "$(first_type ssr-local)" "ssr-local" $log_file -c "$config_file" -v -u @@ -653,14 +637,8 @@ run_global() { [ "$NODE" = "nil" ] && return 1 TYPE=$(echo $(config_n_get $NODE type nil) | tr 'A-Z' 'a-z') [ "$TYPE" = "nil" ] && return 1 - echo $REDIR_PORT > $TMP_PORT_PATH/global - echo $NODE > $TMP_ID_PATH/global - [ "$(config_n_get $NODE protocol nil)" = "_shunt" ] && { - local default_node=$(config_n_get $NODE default_node nil) - local main_node=$(config_n_get $NODE main_node nil) - echo $default_node > $TMP_ID_PATH/global_default - echo $main_node > $TMP_ID_PATH/global_main - } + mkdir -p $TMP_ACL_PATH/default + echo $NODE > $TMP_ACL_PATH/default/global.id if [ $PROXY_IPV6 == "1" ]; then echolog "开启实验性IPv6透明代理(TProxy),请确认您的节点及类型支持IPv6!" @@ -701,14 +679,14 @@ run_global() { source $APP_PATH/helper_dnsmasq.sh stretch source $APP_PATH/helper_dnsmasq.sh add TMP_DNSMASQ_PATH=$TMP_DNSMASQ_PATH DNSMASQ_CONF_FILE=/tmp/dnsmasq.d/dnsmasq-passwall2.conf DEFAULT_DNS=$AUTO_DNS LOCAL_DNS=$LOCAL_DNS TUN_DNS=$TUN_DNS NFTFLAG=${nftflag:-0} - V2RAY_CONFIG=$TMP_PATH/global.json - V2RAY_LOG=$TMP_PATH/global.log + V2RAY_CONFIG=$TMP_ACL_PATH/default/global.json + V2RAY_LOG=$TMP_ACL_PATH/default/global.log [ "$(config_t_get global close_log 1)" = "1" ] && V2RAY_LOG="/dev/null" V2RAY_ARGS="${V2RAY_ARGS} log_file=${V2RAY_LOG} config_file=${V2RAY_CONFIG}" node_socks_port=$(config_t_get global node_socks_port 1070) V2RAY_ARGS="${V2RAY_ARGS} socks_port=${node_socks_port}" - echo "127.0.0.1:$node_socks_port" > $TMP_PATH/global_SOCKS_server + echo "127.0.0.1:$node_socks_port" > $TMP_ACL_PATH/default/SOCKS_server node_http_port=$(config_t_get global node_http_port 0) [ "$node_http_port" != "0" ] && V2RAY_ARGS="${V2RAY_ARGS} http_port=${node_http_port}" @@ -1149,7 +1127,7 @@ SINGBOX_BIN=$(first_type $(config_t_get global_app singbox_file) sing-box) export V2RAY_LOCATION_ASSET=$(config_t_get global_rules v2ray_location_asset "/usr/share/v2ray/") export XRAY_LOCATION_ASSET=$V2RAY_LOCATION_ASSET -mkdir -p /tmp/etc $TMP_PATH $TMP_BIN_PATH $TMP_SCRIPT_FUNC_PATH $TMP_ID_PATH $TMP_PORT_PATH $TMP_ROUTE_PATH $TMP_ACL_PATH $TMP_IFACE_PATH $TMP_PATH2 +mkdir -p /tmp/etc $TMP_PATH $TMP_BIN_PATH $TMP_SCRIPT_FUNC_PATH $TMP_ID_PATH $TMP_ROUTE_PATH $TMP_ACL_PATH $TMP_IFACE_PATH $TMP_PATH2 arg1=$1 shift diff --git a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh index e26198477..38c15f8c4 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh @@ -191,7 +191,7 @@ load_acl() { [ "$ENABLED_ACLS" == 1 ] && { acl_app echolog "访问控制:" - for sid in $(ls -F ${TMP_ACL_PATH} | grep '/$' | awk -F '/' '{print $1}'); do + for sid in $(ls -F ${TMP_ACL_PATH} | grep '/$' | awk -F '/' '{print $1}' | grep -v 'default'); do eval $(uci -q show "${CONFIG}.${sid}" | cut -d'.' -sf 3-) tcp_no_redir_ports=${tcp_no_redir_ports:-default} diff --git a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh index 13301db9b..e502ed866 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh @@ -218,7 +218,7 @@ load_acl() { [ "$ENABLED_ACLS" == 1 ] && { acl_app echolog "访问控制:" - for sid in $(ls -F ${TMP_ACL_PATH} | grep '/$' | awk -F '/' '{print $1}'); do + for sid in $(ls -F ${TMP_ACL_PATH} | grep '/$' | awk -F '/' '{print $1}' | grep -v 'default'); do eval $(uci -q show "${CONFIG}.${sid}" | cut -d'.' -sf 3-) tcp_no_redir_ports=${tcp_no_redir_ports:-default}