luci-app-passwall: sync upstream

This commit is contained in:
actions 2024-04-23 14:30:04 +08:00
parent 17dde9704e
commit d84a869f4f
3 changed files with 34 additions and 14 deletions

View File

@ -131,7 +131,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
end end
type.cfgvalue = get_cfgvalue(v.id, "type") type.cfgvalue = get_cfgvalue(v.id, "type")
type.write = get_write(v.id, "type") type.write = get_write(v.id, "type")
-- pre-proxy -- pre-proxy
o = s:taboption("Main", Flag, vid .. "-preproxy_enabled", translate("Preproxy")) o = s:taboption("Main", Flag, vid .. "-preproxy_enabled", translate("Preproxy"))
o:depends("tcp_node", v.id) o:depends("tcp_node", v.id)
@ -507,13 +507,15 @@ trojan_loglevel:value("4", "fatal")
o = s:taboption("log", Flag, "advanced_log_feature", translate("Advanced log feature"), translate("For professionals only.")) o = s:taboption("log", Flag, "advanced_log_feature", translate("Advanced log feature"), translate("For professionals only."))
o.default = "0" o.default = "0"
o.rmempty = false o = s:taboption("log", Flag, "sys_log", translate("Logging to system log"), translate("Logging to the system log for more advanced functions. For example, send logs to a dedicated log server."))
local syslog = s:taboption("log", Flag, "sys_log", translate("Logging to system log"), translate("Logging to the system log for more advanced functions. For example, send logs to a dedicated log server.")) o:depends("advanced_log_feature", "1")
syslog:depends("advanced_log_feature", "1") o.default = "0"
syslog.default = "0" o = s:taboption("log", Value, "persist_log_path", translate("Persist log file directory"), translate("The path to the directory used to store persist log files, the \"/\" at the end can be omitted. Leave it blank to disable this feature."))
syslog.rmempty = false o:depends({ ["advanced_log_feature"] = 1, ["sys_log"] = 0 })
local logpath = s:taboption("log", Value, "persist_log_path", translate("Persist log file directory"), translate("The path to the directory used to store persist log files, the \"/\" at the end can be omitted. Leave it blank to disable this feature.")) o = s:taboption("log", Value, "log_event_filter", translate("Log Event Filter"), translate("Support regular expression."))
logpath:depends({ ["advanced_log_feature"] = 1, ["sys_log"] = 0 }) o:depends("advanced_log_feature", "1")
o = s:taboption("log", Value, "log_event_cmd", translate("Shell Command"), translate("Shell command to execute, replace log content with %s."))
o:depends("advanced_log_feature", "1")
s:tab("faq", "FAQ") s:tab("faq", "FAQ")

View File

@ -1393,6 +1393,18 @@ msgstr "记录到系统日志"
msgid "Logging to the system log for more advanced functions. For example, send logs to a dedicated log server." msgid "Logging to the system log for more advanced functions. For example, send logs to a dedicated log server."
msgstr "将日志记录到系统日志,以实现更加高级的功能。例如,把日志发送到专门的日志服务器。" msgstr "将日志记录到系统日志,以实现更加高级的功能。例如,把日志发送到专门的日志服务器。"
msgid "Log Event Filter"
msgstr "日志事件过滤器"
msgid "Support regular expression."
msgstr "支持正则表达式。"
msgid "Shell Command"
msgstr "Shell 命令"
msgid "Shell command to execute, replace log content with %s."
msgstr "要执行的 Shell 命令,用 %s 代替日志内容。"
msgid "Not enabled log" msgid "Not enabled log"
msgstr "未启用日志" msgstr "未启用日志"

View File

@ -3,13 +3,17 @@
CONFIG=passwall CONFIG=passwall
LOG_FILE=/tmp/log/$CONFIG.log LOG_FILE=/tmp/log/$CONFIG.log
LOCK_FILE_DIR=/tmp/lock LOCK_FILE_DIR=/tmp/lock
LOG_EVENT_FILTER=
LOG_EVENT_CMD=
flag=0 flag=0
echolog() { echolog() {
local d="$(date "+%Y-%m-%d %H:%M:%S")" local d="$(date "+%Y-%m-%d %H:%M:%S")"
#echo -e "$d: $1" local c="$1"
echo -e "$d: $1" >> $LOG_FILE echo -e "$d: $c" >> $LOG_FILE
[ -n "$LOG_EVENT_CMD" ] && [ -n "$(echo -n $c |grep -E "$LOG_EVENT_FILTER")" ] && {
$(echo -n $LOG_EVENT_CMD |sed "s/%s/$c/g")
}
} }
config_n_get() { config_n_get() {
@ -86,7 +90,7 @@ test_auto_switch() {
return 1 return 1
fi fi
} }
[ $flag -le 1 ] && { [ $flag -le 1 ] && {
main_node=$now_node main_node=$now_node
} }
@ -96,7 +100,7 @@ test_auto_switch() {
echolog "自动切换检测:无法连接到网络,请检查网络是否正常!" echolog "自动切换检测:无法连接到网络,请检查网络是否正常!"
return 2 return 2
fi fi
#检测主节点是否能使用 #检测主节点是否能使用
if [ "$restore_switch" == "1" ] && [ "$main_node" != "nil" ] && [ "$now_node" != "$main_node" ]; then if [ "$restore_switch" == "1" ] && [ "$main_node" != "nil" ] && [ "$now_node" != "$main_node" ]; then
test_node ${main_node} test_node ${main_node}
@ -110,7 +114,7 @@ test_auto_switch() {
return 0 return 0
} }
fi fi
if [ "$status" == 0 ]; then if [ "$status" == 0 ]; then
#echolog "自动切换检测:${id}【$(config_n_get $now_node type)[$(config_n_get $now_node remarks)]】正常。" #echolog "自动切换检测:${id}【$(config_n_get $now_node type)[$(config_n_get $now_node remarks)]】正常。"
return 0 return 0
@ -154,6 +158,8 @@ test_auto_switch() {
start() { start() {
id=$1 id=$1
LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}_socks_auto_switch_${id}.lock LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}_socks_auto_switch_${id}.lock
LOG_EVENT_FILTER=$(uci -q get "${CONFIG}.global[0].log_event_filter" 2>/dev/null)
LOG_EVENT_CMD=$(uci -q get "${CONFIG}.global[0].log_event_cmd" 2>/dev/null)
main_node=$(config_n_get $id node nil) main_node=$(config_n_get $id node nil)
socks_port=$(config_n_get $id port 0) socks_port=$(config_n_get $id port 0)
delay=$(config_n_get $id autoswitch_testing_time 30) delay=$(config_n_get $id autoswitch_testing_time 30)