Improve diagnostics masking controls

This commit is contained in:
ushan0v
2026-06-18 08:44:35 +03:00
parent 3b0c7e0fc7
commit 59a13cc772
3 changed files with 54 additions and 41 deletions
+3 -3
View File
@@ -1169,13 +1169,13 @@ clash_api)
clash_api "$2" "$3" "$4"
;;
show_config)
show_config
show_config "${2:-}"
;;
show_version)
show_version
;;
show_sing_box_config)
show_sing_box_config
show_sing_box_config "${2:-}"
;;
show_sing_box_version)
show_sing_box_version
@@ -1253,7 +1253,7 @@ check_dns_available)
check_dns_available
;;
global_check)
global_check "${2:-}"
global_check "${2:-}" "${3:-}"
;;
validate_nfqws_strategy_json)
validate_nfqws_strategy_json "${2:-}"
+25 -5
View File
@@ -442,6 +442,7 @@ check_sing_box_logs() {
show_sing_box_config() {
local sing_box_config_path
local visibility="${1:-masked}"
config_get sing_box_config_path "settings" "config_path"
nolog "Current sing-box configuration:"
@@ -450,16 +451,26 @@ show_sing_box_config() {
return 1
fi
status_diagnostics_ucode mask-sing-box-config "$sing_box_config_path"
if [ "$visibility" = "raw" ]; then
cat "$sing_box_config_path"
else
status_diagnostics_ucode mask-sing-box-config "$sing_box_config_path"
fi
}
show_config() {
local visibility="${1:-masked}"
if [ ! -f "$PODKOP_CONFIG" ]; then
nolog "Configuration file not found"
return 1
fi
status_diagnostics_ucode podkop-config-masked "$PODKOP_CONFIG"
if [ "$visibility" = "raw" ]; then
cat "$PODKOP_CONFIG"
else
status_diagnostics_ucode podkop-config-masked "$PODKOP_CONFIG"
fi
}
show_version() {
@@ -1550,7 +1561,12 @@ status_diagnostics_ucode() {
global_check() {
local PODKOP_LUCI_VERSION="Unknown"
[ -n "$1" ] && PODKOP_LUCI_VERSION="$1"
local visibility="${2:-masked}"
if [ "$1" = "raw" ] || [ "$1" = "masked" ]; then
visibility="$1"
elif [ -n "$1" ]; then
PODKOP_LUCI_VERSION="$1"
fi
print_global "📡 Global check run!"
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@@ -1633,12 +1649,16 @@ global_check() {
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
print_global "📄 Podkop Plus config"
show_config
show_config "$visibility"
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
print_global "📄 WAN config"
if uci show network.wan > /dev/null 2>&1; then
status_diagnostics_ucode wan-config-masked /etc/config/network
if [ "$visibility" = "raw" ]; then
cat /etc/config/network
else
status_diagnostics_ucode wan-config-masked /etc/config/network
fi
else
print_global "❌ WAN configuration not found"
fi
+26 -33
View File
@@ -399,18 +399,31 @@ function podkop_config_masked(path) {
exit(1);
let lines = split(as_string(data), "\n");
let in_masked_multiline = false;
for (let i = 0; i < length(lines); i++) {
let line = as_string(lines[i]);
if (i == length(lines) - 1 && line == "" && substr(as_string(data), length(data) - 1) == "\n")
continue;
if (in_masked_multiline) {
if (index(line, "'") >= 0)
in_masked_multiline = false;
continue;
}
if (delete_token_space(line, "option tailscale_ephemeral") ||
delete_token_space(line, "option tailscale_exit_node") ||
delete_token_space(line, "option tailscale_exit_node_allow_lan_access"))
continue;
print(podkop_config_masked_line(line), "\n");
let masked = podkop_config_masked_line(line);
print(masked, "\n");
if (index(line, "option outbound_json") >= 0) {
let first_quote = index(line, "'");
if (first_quote >= 0 && index(substr(line, first_quote + 1), "'") < 0)
in_masked_multiline = true;
}
}
}
@@ -1322,41 +1335,13 @@ function print_lines(lines, start, end) {
print_line(lines[i]);
}
function current_http_outbound_tags() {
let config = read_json_file("/etc/sing-box/config.json");
let result = {};
if (type(config) != "object")
return result;
for (let outbound in (type(config.outbounds) == "array" ? config.outbounds : [])) {
if (type(outbound) != "object")
continue;
let tag = as_string(outbound.tag || "");
let outbound_type = lc(as_string(outbound.type || ""));
if (tag != "" && outbound_type == "http")
result[tag] = true;
}
return result;
}
function udp_unsupported_outbound_tag(line) {
let marker = "UDP is not supported by outbound:";
let pos = index(line, marker);
if (pos < 0)
return "";
return trim(substr(line, pos + length(marker)));
function is_udp_unsupported_outbound_log(line) {
return index(as_string(line), "UDP is not supported by outbound:") >= 0;
}
function render_matching_log_tail(needle, max_lines) {
let lines = split(read_stdin(), "\n");
let filtered = [];
let http_outbounds = needle == "sing-box" ? current_http_outbound_tags() : {};
let udp_http_notice_emitted = false;
for (let line in lines) {
@@ -1364,8 +1349,7 @@ function render_matching_log_tail(needle, max_lines) {
continue;
if (line_contains(line, needle))
{
let udp_outbound = udp_unsupported_outbound_tag(line);
if (udp_outbound != "" && http_outbounds[udp_outbound]) {
if (needle == "sing-box" && is_udp_unsupported_outbound_log(line)) {
if (!udp_http_notice_emitted) {
push(filtered, "UDP traffic through HTTP outbounds is not supported by sing-box; repeated UDP warnings for HTTP outbounds are hidden by Podkop Plus.");
udp_http_notice_emitted = true;
@@ -1389,6 +1373,7 @@ function render_podkop_logs() {
let lines = split(read_stdin(), "\n");
let filtered = [];
let start = -1;
let udp_http_notice_emitted = false;
for (let line in lines) {
if (line == "")
@@ -1396,6 +1381,14 @@ function render_podkop_logs() {
if (!line_contains(line, "podkop-plus") && !line_contains(line, "sing-box"))
continue;
if (line_contains(line, "sing-box") && is_udp_unsupported_outbound_log(line)) {
if (!udp_http_notice_emitted) {
push(filtered, "UDP traffic through HTTP outbounds is not supported by sing-box; repeated UDP warnings for HTTP outbounds are hidden by Podkop Plus.");
udp_http_notice_emitted = true;
}
continue;
}
if (line_contains(line, "podkop-plus") && line_contains(line, "Starting Podkop Plus"))
start = length(filtered);