From ce265f893301712789c825431632742a47d6b629 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:22:03 +0800 Subject: [PATCH] update 2023-04-18 16:22:03 --- luci-app-passwall/Makefile | 2 +- .../model/cbi/passwall/client/global.lua | 41 ++++++++------- .../model/cbi/passwall/client/node_config.lua | 8 +-- luci-app-passwall/luasrc/passwall/api.lua | 36 +++++++++++++ .../luasrc/passwall/util_xray.lua | 51 +++++++++++++++++-- luci-app-passwall/po/zh-cn/passwall.po | 3 ++ .../root/usr/share/passwall/app.sh | 4 +- .../root/usr/share/passwall/iptables.sh | 2 + .../root/usr/share/passwall/nftables.sh | 2 + .../root/usr/libexec/argon/online_wallpaper | 8 +-- wxbase/Makefile | 4 +- xray-plugin/Makefile | 4 +- 12 files changed, 127 insertions(+), 38 deletions(-) mode change 100644 => 100755 luci-theme-argon/root/usr/libexec/argon/online_wallpaper diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 43aec5916..bd8d99663 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=4.64-3 +PKG_VERSION:=4.64-4 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ 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 97fd8997c..0fde5ea83 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -85,28 +85,31 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch")) o.rmempty = false local auto_switch_tip -local auto_switch_flag +local shunt_remark local current_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP' ] && echo -n $(cat /tmp/etc/%s/id/TCP)", appname, appname)) if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then local n = uci:get_all(appname, current_tcp_node) if n then if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then - auto_switch_flag = "" if n.protocol == "_shunt" then local shunt_logic = tonumber(m:get("@auto_switch[0]", "shunt_logic")) - if shunt_logic == 1 then - auto_switch_flag = "default" - elseif shunt_logic == 2 then - auto_switch_flag = "main" - end - current_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP_%s' ] && echo -n $(cat /tmp/etc/%s/id/TCP_%s)", appname, auto_switch_flag, appname, auto_switch_flag)) - if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then - n = uci:get_all(appname, current_tcp_node) + 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_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP_%s' ] && echo -n $(cat /tmp/etc/%s/id/TCP_%s)", appname, shunt_remark, appname, shunt_remark)) + if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then + n = uci:get_all(appname, current_tcp_node) + end end end - 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)) .. "
" + 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 @@ -114,7 +117,7 @@ end ---- TCP Node tcp_node = s:taboption("Main", ListValue, "tcp_node", "" .. translate("TCP Node") .. "") tcp_node:value("nil", translate("Close")) -if auto_switch_flag == "" and auto_switch_tip then +if not shunt_remark and auto_switch_tip then tcp_node.description = auto_switch_tip end @@ -171,7 +174,7 @@ if (has_v2ray 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", 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 = 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:depends(vid .. "-preproxy_enabled", "1") for k1, v1 in pairs(balancing_list) do o:value(v1.id, v1.remark) @@ -181,7 +184,7 @@ 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 auto_switch_flag == "main" and auto_switch_tip then + if shunt_remark == "main" and auto_switch_tip then o.description = auto_switch_tip end @@ -195,7 +198,7 @@ if (has_v2ray 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", ListValue, node_option, string.format('* %s', api.url("shunt_rules", id), e.remarks)) + o = s:taboption("Main", Value, 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("tcp_node", v.id) @@ -221,7 +224,7 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then end) local id = "default_node" - o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* %s', translate("Default"))) + o = s:taboption("Main", Value, vid .. "-" .. id, string.format('* %s', translate("Default"))) o.cfgvalue = get_cfgvalue(v.id, id) o.write = get_write(v.id, id) o:depends("tcp_node", v.id) @@ -233,7 +236,7 @@ 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 auto_switch_flag == "default" and auto_switch_tip then + if shunt_remark == "default" and auto_switch_tip then o.description = auto_switch_tip end diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua index 82ea82dd8..34083d657 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua @@ -175,7 +175,7 @@ probeInterval.description = translate("The interval between initiating probes. E if #nodes_table > 0 then o = s:option(Flag, "preproxy_enabled", translate("Preproxy")) o:depends("protocol", "_shunt") - o = s:option(ListValue, "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(Value, "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("preproxy_enabled", "1") for k, v in pairs(balancers_table) do o:value(v.id, v.remarks) @@ -187,7 +187,7 @@ if #nodes_table > 0 then end uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then - o = s:option(ListValue, e[".name"], string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) + o = s:option(Value, 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")) @@ -217,7 +217,7 @@ shunt_tips.cfgvalue = function(t, n) end shunt_tips:depends("protocol", "_shunt") -local default_node = s:option(ListValue, "default_node", string.format('* %s', translate("Default"))) +local default_node = s:option(Value, "default_node", string.format('* %s', translate("Default"))) default_node:depends("protocol", "_shunt") default_node:value("_direct", translate("Direct Connection")) default_node:value("_blackhole", translate("Blackhole")) @@ -749,7 +749,7 @@ wireguard_mtu.default = "1420" wireguard_mtu:depends({ type = "Xray", protocol = "wireguard" }) if api.compare_versions(api.get_app_version("xray"), ">=", "1.8.0") then - wireguard_reserved = s:option(Value, "wireguard_reserved", translate("Reserved")) + wireguard_reserved = s:option(Value, "wireguard_reserved", translate("Reserved"), translate("Decimal numbers separated by \",\" or Base64-encoded strings.")) wireguard_reserved:depends({ type = "Xray", protocol = "wireguard" }) end diff --git a/luci-app-passwall/luasrc/passwall/api.lua b/luci-app-passwall/luasrc/passwall/api.lua index 19ceeeb83..e20ce6e0f 100644 --- a/luci-app-passwall/luasrc/passwall/api.lua +++ b/luci-app-passwall/luasrc/passwall/api.lua @@ -1,5 +1,6 @@ module("luci.passwall.api", package.seeall) local com = require "luci.passwall.com" +bin = require "nixio".bin fs = require "nixio.fs" sys = require "luci.sys" uci = require"luci.model.uci".cursor() @@ -610,6 +611,41 @@ local function auto_get_arch() return util.trim(arch) end +function parseURL(url) + local pattern = "^(%w+)://" + local protocol = url:match(pattern) + + if not protocol then + --error("Invalid URL: " .. url) + return nil + end + + local auth_host_port = url:sub(#protocol + 4) + local auth_pattern = "^([^@]+)@" + local auth = auth_host_port:match(auth_pattern) + local username, password + + if auth then + username, password = auth:match("^([^:]+):([^:]+)$") + auth_host_port = auth_host_port:sub(#auth + 2) + end + + local host, port = auth_host_port:match("^([^:]+):(%d+)$") + + if not host or not port then + --error("Invalid URL: " .. url) + return nil + end + + return { + protocol = protocol, + username = username, + password = password, + host = host, + port = tonumber(port) + } +end + local default_file_tree = { x86_64 = "amd64", x86 = "386", diff --git a/luci-app-passwall/luasrc/passwall/util_xray.lua b/luci-app-passwall/luasrc/passwall/util_xray.lua index 3b0825124..996edbcf4 100644 --- a/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -102,9 +102,16 @@ function gen_outbound(flag, node, tag, proxy_table) if node.protocol == "wireguard" and node.wireguard_reserved then local bytes = {} - node.wireguard_reserved:gsub("[^,]+", function(b) - bytes[#bytes+1] = tonumber(b) - end) + if not node.wireguard_reserved:match("[^%d,]+") then + node.wireguard_reserved:gsub("%d+", function(b) + bytes[#bytes + 1] = tonumber(b) + end) + else + local result = api.bin.b64decode(node.wireguard_reserved) + for i = 1, #result do + bytes[i] = result:byte(i) + end + end node.wireguard_reserved = #bytes > 0 and bytes or nil end @@ -667,7 +674,26 @@ 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 local preproxy_is_balancer - if preproxy_node and api.is_normal_node(preproxy_node) then + + if not preproxy_node 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 + end + elseif preproxy_node and api.is_normal_node(preproxy_node) then local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag) if preproxy_outbound then table.insert(outbounds, preproxy_outbound) @@ -696,6 +722,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 + end elseif _node_id ~= "nil" then local _node = uci:get_all(appname, _node_id) if not _node then return nil, nil end diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 4408869a2..2223796c8 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -1117,6 +1117,9 @@ msgstr "额外的对称加密密钥" msgid "Local Address" msgstr "本地地址" +msgid "Decimal numbers separated by \",\" or Base64-encoded strings." +msgstr "用“,”隔开的十进制数字或 Base64 编码字符串。" + msgid "Camouflage Type" msgstr "伪装类型" diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 76fbb8948..4d01fed98 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -1519,8 +1519,8 @@ start() { elif [ "$use_nft" == 1 ] && [ -n "$(dnsmasq --version | grep 'Compile time options:.* nftset')" ]; then USE_TABLES="nftables" nftflag=1 - elif [ -z "$(command -v iptables-legacy || command -v iptables)" ] || [ -z "$(command -v ipset)" ]; then - echolog "系统未安装iptables或ipset,无法透明代理!" + elif [ -z "$(command -v iptables-legacy || command -v iptables)" ] || [ -z "$(command -v ipset)" ] || [ -z "$(dnsmasq --version | grep 'Compile time options:.* ipset')" ]; then + echolog "系统未安装iptables或ipset或Dnsmasq没有开启ipset支持,无法透明代理!" else USE_TABLES="iptables" fi diff --git a/luci-app-passwall/root/usr/share/passwall/iptables.sh b/luci-app-passwall/root/usr/share/passwall/iptables.sh index 707515d3c..65f85123e 100755 --- a/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -285,6 +285,8 @@ load_acl() { [ -s "${TMP_ACL_PATH}/${sid}/var_udp_node" ] && udp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_node) [ -s "${TMP_ACL_PATH}/${sid}/var_tcp_port" ] && tcp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_port) [ -s "${TMP_ACL_PATH}/${sid}/var_udp_port" ] && udp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_port) + + [ "$udp_node" == "default" ] && [ "$UDP_NODE" = "nil" ] && [ "$TCP_UDP" = "1" ] && udp_node=$TCP_NODE [ -n "$tcp_node" ] && [ "$tcp_node" != "default" ] && tcp_node_remark=$(config_n_get $tcp_node remarks) [ -n "$udp_node" ] && [ "$udp_node" != "default" ] && udp_node_remark=$(config_n_get $udp_node remarks) diff --git a/luci-app-passwall/root/usr/share/passwall/nftables.sh b/luci-app-passwall/root/usr/share/passwall/nftables.sh index 072954dc3..53ba6e721 100755 --- a/luci-app-passwall/root/usr/share/passwall/nftables.sh +++ b/luci-app-passwall/root/usr/share/passwall/nftables.sh @@ -296,6 +296,8 @@ load_acl() { [ -s "${TMP_ACL_PATH}/${sid}/var_udp_node" ] && udp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_node) [ -s "${TMP_ACL_PATH}/${sid}/var_tcp_port" ] && tcp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_port) [ -s "${TMP_ACL_PATH}/${sid}/var_udp_port" ] && udp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_port) + + [ "$udp_node" == "default" ] && [ "$UDP_NODE" = "nil" ] && [ "$TCP_UDP" = "1" ] && udp_node=$TCP_NODE [ -n "$tcp_node" ] && [ "$tcp_node" != "default" ] && tcp_node_remark=$(config_n_get $tcp_node remarks) [ -n "$udp_node" ] && [ "$udp_node" != "default" ] && udp_node_remark=$(config_n_get $udp_node remarks) diff --git a/luci-theme-argon/root/usr/libexec/argon/online_wallpaper b/luci-theme-argon/root/usr/libexec/argon/online_wallpaper old mode 100644 new mode 100755 index ab735b082..241c31d0b --- a/luci-theme-argon/root/usr/libexec/argon/online_wallpaper +++ b/luci-theme-argon/root/usr/libexec/argon/online_wallpaper @@ -10,19 +10,19 @@ WRLOCK=/var/lock/argon_${WEB_PIC_SRC}.lock fetch_pic_url() { case $WEB_PIC_SRC in bing) - local picpath=$(curl -fks --max-time 1 \ + local picpath=$(curl -fks --max-time 3 \ "https://www.bing.com/HPImageArchive.aspx?format=js&n=1" | jsonfilter -q -e '@.images[0].url') [ -n "${picpath}" ] && echo "//www.bing.com${picpath}" ;; unsplash) - curl -fks --max-time 1 \ + curl -fks --max-time 3 \ "https://source.unsplash.com/1920x1080/daily?wallpapers" | sed -E 's#^.*href="([^?]+)\?.*$#\1?fm=jpg\&fit=crop\&w=1920\&h=1080#' ;; unsplash_*) local collection_id=${WEB_PIC_SRC#unsplash_} - curl -fks --max-time 1 \ + curl -fks --max-time 3 \ "https://source.unsplash.com/collection/${collection_id}/1920x1080" | sed -E 's#^.*href="([^?]+)\?.*$#\1?fm=jpg\&fit=crop\&w=1920\&h=1080#' ;; @@ -36,7 +36,7 @@ try_update() { if flock -n 200 >/dev/null 2>&1; then local picurl=$(fetch_pic_url) if [ -n "$picurl" ]; then - echo "${picurl}" >"$CACHE" + echo "${picurl}" | tee "$CACHE" else if [ -s "$CACHE" ]; then cat "$CACHE" diff --git a/wxbase/Makefile b/wxbase/Makefile index a4a0d70bf..1f7af0862 100644 --- a/wxbase/Makefile +++ b/wxbase/Makefile @@ -22,6 +22,8 @@ PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk +DISABLE_NLS:= + define Package/libwxbase SECTION:=libs CATEGORY:=Libraries @@ -95,8 +97,6 @@ CONFIGURE_ARGS += \ --without-x \ --without-x11 -CONFIGURE_ARGS := $(filter-out --disable-nls, $(CONFIGURE_ARGS)) - define Build/InstallDev $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/wx-config $(1)/usr/bin/ diff --git a/xray-plugin/Makefile b/xray-plugin/Makefile index 5f4a9e57d..af4081d99 100644 --- a/xray-plugin/Makefile +++ b/xray-plugin/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=xray-plugin -PKG_VERSION:=1.8.0 +PKG_VERSION:=1.8.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/teddysun/xray-plugin/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=a21e598a41e760b4286cc621311a03fbe60b05268af85a019931e90fccf6df07 +PKG_HASH:=b86b265bd55984c74b80c8b044dfa0cdded448cc92bc8a923b677ca8d54eaa86 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE