luci-app-passwall: sync with upstream source

Co-authored-by: badgv <45598380+badgv@users.noreply.github.com>
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
xiaorouji 2021-03-22 18:03:49 +08:00 committed by Tianling Shen
parent c8f9cb2451
commit 6c8d8a865e
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 30 additions and 26 deletions

View File

@ -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 = "<font color='green'><%:Share url to clipboard successfully.%></font>";
s.innerHTML = "<font color='green'><%:Share URL to clipboard successfully.%></font>";
} catch (ex) {
s.innerHTML = "<font color='red'><%:Share url to clipboard unable.%></font>";
s.innerHTML = "<font color='red'><%:Share URL to clipboard unable.%></font>";
} finally {
document.body.removeChild(textarea);
}

View File

@ -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:"

View File

@ -48,7 +48,7 @@ comment() {
destroy_ipset() {
for i in "$@"; do
#ipset -q -F $i
ipset -q -F $i
ipset -q -X $i
done
}

View File

@ -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