~修复proxies只有一行时无法正确生成配置文件的bug

This commit is contained in:
juewuy
2026-10-24 18:07:49 +08:00
parent b3b703778f
commit 0c0de44aea
2 changed files with 8 additions and 1 deletions
+4 -1
View File
@@ -4,6 +4,9 @@
check_config() { #检查clash配置文件
#检测节点或providers
sed -n "/^proxies:/,/^[a-z]/ { /^[a-z]/d; p; }" "$core_config_new" >"$TMPDIR"/proxies.yaml
if [ ! -s "$TMPDIR"/proxies.yaml ]; then
sed -n 's/^proxies:[[:space:]]*\[\(.*\)\][[:space:]]*$/ - \1/p' "$core_config_new" >"$TMPDIR"/proxies.yaml
fi
if ! grep -Eq 'server:|server":|server'\'':' "$TMPDIR"/proxies.yaml && ! grep -q 'proxy-providers:' "$core_config_new"; then
echo "-----------------------------------------------"
logger "获取到了配置文件【$core_config_new】,但似乎并不包含正确的节点信息!" 31
@@ -38,4 +41,4 @@ check_config() { #检查clash配置文件
done <"$TMPDIR"/clash_proxies
rm -rf "$TMPDIR"/clash_proxies
}
}
}
+4
View File
@@ -121,6 +121,10 @@ split_and_customize_yaml_parts() {
yaml_char='proxies proxy-groups proxy-providers rules rule-providers sub-rules listeners'
for char in $yaml_char; do
sed -n "/^$char:/,/^[a-z]/ { /^[a-z]/d; p; }" $core_config >"$TMPDIR"/${char}.yaml
#支持 Clash 常见的单行 flow-style 节点列表,例如 proxies: [{name: ..., type: ...}]
if [ "$char" = proxies ] && [ ! -s "$TMPDIR"/proxies.yaml ]; then
sed -n 's/^proxies:[[:space:]]*\[\(.*\)\][[:space:]]*$/ - \1/p' "$core_config" >"$TMPDIR"/proxies.yaml
fi
done
#跳过本地tls证书验证
[ "$skip_cert" != "OFF" ] && sed -i 's/skip-cert-verify: false/skip-cert-verify: true/' "$TMPDIR"/proxies.yaml ||