From 6c8d8a865e7349e621d2a2d92d2d893256b2b761 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Mon, 22 Mar 2021 18:03:49 +0800 Subject: [PATCH] luci-app-passwall: sync with upstream source Co-authored-by: badgv <45598380+badgv@users.noreply.github.com> Signed-off-by: Tianling Shen --- .../passwall/node_list/link_share_man.htm | 34 ++++++++++++------- .../luci-app-passwall/po/zh_Hans/passwall.po | 4 +-- .../root/usr/share/passwall/iptables.sh | 2 +- .../root/usr/share/passwall/monitor.sh | 16 ++++----- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm index ba900f8168..9017abd722 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm @@ -274,17 +274,21 @@ local api = require "luci.model.cbi.passwall.api.api" } url += params; } else if ((v_type === "Xray" && opt.get("protocol").value === "trojan") || v_type === "Trojan" || v_type === "Trojan-Plus" || v_type === "Trojan-Go") { + if (v_type === "Xray" && opt.get("protocol").value === "trojan") { + v_type = "trojan"; + } var v_password = opt.get(!opt.client && v_type === "Trojan-Go" ? "passwords" : "password"); var v_server = opt.get("address"); var v_port = opt.get("port"); url = encodeURIComponent(v_password.value) + "@" + v_server.value + ":" + v_port.value + "/?"; + var params = ""; if (opt.get("tls").checked) { - url += opt.query("sni", "tls_serverName"); + params += opt.query("sni", "tls_serverName"); if (v_type !== "Trojan-Go") { - url += "&tls=1" - url += opt.query("allowinsecure", "tls_allowInsecure"); + params += "&tls=1" + params += opt.query("allowinsecure", "tls_allowInsecure"); } } if (v_type === "Trojan-Go") { @@ -296,17 +300,17 @@ local api = require "luci.model.cbi.passwall.api.api" plugin.option = opt.get("plugin_option").value; plugin.arg = opt.getlist("plugin_arg"); } - url += "&plugin=" + encodeURIComponent(JSON.stringify(plugin)); + params += "&plugin=" + encodeURIComponent(JSON.stringify(plugin)); } - url += opt.query("type", "trojan_transport"); + params += opt.query("type", "trojan_transport"); var ws = (opt.get("trojan_transport").value.indexOf("ws") !== -1); var h2 = (opt.get("trojan_transport").value.indexOf("h2") !== -1); if (ws) { - url += opt.query("host", "ws_host"); - url += opt.query("path", "ws_path"); + params += opt.query("host", "ws_host"); + params += opt.query("path", "ws_path"); } else if (h2) { - url += opt.query("host", "h2_host"); - url += opt.query("path", "h2_path"); + params += opt.query("host", "h2_host"); + params += opt.query("path", "h2_path"); } var enc = "none"; if (opt.get("ss_aead").checked === true) { @@ -314,9 +318,13 @@ local api = require "luci.model.cbi.passwall.api.api" opt.get("ss_aead_method").value + ":" + opt.get("ss_aead_pwd").value; } - url += "&encryption=" + encodeURIComponent(enc); + params += "&encryption=" + encodeURIComponent(enc); } - url += "#" + encodeURI(v_alias.value); + params += "#" + encodeURI(v_alias.value); + if (params[0] == "&") { + params = params.substring(1); + } + url += params; } if (url) { url = v_type.toLowerCase() + "://" + url; @@ -327,9 +335,9 @@ local api = require "luci.model.cbi.passwall.api.api" textarea.select(); try { document.execCommand("copy"); // Security exception may be thrown by some browsers. - s.innerHTML = "<%:Share url to clipboard successfully.%>"; + s.innerHTML = "<%:Share URL to clipboard successfully.%>"; } catch (ex) { - s.innerHTML = "<%:Share url to clipboard unable.%>"; + s.innerHTML = "<%:Share URL to clipboard unable.%>"; } finally { document.body.removeChild(textarea); } diff --git a/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po b/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po index 9fa953c6da..e5e0c9298c 100644 --- a/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po +++ b/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po @@ -466,10 +466,10 @@ msgstr "无效的分享URL信息" msgid "Paste Share URL Here" msgstr "在此处粘贴分享信息" -msgid "Share url to clipboard unable." +msgid "Share URL to clipboard unable." msgstr "无法分享URL到剪贴板。" -msgid "Share url to clipboard successfully." +msgid "Share URL to clipboard successfully." msgstr "成功复制分享URL到剪贴板。" msgid "Faltal on get option, please help in debug:" diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh index 5ae53147d9..078c37a8a0 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -48,7 +48,7 @@ comment() { destroy_ipset() { for i in "$@"; do - #ipset -q -F $i + ipset -q -F $i ipset -q -X $i done } diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/monitor.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/monitor.sh index db0b07afb3..b9b89c0b71 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/monitor.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/monitor.sh @@ -17,7 +17,7 @@ config_t_get() { echo ${ret:=$3} } -if [ "$(top -bn1 | grep -v grep | grep $CONFIG/monitor.sh | wc -l)" -gt 2 ]; then +if [ "$(pgrep -f $CONFIG/monitor.sh | wc -l)" -gt 2 ]; then exit 1 fi @@ -35,13 +35,12 @@ do #kcptun use_kcp=$(config_n_get $TCP_NODE use_kcp 0) if [ $use_kcp -gt 0 ]; then - icount=$(top -bn1 | grep -v grep | grep "$TMP_BIN_PATH/kcptun" | grep -i "tcp" | wc -l) - if [ $icount = 0 ]; then + if ! pgrep -af "$TMP_BIN_PATH/kcptun.*(tcp|TCP)" > /dev/null 2>&1; then /etc/init.d/$CONFIG restart exit 0 fi fi - icount=$(top -bn1 | grep -v -E 'grep|kcptun' | grep "$TMP_BIN_PATH" | grep -i "TCP" | wc -l) + icount=$(pgrep -af "$TMP_BIN_PATH.*(tcp|TCP)" | grep -v kcptun | wc -l) if [ $icount = 0 ]; then /etc/init.d/$CONFIG restart exit 0 @@ -55,8 +54,7 @@ do if [ "$UDP_NODE" != "nil" ]; then [ "$UDP_NODE" == "tcp" ] && continue [ "$UDP_NODE" == "tcp_" ] && UDP_NODE=$TCP_NODE - icount=$(top -bn1 | grep -v grep | grep "$TMP_BIN_PATH" | grep -i "UDP" | wc -l) - if [ $icount = 0 ]; then + if ! pgrep -af "$TMP_BIN_PATH.*(udp|UDP)" > /dev/null 2>&1; then /etc/init.d/$CONFIG restart exit 0 fi @@ -74,8 +72,7 @@ do fi [ -f "$TMP_BIN_PATH/chinadns-ng" ] && { - icount=$(top -bn1 | grep -v grep | grep $TMP_BIN_PATH/chinadns-ng | wc -l) - if [ $icount = 0 ]; then + if ! pgrep -x "$TMP_BIN_PATH/chinadns-ng" > /dev/null 2>&1; then /etc/init.d/$CONFIG restart exit 0 fi @@ -84,8 +81,7 @@ do #haproxy use_haproxy=$(config_t_get global_haproxy balancing_enable 0) if [ $use_haproxy -gt 0 ]; then - icount=$(top -bn1 | grep -v grep | grep "$TMP_BIN_PATH/haproxy" | wc -l) - if [ $icount = 0 ]; then + if ! pgrep -x "$TMP_BIN_PATH/haproxy" > /dev/null 2>&1; then /etc/init.d/$CONFIG restart exit 0 fi