feat(clashsub): support custom User-Agent for subscription download

Fix #414
This commit is contained in:
libm committed 2025-12-31 15:15:18 +08:00
1 parent 293b6200e5
commit 7998ede44a
2 files changed
+6 -4

No files matched your search

+3
View File
@@ -7,6 +7,9 @@ CLASH_BASE_DIR=~/clashctl
# 机场订阅
CLASH_CONFIG_URL=
# 下载订阅时的 UserAgent
CLASH_SUB_UA=clash
# init 系统(自动识别)
INIT_TYPE=
+3 -4
View File
@@ -146,7 +146,6 @@ function _download_config() {
_download_raw_config() {
local dest=$1
local url=$2
local agent='clash'
curl \
--silent \
@@ -156,7 +155,7 @@ _download_raw_config() {
--location \
--max-time 5 \
--retry 1 \
--user-agent "$agent" \
--user-agent "$CLASH_SUB_UA" \
--output "$dest" \
"$url" ||
wget \
@@ -164,7 +163,7 @@ _download_raw_config() {
--no-check-certificate \
--timeout 5 \
--tries 1 \
--user-agent "$agent" \
--user-agent "$CLASH_SUB_UA" \
--output-document "$dest" \
"$url"
}
@@ -188,7 +187,7 @@ _download_convert_config() {
--write-out '%{url_effective}' \
"$base_url"
)
curl --silent --output "$dest" "$convert_url"
curl --user-agent "$CLASH_SUB_UA" --silent --output "$dest" "$convert_url"
flag=$?
_stop_convert
return $flag