Support gzip-compressed subscriptions

This commit is contained in:
ushan0v
2026-06-09 01:29:09 +03:00
parent 5ae4117dfb
commit a9ce644bc6
7 changed files with 92 additions and 5 deletions
+7
View File
@@ -564,6 +564,13 @@
"src/podkop/tabs/monitoring/render.ts:29"
]
},
{
"call": "Components",
"key": "Components",
"places": [
"../luci-app-podkop-plus/htdocs/luci-static/resources/view/podkop/podkop.js:497"
]
},
{
"call": "compressed",
"key": "compressed",
+4
View File
@@ -359,6 +359,10 @@ msgstr ""
msgid "Closed"
msgstr ""
#: ../luci-app-podkop-plus/htdocs/luci-static/resources/view/podkop/podkop.js:497
msgid "Components"
msgstr ""
#: src/podkop/helpers/singBoxVariant.ts:52
msgid "compressed"
msgstr ""
+3
View File
@@ -239,6 +239,9 @@ msgstr "Закрыть подключение"
msgid "Closed"
msgstr "Закрытые"
msgid "Components"
msgstr "Компоненты"
msgid "compressed"
msgstr "compressed"
@@ -239,6 +239,9 @@ msgstr "Закрыть подключение"
msgid "Closed"
msgstr "Закрытые"
msgid "Components"
msgstr "Компоненты"
msgid "compressed"
msgstr "compressed"
@@ -359,6 +359,10 @@ msgstr ""
msgid "Closed"
msgstr ""
#: ../luci-app-podkop-plus/htdocs/luci-static/resources/view/podkop/podkop.js:497
msgid "Components"
msgstr ""
#: src/podkop/helpers/singBoxVariant.ts:52
msgid "compressed"
msgstr ""
+67 -5
View File
@@ -36,19 +36,81 @@ subscription_log_normalized_skipped() {
log "$message" "warn"
}
subscription_normalize_content_file() {
subscription_gzip_decode_file() {
local input="$1"
local output="$2"
if subscription_parser_ucode normalize-content "$input" "$output"; then
subscription_log_normalized_skipped "$output"
subscription_validate_normalized_file "$output"
return $?
[ -s "$input" ] || return 1
if command -v gzip >/dev/null 2>&1; then
if gzip -dc "$input" > "$output" 2>/dev/null && [ -s "$output" ]; then
return 0
fi
rm -f "$output"
fi
if command -v gunzip >/dev/null 2>&1; then
if gunzip -c "$input" > "$output" 2>/dev/null && [ -s "$output" ]; then
return 0
fi
rm -f "$output"
fi
if command -v zcat >/dev/null 2>&1; then
if zcat "$input" > "$output" 2>/dev/null && [ -s "$output" ]; then
return 0
fi
rm -f "$output"
fi
return 1
}
subscription_try_decode_gzip_content_file() {
local input="$1"
local tmpfile
tmpfile="$(mktemp)" || return 1
if subscription_gzip_decode_file "$input" "$tmpfile"; then
mv "$tmpfile" "$input" || {
rm -f "$tmpfile"
return 1
}
return 0
fi
rm -f "$tmpfile"
return 1
}
subscription_normalize_content_file() {
local input="$1"
local output="$2"
local normalize_input="$input"
local decoded_tmpfile status
decoded_tmpfile="$(mktemp)" || decoded_tmpfile=""
if [ -n "$decoded_tmpfile" ]; then
if subscription_gzip_decode_file "$input" "$decoded_tmpfile"; then
normalize_input="$decoded_tmpfile"
else
rm -f "$decoded_tmpfile"
decoded_tmpfile=""
fi
fi
if subscription_parser_ucode normalize-content "$normalize_input" "$output"; then
subscription_log_normalized_skipped "$output"
subscription_validate_normalized_file "$output"
status=$?
else
status=1
fi
[ -n "$decoded_tmpfile" ] && rm -f "$decoded_tmpfile"
return "$status"
}
subscription_runtime_outbounds_equal() {
local left="$1"
local right="$2"
@@ -660,6 +660,10 @@ download_subscription_into_cache() {
continue
fi
if subscription_try_decode_gzip_content_file "$raw_tmpfile"; then
log "Decoded gzip-compressed subscription body for rule '$section'" "info"
fi
subscription_extract_ui_metadata "$headers_tmpfile" "$raw_tmpfile" "$metadata_tmpfile" >/dev/null 2>&1 || rm -f "$metadata_tmpfile"
if [ -n "$metadata_output_path" ]; then
if [ -s "$metadata_tmpfile" ] && subscription_cache_ucode object-has-extra-keys "$metadata_tmpfile" >/dev/null 2>&1; then