mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-07-27 00:01:22 +08:00
update 2026-07-26 04:43:32
This commit is contained in:
parent
4007fe9cb7
commit
95b3db1274
@ -70,6 +70,7 @@ function index()
|
||||
entry({"admin", "services", appname, "get_now_use_node"}, call("get_now_use_node")).leaf = true
|
||||
entry({"admin", "services", appname, "get_redir_log"}, call("get_redir_log")).leaf = true
|
||||
entry({"admin", "services", appname, "get_socks_log"}, call("get_socks_log")).leaf = true
|
||||
entry({"admin", "services", appname, "get_acl_log"}, call("get_acl_log")).leaf = true
|
||||
entry({"admin", "services", appname, "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "services", appname, "clear_log"}, call("clear_log")).leaf = true
|
||||
entry({"admin", "services", appname, "index_status"}, call("index_status")).leaf = true
|
||||
@ -266,6 +267,18 @@ function get_socks_log()
|
||||
end
|
||||
end
|
||||
|
||||
function get_acl_log()
|
||||
local id = http.formvalue("id")
|
||||
local path = "/tmp/log/passwall2_acl_" .. id .. ".log"
|
||||
if nixio.fs.access(path) then
|
||||
local content = luci.sys.exec("tail -n 5000 '" .. path .. "'")
|
||||
content = content:gsub("\n", "<br />")
|
||||
http.write(content)
|
||||
else
|
||||
http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate("Not enabled log")))
|
||||
end
|
||||
end
|
||||
|
||||
function get_log()
|
||||
-- luci.sys.exec("[ -f /tmp/log/passwall2.log ] && sed '1!G;h;$!d' /tmp/log/passwall2.log > /tmp/log/passwall2_show.log")
|
||||
http.write(luci.sys.exec("[ -f '/tmp/log/passwall2.log' ] && cat /tmp/log/passwall2.log"))
|
||||
|
||||
@ -78,6 +78,33 @@ o = s:option(Value, "remarks", translate("Remarks"))
|
||||
o.default = arg[1]
|
||||
o.rmempty = false
|
||||
|
||||
---- Log
|
||||
o = s:option(Flag, "log", translate("Enable Log"))
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "loglevel", translate("Log Level"))
|
||||
o.default = "warn"
|
||||
o:value("debug", "Debug")
|
||||
o:value("info", "Info")
|
||||
o:value("warn", "Warning")
|
||||
o:value("error", "Error")
|
||||
o:depends("log", "1")
|
||||
|
||||
o = s:option(DummyValue, "_acl_log", translate("Log File"))
|
||||
o.rawhtml = true
|
||||
o.cfgvalue = function(t, n)
|
||||
local log_path = "/tmp/log/passwall2_acl_" .. arg[1] .. ".log"
|
||||
local log_url = api.url("get_acl_log") .. "?id=" .. arg[1]
|
||||
return string.format(
|
||||
'<code>%s</code> <input class="btn cbi-button cbi-button-apply" type="button" value="%s" onclick="window.open(\'%s\', \'_blank\')" />',
|
||||
log_path,
|
||||
translate("View Log"),
|
||||
log_url
|
||||
)
|
||||
end
|
||||
o:depends("log", "1")
|
||||
|
||||
o = s:option(Value, "interface", translate("Source Interface"))
|
||||
o:value("", translate("All"))
|
||||
local iface = api.get_network_devices()
|
||||
|
||||
@ -1021,11 +1021,15 @@ acl_app() {
|
||||
dnsmasq_port=${GLOBAL_DNSMASQ_PORT:-11400}
|
||||
for item in $items; do
|
||||
index=$(expr $index + 1)
|
||||
local enabled sid remarks sources interface tcp_no_redir_ports udp_no_redir_ports node direct_dns_query_strategy remote_dns_protocol remote_dns remote_dns_doh remote_dns_client_ip remote_dns_detour remote_fakedns remote_dns_query_strategy
|
||||
local enabled sid remarks sources interface tcp_no_redir_ports udp_no_redir_ports node direct_dns_query_strategy remote_dns_protocol remote_dns remote_dns_doh remote_dns_client_ip remote_dns_detour remote_fakedns remote_dns_query_strategy log loglevel log_file
|
||||
local _ip _mac _iprange _ipset _ip_or_mac source_list config_file
|
||||
local sid=$(uci -q show "${CONFIG}.${item}" | grep "=acl_rule" | awk -F '=' '{print $1}' | awk -F '.' '{print $2}')
|
||||
[ "$(config_n_get $sid enabled)" = "1" ] || continue
|
||||
eval $(uci -q show "${CONFIG}.${item}" | cut -d'.' -sf 3-)
|
||||
log=${log:-0}
|
||||
loglevel=${loglevel:-warn}
|
||||
log_file="/dev/null"
|
||||
[ "${log}" = "1" ] && log_file="/tmp/log/passwall2_acl_${sid}.log"
|
||||
|
||||
if [ -n "${sources}" ]; then
|
||||
for s in $sources; do
|
||||
@ -1121,7 +1125,8 @@ acl_app() {
|
||||
direct_dns_query_strategy=${direct_dns_query_strategy} \
|
||||
remote_dns_protocol=${remote_dns_protocol} remote_dns_tcp_server=${remote_dns} remote_dns_udp_server=${remote_dns} remote_dns_doh="${remote_dns}" \
|
||||
remote_dns_client_ip=${remote_dns_client_ip} remote_dns_detour=${remote_dns_detour} remote_fakedns=${remote_fakedns} remote_dns_query_strategy=${remote_dns_query_strategy} \
|
||||
config_file=${config_file}
|
||||
config_file=${config_file} \
|
||||
log_file="${log_file}" loglevel="${loglevel}"
|
||||
local status=$?
|
||||
if [ "$status" != 0 ]; then
|
||||
log_i18n 2 "[%s] process %s error, skip this transparent proxy!" "${remarks}" "${config_file}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user