mirror of
https://github.com/wnlen/clash-for-linux.git
synced 2026-10-10 04:03:04 +08:00
This commit is contained in:
@@ -1926,7 +1926,7 @@ runtime_config_allow_lan() {
|
||||
file="$(runtime_config_file)"
|
||||
[ -s "$file" ] || return 1
|
||||
|
||||
value="$("$(yq_bin)" eval '.["allow-lan"] // true' "$file" 2>/dev/null | head -n 1)"
|
||||
value="$("$(yq_bin)" eval '.["allow-lan"]' "$file" 2>/dev/null | head -n 1)"
|
||||
case "$value" in
|
||||
false) echo "false" ;;
|
||||
*) echo "true" ;;
|
||||
|
||||
@@ -424,7 +424,7 @@ config_allow_lan() {
|
||||
local value
|
||||
|
||||
ensure_config_files
|
||||
value="$("$(yq_bin)" eval '.["allow-lan"] // true' "$file" 2>/dev/null | head -n 1)"
|
||||
value="$("$(yq_bin)" eval '.["allow-lan"]' "$file" 2>/dev/null | head -n 1)"
|
||||
case "$value" in
|
||||
false) echo "false" ;;
|
||||
*) echo "true" ;;
|
||||
|
||||
@@ -76,7 +76,6 @@ resolve_runtime_ports() {
|
||||
|
||||
ensure_controller_secret() { printf 'test-secret\n'; }
|
||||
runtime_dashboard_dir() { printf '%s/dashboard\n' "$RUNTIME_DIR"; }
|
||||
config_allow_lan() { printf 'true\n'; }
|
||||
tun_enabled() { printf 'false\n'; }
|
||||
tun_stack() { printf 'mixed\n'; }
|
||||
tun_auto_route() { printf 'false\n'; }
|
||||
@@ -84,6 +83,22 @@ tun_auto_redirect() { printf 'false\n'; }
|
||||
tun_strict_route() { printf 'false\n'; }
|
||||
tun_dns_hijack() { printf 'any:53\n'; }
|
||||
|
||||
set_config_allow_lan false
|
||||
|
||||
actual="$("$BIN_DIR/yq" eval '.["allow-lan"]' "$CONFIG_DIR/template.yaml")"
|
||||
if [ "$actual" != "false" ]; then
|
||||
echo "not ok - writes disabled LAN setting: got '$actual', expected 'false'" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "ok - writes disabled LAN setting"
|
||||
|
||||
actual="$(config_allow_lan)"
|
||||
if [ "$actual" != "false" ]; then
|
||||
echo "not ok - reads disabled LAN setting: got '$actual', expected 'false'" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "ok - reads disabled LAN setting"
|
||||
|
||||
sample_config="$tmp_dir/runtime-config.yaml"
|
||||
cat > "$sample_config" <<'YAML'
|
||||
port: 7890
|
||||
@@ -141,6 +156,16 @@ assert_yq "removes legacy socks-port" 'has("socks-port")' "false"
|
||||
assert_yq "removes legacy redir-port" 'has("redir-port")' "false"
|
||||
assert_yq "removes legacy tproxy-port" 'has("tproxy-port")' "false"
|
||||
assert_yq "keeps controller normalization" '.["external-controller"]' "0.0.0.0:9090"
|
||||
assert_yq "keeps LAN proxy disabled" '.["allow-lan"]' "false"
|
||||
|
||||
cp "$sample_config" "$RUNTIME_DIR/config.yaml"
|
||||
actual="$(runtime_config_allow_lan)"
|
||||
if [ "$actual" != "false" ]; then
|
||||
echo "not ok - reports disabled runtime LAN status: got '$actual', expected 'false'" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "ok - reports disabled runtime LAN status"
|
||||
|
||||
assert_yq "preserves subscription IPv6" '.ipv6' "true"
|
||||
assert_yq "preserves subscription DNS IPv6" '.dns.ipv6' "true"
|
||||
assert_yq "preserves Hysteria2 proxy type" '.proxies[0].type' "hysteria2"
|
||||
|
||||
Reference in New Issue
Block a user