diff --git a/scripts/core/alias.sh b/scripts/core/alias.sh index 233cee5..db3c069 100644 --- a/scripts/core/alias.sh +++ b/scripts/core/alias.sh @@ -38,6 +38,12 @@ _clashctl_real_on_target() { _clash_alias_project_dir() { local self_dir + + if [ -n "${CLASH_FOR_LINUX_PROJECT_DIR:-}" ]; then + echo "$CLASH_FOR_LINUX_PROJECT_DIR" + return 0 + fi + self_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" echo "$self_dir" } @@ -56,10 +62,17 @@ _clash_alias_yq_bin() { _clash_alias_env_value() { local key="$1" - local env_file + local env_file value + + case "$key" in + ""|*[!A-Za-z0-9_]*) + return 0 + ;; + esac - if [ -n "${!key:-}" ]; then - printf '%s' "${!key}" + eval "value=\${$key:-}" + if [ -n "${value:-}" ]; then + printf '%s' "$value" return 0 fi diff --git a/scripts/core/common.sh b/scripts/core/common.sh index 4207cca..4eae1e8 100644 --- a/scripts/core/common.sh +++ b/scripts/core/common.sh @@ -2614,10 +2614,11 @@ install_shell_alias_entry() { cat > "$profile_file" </dev/null || true - die "本地订阅不是 Clash YAML,且无法识别为 Base64 或 vmess/vless/trojan/tuic 分享链接:$local_path" + die "本地订阅不是 Clash YAML,且无法识别为 Base64 或 vmess/vless/trojan/tuic/hysteria2/hy2/anytls 分享链接:$local_path" } download_candidate_probe() { @@ -721,7 +721,15 @@ download_subscription_yaml() { subscription_cache_identity() { local url="$1" local fmt="${2:-clash}" - printf '%s|%s' "$fmt" "$url" + local ua="" + + case "$fmt" in + clash|convert) + ua="$(subconverter_subscription_user_agent)" + ;; + esac + + printf '%s|%s|%s' "$fmt" "$url" "$ua" } subscription_cache_key() { @@ -3311,7 +3319,7 @@ subscription_yaml_has_no_nodes() { } subconverter_default_subscription_user_agent() { - echo "clash.meta/1.18.0 clash/1.18.0 subconverter/0.9.0" + echo "clash-verge/v2.2.3" } subconverter_subscription_user_agent() {