Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions scripts/core/alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions scripts/core/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2614,10 +2614,11 @@ install_shell_alias_entry() {
cat > "$profile_file" <<EOF
#!/usr/bin/env bash
# clash-for-linux shell entry
export CLASH_FOR_LINUX_PROJECT_DIR="$PROJECT_DIR"
export PATH="$(command_install_dir):\$PATH"

if [ -n "\${BASH_VERSION:-}" ] && [ -z "\${CLASH_FOR_LINUX_SHELL_LOADED:-}" ]; then
CLASH_FOR_LINUX_SHELL_LOADED="1"
if [ -z "\${CLASH_FOR_LINUX_SHELL_LOADED:-}" ] && { [ -n "\${BASH_VERSION:-}" ] || [ -n "\${ZSH_VERSION:-}" ]; }; then
export CLASH_FOR_LINUX_SHELL_LOADED="1"
source "$alias_file"
fi

Expand Down
16 changes: 12 additions & 4 deletions scripts/core/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ local_subscription_share_links_to_subconverter_url() {
sub(/[[:space:]]+$/, "")
}
$0 == "" || $0 ~ /^#/ { next }
$0 ~ /^(vmess|vless|trojan|tuic):\/\// {
$0 ~ /^(vmess|vless|trojan|tuic|hysteria2|hy2|anytls):\/\// {
if (out != "") {
out = out "|"
}
Expand Down Expand Up @@ -577,7 +577,7 @@ local_subscription_convert_url_from_url() {
fi

rm -f "$decoded_file" 2>/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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down