From 74c2daf076477414d06756c874665f2b487bffff Mon Sep 17 00:00:00 2001 From: paladin4fan <34474436+paladin4fan@users.noreply.github.com> Date: Sun, 1 May 2022 17:15:04 +0800 Subject: [PATCH] fix ipv6 judgement Fix the issue witch IPv4 address with :port would be thought as IPv6 address --- root/etc/init.d/frpc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/root/etc/init.d/frpc b/root/etc/init.d/frpc index 7458925..4608517 100755 --- a/root/etc/init.d/frpc +++ b/root/etc/init.d/frpc @@ -33,13 +33,16 @@ append_options() { v="$(eval echo "\$$o")" if [ -n "$v" ] ; then # add brackets when ipv6 address - if ( echo "$o" | grep -qE 'addr|ip' ) && - ( echo "$v" | grep -q ':' ) ; then - v="[$v]" + if ( echo "$o" | grep -qE 'addr|ip' ); then + num=`eval echo "$v" | awk -F':' '{print NF-1}' ` + if [ "$num" -gt 1 ] ; then + v="[$v]" + fi fi echo "${o} = $v" >>"$file" fi + done }