Skip to content

Commit fedeb86

Browse files
committed
fix: fakeip-range6 empty vernesong#5081
1 parent 9e64414 commit fedeb86

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

luci-app-openclash/luasrc/model/cbi/openclash/settings.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,17 @@ o.placeholder = translate("5000 or 1234-2345")
265265
o.rmempty = true
266266

267267
o = s2:option(ListValue, "proto", translate("Proto"))
268+
o:value("both", translate("Both"))
268269
o:value("udp", translate("UDP"))
269270
o:value("tcp", translate("TCP"))
270-
o:value("both", translate("Both"))
271-
o.default = "tcp"
271+
o.default = "both"
272272
o.rmempty = false
273273

274274
o = s2:option(ListValue, "family", translate("Family"))
275+
o:value("both", translate("Both"))
275276
o:value("ipv4", translate("IPv4"))
276277
o:value("ipv6", translate("IPv6"))
277-
o:value("both", translate("Both"))
278-
o.default = "tcp"
278+
o.default = "both"
279279
o.rmempty = false
280280

281281
o = s2:option(ListValue, "interface", translate("Interface"))

luci-app-openclash/root/etc/init.d/openclash

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -870,13 +870,21 @@ upnp_exclude()
870870
ipv6_suffix_to_nft_format()
871871
{
872872
local ipv6_with_prefix="$1"
873-
if [[ "$ipv6_with_prefix" =~ / ]] || [ -n "$(echo ${ipv6_with_prefix} | grep '/')" ]; then
874-
local suffix="${ipv6_with_prefix%%/*}"
875-
local prefix="${ipv6_with_prefix##*/}"
876-
echo "& $prefix == $suffix"
877-
else
878-
echo "$ipv6_with_prefix"
873+
874+
if ! echo "$ipv6_with_prefix" | grep -q '/'; then
875+
echo "{ $ipv6_with_prefix }"
876+
return
877+
fi
878+
879+
local addr="${ipv6_with_prefix%%/*}"
880+
local suffix="${ipv6_with_prefix##*/}"
881+
882+
if echo "$suffix" | grep -qE '^[0-9]+$'; then
883+
echo "${addr}/${suffix}"
884+
return
879885
fi
886+
887+
echo "& ${suffix} == ${addr}"
880888
} 2>/dev/null
881889

882890
firewall_lan_ac_traffic()
@@ -3718,7 +3726,12 @@ get_config()
37183726
else
37193727
fakeip_range6=$(uci_get_config "fakeip_range6")
37203728
fi
3721-
[ -z "$fakeip_range6" ] && fakeip_range6=0
3729+
if [ -z "$fakeip_range6" ]; then
3730+
fakeip_range6="fdfe:dcba:9876::1/64"
3731+
fake_ip_range6_enable=0
3732+
else
3733+
fake_ip_range6_enable=1
3734+
fi
37223735

37233736
lan_interface_name=$(uci_get_config "lan_interface_name" || echo 0)
37243737
if [ "$lan_interface_name" = "0" ]; then
@@ -3820,7 +3833,7 @@ start_service()
38203833
"$find_process_mode" "$fakeip_range" "$ipv6_mode" "$stack_type_v6" "$enable_unified_delay"\
38213834
"$enable_respect_rules" "$custom_fakeip_filter_mode" "$iptables_compat" "$disable_quic_go_gso" "$cors_allow"\
38223835
"$geo_custom_url" "$geoip_custom_url" "$geosite_custom_url" "$geoasn_custom_url"\
3823-
"$lgbm_auto_update" "$lgbm_custom_url" "$lgbm_update_interval" "$smart_collect" "$smart_collect_size" "$fakeip_range6"
3836+
"$lgbm_auto_update" "$lgbm_custom_url" "$lgbm_update_interval" "$smart_collect" "$smart_collect_size" "$fakeip_range6" "$fake_ip_range6_enable"
38243837

38253838
/usr/share/openclash/yml_rules_change.sh \
38263839
"$enable_custom_clash_rules" "$TMP_CONFIG_FILE"\

luci-app-openclash/root/usr/share/openclash/yml_change.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ begin
378378
smart_collect = '${44}' == '1'
379379
smart_collect_size = '${45}'
380380
fake_ip_range6 = '${46}'
381+
fake_ip_range6_enable = '${47}' == '1'
381382
default_dashboard = '$default_dashboard'
382383
yacd_type = '$yacd_type'
383384
dashboard_type = '$dashboard_type'
@@ -480,7 +481,7 @@ begin
480481
else
481482
Value['dns']['enhanced-mode'] = 'fake-ip'
482483
Value['dns']['fake-ip-range'] = fake_ip_range
483-
if Value['dns']['ipv6'] and fake_ip_range6 != '0'
484+
if Value['dns']['ipv6'] and fake_ip_range6_enable
484485
Value['dns']['fake-ip-range6'] = fake_ip_range6
485486
end
486487
end

0 commit comments

Comments
 (0)