From dc88083f49cc4bb759ec46c735122a1c9b096e24 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 3 Jan 2020 13:21:45 +0800 Subject: [PATCH] luci-app-passwall: sync with upstream source --- package/lienol/luci-app-passwall/Makefile | 4 +- .../api/gen_v2ray_client_config_file.lua | 143 +++++++++--------- .../luasrc/model/cbi/passwall/node_config.lua | 5 +- .../luasrc/model/cbi/passwall/node_list.lua | 3 +- .../view/passwall/node_list/node_list.htm | 3 +- .../luci-app-passwall/po/zh-cn/passwall.po | 3 + .../root/usr/share/passwall/app.sh | 27 +--- .../root/usr/share/passwall/subscription.sh | 12 +- .../root/usr/share/passwall/test.sh | 7 +- 9 files changed, 93 insertions(+), 114 deletions(-) diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index 468235d37d..34e6c75edd 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -6,8 +6,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=3.0 -PKG_RELEASE:=2-20200101 +PKG_VERSION:=3.1 +PKG_RELEASE:=3-20200103 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PO2LMO:=./po2lmo diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config_file.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config_file.lua index 9cfada9747..820151781b 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config_file.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config_file.lua @@ -26,20 +26,18 @@ if redir_port ~= "nil" then } if proto == "tcp" and node.v2ray_tcp_socks == "1" then inboundDetour_json = { - { - listen = "0.0.0.0", - port = tonumber(node.v2ray_tcp_socks_port), - protocol = "socks", - settings = { - auth = node.v2ray_tcp_socks_auth, - accounts = (node.v2ray_tcp_socks_auth == "password") and { - { - user = node.v2ray_tcp_socks_auth_username, - pass = node.v2ray_tcp_socks_auth_password - } - } or nil, - udp = true - } + listen = "0.0.0.0", + port = tonumber(node.v2ray_tcp_socks_port), + protocol = "socks", + settings = { + auth = node.v2ray_tcp_socks_auth, + accounts = (node.v2ray_tcp_socks_auth == "password") and { + { + user = node.v2ray_tcp_socks_auth_username, + pass = node.v2ray_tcp_socks_auth_password + } + } or nil, + udp = true } } end @@ -51,70 +49,69 @@ local v2ray = { loglevel = "warning" }, -- 传入连接 - inbound = inbound_json, - inboundDetour = inboundDetour_json, + inbounds = {inbound_json, inboundDetour_json}, -- 传出连接 - outbound = { - protocol = node.v2ray_protocol, - settings = { - vnext = { - { - address = node.address, - port = tonumber(node.port), - users = { - { - id = node.v2ray_VMess_id, - alterId = tonumber(node.v2ray_VMess_alterId), - level = tonumber(node.v2ray_VMess_level), - security = node.v2ray_security + outbounds = { + { + protocol = node.v2ray_protocol, + mux = { + enabled = (node.v2ray_mux == "1") and true or false, + concurrency = (node.v2ray_mux_concurrency) and + tonumber(node.v2ray_mux_concurrency) or 8 + }, + -- 底层传输配置 + streamSettings = { + network = node.v2ray_transport, + security = node.v2ray_stream_security, + tlsSettings = (node.v2ray_stream_security == "tls") and { + serverName = node.tls_serverName, + allowInsecure = (node.tls_allowInsecure == "1") and true or + false + } or nil, + kcpSettings = (node.v2ray_transport == "mkcp") and { + mtu = tonumber(node.v2ray_mkcp_mtu), + tti = tonumber(node.v2ray_mkcp_tti), + uplinkCapacity = tonumber(node.v2ray_mkcp_uplinkCapacity), + downlinkCapacity = tonumber(node.v2ray_mkcp_downlinkCapacity), + congestion = (node.v2ray_mkcp_congestion == "1") and true or + false, + readBufferSize = tonumber(node.v2ray_mkcp_readBufferSize), + writeBufferSize = tonumber(node.v2ray_mkcp_writeBufferSize), + header = {type = node.v2ray_mkcp_guise} + } or nil, + wsSettings = (node.v2ray_transport == "ws") and { + path = node.v2ray_ws_path, + headers = (node.v2ray_ws_host ~= nil) and + {Host = node.v2ray_ws_host} or nil + } or nil, + httpSettings = (node.v2ray_transport == "h2") and + {path = node.v2ray_h2_path, host = node.v2ray_h2_host} or + nil, + dsSettings = (node.v2ray_transport == "ds") and + {path = node.v2ray_ds_path} or nil, + quicSettings = (node.v2ray_transport == "quic") and { + security = node.v2ray_quic_security, + key = node.v2ray_quic_key, + header = {type = node.v2ray_quic_guise} + } or nil + }, + settings = { + vnext = { + { + address = node.address, + port = tonumber(node.port), + users = { + { + id = node.v2ray_VMess_id, + alterId = tonumber(node.v2ray_VMess_alterId), + level = tonumber(node.v2ray_VMess_level), + security = node.v2ray_security + } } } } } - }, - mux = { - enabled = (node.v2ray_mux == "1") and true or false, - concurrency = (node.v2ray_mux_concurrency) and - tonumber(node.v2ray_mux_concurrency) or 8 - }, - -- 底层传输配置 - streamSettings = { - network = node.v2ray_transport, - security = node.v2ray_stream_security, - tlsSettings = (node.v2ray_stream_security == "tls") and { - serverName = node.tls_serverName, - allowInsecure = (node.tls_allowInsecure == "1") and true or - false - } or nil, - kcpSettings = (node.v2ray_transport == "mkcp") and { - mtu = tonumber(node.v2ray_mkcp_mtu), - tti = tonumber(node.v2ray_mkcp_tti), - uplinkCapacity = tonumber(node.v2ray_mkcp_uplinkCapacity), - downlinkCapacity = tonumber(node.v2ray_mkcp_downlinkCapacity), - congestion = (node.v2ray_mkcp_congestion == "1") and true or - false, - readBufferSize = tonumber(node.v2ray_mkcp_readBufferSize), - writeBufferSize = tonumber(node.v2ray_mkcp_writeBufferSize), - header = {type = node.v2ray_mkcp_guise} - } or nil, - wsSettings = (node.v2ray_transport == "ws") and { - path = node.v2ray_ws_path, - headers = (node.v2ray_ws_host ~= nil) and - {Host = node.v2ray_ws_host} or nil - } or nil, - httpSettings = (node.v2ray_transport == "h2") and - {path = node.v2ray_h2_path, host = node.v2ray_h2_host} or nil, - dsSettings = (node.v2ray_transport == "ds") and - {path = node.v2ray_ds_path} or nil, - quicSettings = (node.v2ray_transport == "quic") and { - security = node.v2ray_quic_security, - key = node.v2ray_quic_key, - header = {type = node.v2ray_quic_guise} - } or nil - } - }, - -- 额外传出连接 - outboundDetour = { + }, -- 额外传出连接 {protocol = "freedom", tag = "direct", settings = {keep = ""}} } } diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua index 10b17b72b8..edd89e2445 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua @@ -144,10 +144,7 @@ ss_plugin:value("none", translate("none")) if is_finded("v2ray-plugin") then ss_plugin:value("v2ray-plugin") end ss_plugin:depends("type", "SS") -ss_plugin_v2ray_opts = s:option(ListValue, "ss_plugin_v2ray_opts", translate("opts")) -ss_plugin_v2ray_opts:value("http", translate("HTTP")) -ss_plugin_v2ray_opts:value("https", translate("HTTPS")) -ss_plugin_v2ray_opts:value("quic", translate("QUIC")) +ss_plugin_v2ray_opts = s:option(Value, "ss_plugin_v2ray_opts", translate("opts")) ss_plugin_v2ray_opts:depends("ss_plugin", "v2ray-plugin") use_kcp = s:option(Flag, "use_kcp", translate("Use Kcptun"), diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua index 549a29efc7..dad2429867 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua @@ -37,7 +37,8 @@ o.default = 1 s:append(Template("passwall/node_list/link_add_node")) -- [[ Node List ]]-- -s = m:section(TypedSection, "nodes") +s = m:section(TypedSection, "nodes", translate(""), translate( + "Support for more than 10,000 ping nodes and luci does not crash and not slow.")) s.anonymous = true s.addremove = true s.template = "cbi/tblsection" diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm index ddcd05ec9c..35187c5f6f 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm @@ -1,4 +1,5 @@ <% + -- Copyright 2018-2020 Lienol local api = require "luci.model.cbi.passwall.api.api" local dsp = require "luci.dispatcher" @@ -199,4 +200,4 @@ table td, .table .td { <% end %> - + \ No newline at end of file diff --git a/package/lienol/luci-app-passwall/po/zh-cn/passwall.po b/package/lienol/luci-app-passwall/po/zh-cn/passwall.po index db17b96b9c..551ca9b58a 100644 --- a/package/lienol/luci-app-passwall/po/zh-cn/passwall.po +++ b/package/lienol/luci-app-passwall/po/zh-cn/passwall.po @@ -304,6 +304,9 @@ msgstr "选中后保存应用后即自动Ping节点" msgid "Concise display nodes" msgstr "简洁显示节点" +msgid "Support for more than 10,000 ping nodes and luci does not crash and not slow." +msgstr "支持超过10000个节点,而LuCI却不会卡死,更不会崩溃。" + msgid "Apply" msgstr "应用" diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh index f127cdc709..9b4618d6a5 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh @@ -433,15 +433,8 @@ start_tcp_redir() { local plugin=$(config_n_get $temp_server ss_plugin) if [ "$plugin" != "none" ]; then [ "$plugin" == "v2ray-plugin" ] && { - plugin_params="--plugin " - plugin_params="${plugin_params}v2ray-plugin" local opts=$(config_n_get $temp_server ss_plugin_v2ray_opts) - local address=$(config_n_get $temp_server address) - if [ "$opts" == "https" ]; then - plugin_params="${plugin_params} --plugin-opts \"tls;host=${address}\"" - elif [ "$opts" == "quic" ]; then - plugin_params="${plugin_params} --plugin-opts \"mode=quic;host=${address}\"" - fi + plugin_params="--plugin v2ray-plugin --plugin-opts \"$opts\"" } fi for k in $(seq 1 $process); do @@ -524,15 +517,8 @@ start_udp_redir() { local plugin=$(config_n_get $temp_server ss_plugin) if [ "$plugin" != "none" ]; then [ "$plugin" == "v2ray-plugin" ] && { - plugin_params="--plugin " - plugin_params="${plugin_params}v2ray-plugin" local opts=$(config_n_get $temp_server ss_plugin_v2ray_opts) - local address=$(config_n_get $temp_server address) - if [ "$opts" == "https" ]; then - plugin_params="${plugin_params} --plugin-opts \"tls;host=${address}\"" - elif [ "$opts" == "quic" ]; then - plugin_params="${plugin_params} --plugin-opts \"mode=quic;host=${address}\"" - fi + plugin_params="--plugin v2ray-plugin --plugin-opts \"$opts\"" } fi $ss_bin -c $config_file -f $RUN_PID_PATH/udp_${TYPE}_1_$i -U $plugin_params >/dev/null 2>&1 & @@ -584,15 +570,8 @@ start_socks5_proxy() { local plugin=$(config_n_get $temp_server ss_plugin) if [ "$plugin" != "none" ]; then [ "$plugin" == "v2ray-plugin" ] && { - plugin_params="--plugin " - plugin_params="${plugin_params}v2ray-plugin" local opts=$(config_n_get $temp_server ss_plugin_v2ray_opts) - local address=$(config_n_get $temp_server address) - if [ "$opts" == "https" ]; then - plugin_params="${plugin_params} --plugin-opts \"tls;host=${address}\"" - elif [ "$opts" == "quic" ]; then - plugin_params="${plugin_params} --plugin-opts \"mode=quic;host=${address}\"" - fi + plugin_params="--plugin v2ray-plugin --plugin-opts \"$opts\"" } fi $ss_bin -c $config_file -b 0.0.0.0 -u $plugin_params >/dev/null 2>&1 & diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/subscription.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/subscription.sh index e7d113f0a1..72fbbf25d4 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/subscription.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/subscription.sh @@ -307,13 +307,15 @@ add_nodes(){ update_config(){ [ "$isAdd" == 1 ] && { - isadded_remarks=$(uci show $CONFIG | grep -c "remarks='$remarks'") + isadded_remarks=$(uci show $CONFIG | grep "@nodes" | grep "remarks" | grep -c -F "$remarks") if [ "$isadded_remarks" -eq 0 ]; then add_nodes add "$link_type" else - index=$(uci show $CONFIG | grep -w "remarks='$remarks'" | cut -d '[' -f2|cut -d ']' -f1) - uci delete $CONFIG.@nodes[$index] - add_nodes update "$link_type" + index=$(uci show $CONFIG | grep "@nodes" | grep "remarks" | grep -w -F "$remarks" | cut -d '[' -f2|cut -d ']' -f1) + [ "$?" == 0 ] && { + uci delete $CONFIG.@nodes[$index] + add_nodes update "$link_type" + } fi } } @@ -323,7 +325,7 @@ del_config(){ for localaddress in $(cat /usr/share/${CONFIG}/sub/all_localnodes) do [ "`cat /usr/share/${CONFIG}/sub/all_onlinenodes |grep -c "$localaddress"`" -eq 0 ] && { - for localindex in $(uci show $CONFIG|grep -w "$localaddress" |grep -w "address=" |cut -d '[' -f2|cut -d ']' -f1) + for localindex in $(uci show $CONFIG | grep -w "$localaddress" | grep -w "address=" |cut -d '[' -f2|cut -d ']' -f1) do del_type=$(uci get $CONFIG.@nodes[$localindex].type) uci delete $CONFIG.@nodes[$localindex] diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/test.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/test.sh index d958df15a9..c2cf699791 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/test.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/test.sh @@ -8,10 +8,9 @@ get_date() { } test_url() { - ps -ef | grep "$1" | grep -v grep | awk '{print $1}' | xargs kill -9 - status=$(/usr/bin/curl -I -o /dev/null -s --connect-timeout 3 -w %{http_code} "$1" | grep 200) + status=$(/usr/bin/curl -I -o /dev/null -s --connect-timeout 2 -w %{http_code} "$1" | grep 200) [ "$?" != 0 ] && { - status=$(/usr/bin/wget --no-check-certificate --spider --timeout=3 "$1") + status=$(/usr/bin/wget --no-check-certificate --spider --timeout=2 "$1") [ "$?" == 0 ] && status=200 } echo $status @@ -141,4 +140,4 @@ test_url) *) start ;; -esac +esac \ No newline at end of file