@@ -785,13 +785,13 @@ check_core_status()
785
785
fi
786
786
else
787
787
reg4=' ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$'
788
- while ( [ -n " $( pidof clash) " ] && [ " $CORE_HTTP_CODE " != " 200" ] && [ " $TUN_WAIT " -le 120 ] && [[ " $ lan_ip" =~ $ reg4 ] ] )
788
+ while ( [ -n " $( pidof clash) " ] && [ " $CORE_HTTP_CODE " != " 200" ] && [ " $TUN_WAIT " -le 120 ] && [ -n " $( echo ${ lan_ip} | grep -Eo ${ reg4} ) " ] )
789
789
do
790
790
CORE_HTTP_CODE=$( curl -m 5 -o /dev/null -s -w ' %{http_code}' -H ' Content-Type: application/json' -H " Authorization: Bearer ${da_password} " -XGET http://${lan_ip} :${cn_port} /group)
791
791
let TUN_WAIT++
792
792
sleep 1
793
793
done > /dev/null 2>&1
794
- if ! [[ " $ lan_ip" =~ $ reg4 ] ]; then
794
+ if [ -z " $( echo ${ lan_ip} | grep -Eo ${ reg4} ) " ]; then
795
795
LOG_OUT " Error: LAN IP Address Get Error, Please Check The LAN Interface Setting or Choose the Correct Interface in the Setting!"
796
796
sleep 10
797
797
fi
@@ -957,7 +957,7 @@ firewall_rule_exclude()
957
957
958
958
ipv6_suffix_to_nft_format () {
959
959
local ipv6_with_prefix=" $1 "
960
- if [[ " $ipv6_with_prefix " =~ / ]]; then
960
+ if [[ " $ipv6_with_prefix " =~ / ]] || [ -n " $( echo ${ipv6_with_prefix} | grep ' / ' ) " ] ; then
961
961
local suffix=" ${ipv6_with_prefix%%/* } "
962
962
local prefix=" ${ipv6_with_prefix##*/ } "
963
963
echo " & $prefix == $suffix "
@@ -1043,7 +1043,7 @@ firewall_rule_exclude()
1043
1043
nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto {ipv6} tcp sport " $i " counter return > /dev/null 2>&1
1044
1044
nft insert rule inet fw4 openclash_v6 position 0 meta nfproto {ipv6} tcp sport " $i " counter return > /dev/null 2>&1
1045
1045
else
1046
- if [[ " $dest_ip " =~ , ]]; then
1046
+ if [[ " $dest_ip " =~ , ]] || [ -n " $( echo ${dest_ip} | grep ' , ' ) " ] ; then
1047
1047
nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { " $dest_ip " } tcp sport " $i " counter return > /dev/null 2>&1
1048
1048
nft insert rule inet fw4 openclash_v6 position 0 ip6 saddr { " $dest_ip " } tcp sport " $i " counter return > /dev/null 2>&1
1049
1049
else
@@ -1058,7 +1058,7 @@ firewall_rule_exclude()
1058
1058
if [ -z " $dest_ip " ]; then
1059
1059
nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto {ipv6} udp sport " $i " counter return > /dev/null 2>&1
1060
1060
else
1061
- if [[ " $dest_ip " =~ , ]]; then
1061
+ if [[ " $dest_ip " =~ , ]] || [ -n " $( echo ${dest_ip} | grep ' , ' ) " ] ; then
1062
1062
nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { " $dest_ip " } udp sport " $i " counter return > /dev/null 2>&1
1063
1063
else
1064
1064
nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr " $nft_ipv6 " udp sport " $i " counter return > /dev/null 2>&1
@@ -2920,9 +2920,9 @@ get_config()
2920
2920
2921
2921
lan_interface_name=$( uci -q get openclash.config.lan_interface_name || echo 0)
2922
2922
if [ " $lan_interface_name " = " 0" ]; then
2923
- lan_ip=$( uci -q get network.lan.ipaddr | awk -F ' /' ' {print $1}' 2> /dev/null | tr -d ' \n' || ip address show $( uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w " inet" 2> /dev/null | grep -Eo ' inet [0-9\.]+' | awk ' {print $2}' | head -1 | tr -d ' \n' || ip addr show 2> /dev/null | grep -w ' inet' | grep ' global' | grep ' brd' | grep -Eo ' inet [0-9\.]+' | awk ' {print $2}' | head -n 1 | tr -d ' \n' )
2923
+ lan_ip=$( uci -q get network.lan.ipaddr 2> /dev/null | awk -F ' /' ' {print $1}' 2> /dev/null | tr -d ' \n' || ip address show $( uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w " inet" 2> /dev/null | grep -Eo ' inet [0-9\.]+' | awk ' {print $2}' | head -1 | tr -d ' \n' || ip addr show 2> /dev/null | grep -w ' inet' | grep ' global' | grep ' brd' | grep -Eo ' inet [0-9\.]+' | awk ' {print $2}' | head -n 1 | tr -d ' \n' )
2924
2924
else
2925
- lan_ip=$( ip address show $lan_interface_name | grep -w " inet" 2> /dev/null | grep -Eo ' inet [0-9\.]+' | awk ' {print $2}' | head -1 | tr -d ' \n' )
2925
+ lan_ip=$( ip address show $lan_interface_name 2> /dev/null | grep -w " inet" 2> /dev/null | grep -Eo ' inet [0-9\.]+' | awk ' {print $2}' | head -1 | tr -d ' \n' )
2926
2926
fi
2927
2927
2928
2928
wan_ip4s=$( /usr/share/openclash/openclash_get_network.lua " wanip" 2> /dev/null)
0 commit comments